babylon.d.txt 3.1 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */ private _willBeUnregistered: boolean;
  111. /**
  112. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  113. */
  114. unregisterOnNextCall: boolean;
  115. /**
  116. * Creates a new observer
  117. * @param callback defines the callback to call when the observer is notified
  118. * @param mask defines the mask of the observer (used to filter notifications)
  119. * @param scope defines the current scope used to restore the JS context
  120. */
  121. constructor(
  122. /**
  123. * Defines the callback to call when the observer is notified
  124. */
  125. callback: (eventData: T, eventState: EventState) => void,
  126. /**
  127. * Defines the mask of the observer (used to filter notifications)
  128. */
  129. mask: number,
  130. /**
  131. * Defines the current scope used to restore the JS context
  132. */
  133. scope?: any);
  134. }
  135. /**
  136. * Represent a list of observers registered to multiple Observables object.
  137. */
  138. export class MultiObserver<T> {
  139. private _observers;
  140. private _observables;
  141. /**
  142. * Release associated resources
  143. */
  144. dispose(): void;
  145. /**
  146. * Raise a callback when one of the observable will notify
  147. * @param observables defines a list of observables to watch
  148. * @param callback defines the callback to call on notification
  149. * @param mask defines the mask used to filter notifications
  150. * @param scope defines the current scope used to restore the JS context
  151. * @returns the new MultiObserver
  152. */
  153. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  154. }
  155. /**
  156. * The Observable class is a simple implementation of the Observable pattern.
  157. *
  158. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  159. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  160. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  161. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  162. */
  163. export class Observable<T> {
  164. private _observers;
  165. private _eventState;
  166. private _onObserverAdded;
  167. /**
  168. * Gets the list of observers
  169. */
  170. readonly observers: Array<Observer<T>>;
  171. /**
  172. * Creates a new observable
  173. * @param onObserverAdded defines a callback to call when a new observer is added
  174. */
  175. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  176. /**
  177. * Create a new Observer with the specified callback
  178. * @param callback the callback that will be executed for that Observer
  179. * @param mask the mask used to filter observers
  180. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  181. * @param scope optional scope for the callback to be called from
  182. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  183. * @returns the new observer created for the callback
  184. */
  185. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  186. /**
  187. * Create a new Observer with the specified callback and unregisters after the next notification
  188. * @param callback the callback that will be executed for that Observer
  189. * @returns the new observer created for the callback
  190. */
  191. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  192. /**
  193. * Remove an Observer from the Observable object
  194. * @param observer the instance of the Observer to remove
  195. * @returns false if it doesn't belong to this Observable
  196. */
  197. remove(observer: Nullable<Observer<T>>): boolean;
  198. /**
  199. * Remove a callback from the Observable object
  200. * @param callback the callback to remove
  201. * @param scope optional scope. If used only the callbacks with this scope will be removed
  202. * @returns false if it doesn't belong to this Observable
  203. */
  204. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  205. private _deferUnregister;
  206. private _remove;
  207. /**
  208. * Moves the observable to the top of the observer list making it get called first when notified
  209. * @param observer the observer to move
  210. */
  211. makeObserverTopPriority(observer: Observer<T>): void;
  212. /**
  213. * Moves the observable to the bottom of the observer list making it get called last when notified
  214. * @param observer the observer to move
  215. */
  216. makeObserverBottomPriority(observer: Observer<T>): void;
  217. /**
  218. * Notify all Observers by calling their respective callback with the given data
  219. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  220. * @param eventData defines the data to send to all observers
  221. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  222. * @param target defines the original target of the state
  223. * @param currentTarget defines the current target of the state
  224. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  225. */
  226. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  227. /**
  228. * Calling this will execute each callback, expecting it to be a promise or return a value.
  229. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  230. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  231. * and it is crucial that all callbacks will be executed.
  232. * The order of the callbacks is kept, callbacks are not executed parallel.
  233. *
  234. * @param eventData The data to be sent to each callback
  235. * @param mask is used to filter observers defaults to -1
  236. * @param target defines the callback target (see EventState)
  237. * @param currentTarget defines he current object in the bubbling phase
  238. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  239. */
  240. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  241. /**
  242. * Notify a specific observer
  243. * @param observer defines the observer to notify
  244. * @param eventData defines the data to be sent to each callback
  245. * @param mask is used to filter observers defaults to -1
  246. */
  247. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  248. /**
  249. * Gets a boolean indicating if the observable has at least one observer
  250. * @returns true is the Observable has at least one Observer registered
  251. */
  252. hasObservers(): boolean;
  253. /**
  254. * Clear the list of observers
  255. */
  256. clear(): void;
  257. /**
  258. * Clone the current observable
  259. * @returns a new observable
  260. */
  261. clone(): Observable<T>;
  262. /**
  263. * Does this observable handles observer registered with a given mask
  264. * @param mask defines the mask to be tested
  265. * @return whether or not one observer registered with the given mask is handeled
  266. **/
  267. hasSpecificMask(mask?: number): boolean;
  268. }
  269. }
  270. declare module BABYLON {
  271. /**
  272. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  273. * Babylon.js
  274. */
  275. export class DomManagement {
  276. /**
  277. * Checks if the window object exists
  278. * @returns true if the window object exists
  279. */
  280. static IsWindowObjectExist(): boolean;
  281. /**
  282. * Checks if the navigator object exists
  283. * @returns true if the navigator object exists
  284. */
  285. static IsNavigatorAvailable(): boolean;
  286. /**
  287. * Extracts text content from a DOM element hierarchy
  288. * @param element defines the root element
  289. * @returns a string
  290. */
  291. static GetDOMTextContent(element: HTMLElement): string;
  292. }
  293. }
  294. declare module BABYLON {
  295. /**
  296. * Logger used througouht the application to allow configuration of
  297. * the log level required for the messages.
  298. */
  299. export class Logger {
  300. /**
  301. * No log
  302. */
  303. static readonly NoneLogLevel: number;
  304. /**
  305. * Only message logs
  306. */
  307. static readonly MessageLogLevel: number;
  308. /**
  309. * Only warning logs
  310. */
  311. static readonly WarningLogLevel: number;
  312. /**
  313. * Only error logs
  314. */
  315. static readonly ErrorLogLevel: number;
  316. /**
  317. * All logs
  318. */
  319. static readonly AllLogLevel: number;
  320. private static _LogCache;
  321. /**
  322. * Gets a value indicating the number of loading errors
  323. * @ignorenaming
  324. */
  325. static errorsCount: number;
  326. /**
  327. * Callback called when a new log is added
  328. */
  329. static OnNewCacheEntry: (entry: string) => void;
  330. private static _AddLogEntry;
  331. private static _FormatMessage;
  332. private static _LogDisabled;
  333. private static _LogEnabled;
  334. private static _WarnDisabled;
  335. private static _WarnEnabled;
  336. private static _ErrorDisabled;
  337. private static _ErrorEnabled;
  338. /**
  339. * Log a message to the console
  340. */
  341. static Log: (message: string) => void;
  342. /**
  343. * Write a warning message to the console
  344. */
  345. static Warn: (message: string) => void;
  346. /**
  347. * Write an error message to the console
  348. */
  349. static Error: (message: string) => void;
  350. /**
  351. * Gets current log cache (list of logs)
  352. */
  353. static readonly LogCache: string;
  354. /**
  355. * Clears the log cache
  356. */
  357. static ClearLogCache(): void;
  358. /**
  359. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  360. */
  361. static LogLevels: number;
  362. }
  363. }
  364. declare module BABYLON {
  365. /** @hidden */
  366. export class _TypeStore {
  367. /** @hidden */
  368. static RegisteredTypes: {
  369. [key: string]: Object;
  370. };
  371. /** @hidden */
  372. static GetClass(fqdn: string): any;
  373. }
  374. }
  375. declare module BABYLON {
  376. /**
  377. * Class containing a set of static utilities functions for deep copy.
  378. */
  379. export class DeepCopier {
  380. /**
  381. * Tries to copy an object by duplicating every property
  382. * @param source defines the source object
  383. * @param destination defines the target object
  384. * @param doNotCopyList defines a list of properties to avoid
  385. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  386. */
  387. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  388. }
  389. }
  390. declare module BABYLON {
  391. /**
  392. * Class containing a set of static utilities functions for precision date
  393. */
  394. export class PrecisionDate {
  395. /**
  396. * Gets either window.performance.now() if supported or Date.now() else
  397. */
  398. static readonly Now: number;
  399. }
  400. }
  401. declare module BABYLON {
  402. /** @hidden */
  403. export class _DevTools {
  404. static WarnImport(name: string): string;
  405. }
  406. }
  407. declare module BABYLON {
  408. /**
  409. * Interface used to define the mechanism to get data from the network
  410. */
  411. export interface IWebRequest {
  412. /**
  413. * Returns client's response url
  414. */
  415. responseURL: string;
  416. /**
  417. * Returns client's status
  418. */
  419. status: number;
  420. /**
  421. * Returns client's status as a text
  422. */
  423. statusText: string;
  424. }
  425. }
  426. declare module BABYLON {
  427. /**
  428. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  429. */
  430. export class WebRequest implements IWebRequest {
  431. private _xhr;
  432. /**
  433. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  434. * i.e. when loading files, where the server/service expects an Authorization header
  435. */
  436. static CustomRequestHeaders: {
  437. [key: string]: string;
  438. };
  439. /**
  440. * Add callback functions in this array to update all the requests before they get sent to the network
  441. */
  442. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  443. private _injectCustomRequestHeaders;
  444. /**
  445. * Gets or sets a function to be called when loading progress changes
  446. */
  447. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  448. /**
  449. * Returns client's state
  450. */
  451. readonly readyState: number;
  452. /**
  453. * Returns client's status
  454. */
  455. readonly status: number;
  456. /**
  457. * Returns client's status as a text
  458. */
  459. readonly statusText: string;
  460. /**
  461. * Returns client's response
  462. */
  463. readonly response: any;
  464. /**
  465. * Returns client's response url
  466. */
  467. readonly responseURL: string;
  468. /**
  469. * Returns client's response as text
  470. */
  471. readonly responseText: string;
  472. /**
  473. * Gets or sets the expected response type
  474. */
  475. responseType: XMLHttpRequestResponseType;
  476. /** @hidden */
  477. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  478. /** @hidden */
  479. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  480. /**
  481. * Cancels any network activity
  482. */
  483. abort(): void;
  484. /**
  485. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  486. * @param body defines an optional request body
  487. */
  488. send(body?: Document | BodyInit | null): void;
  489. /**
  490. * Sets the request method, request URL
  491. * @param method defines the method to use (GET, POST, etc..)
  492. * @param url defines the url to connect with
  493. */
  494. open(method: string, url: string): void;
  495. /**
  496. * Sets the value of a request header.
  497. * @param name The name of the header whose value is to be set
  498. * @param value The value to set as the body of the header
  499. */
  500. setRequestHeader(name: string, value: string): void;
  501. /**
  502. * Get the string containing the text of a particular header's value.
  503. * @param name The name of the header
  504. * @returns The string containing the text of the given header name
  505. */
  506. getResponseHeader(name: string): Nullable<string>;
  507. }
  508. }
  509. declare module BABYLON {
  510. /**
  511. * File request interface
  512. */
  513. export interface IFileRequest {
  514. /**
  515. * Raised when the request is complete (success or error).
  516. */
  517. onCompleteObservable: Observable<IFileRequest>;
  518. /**
  519. * Aborts the request for a file.
  520. */
  521. abort: () => void;
  522. }
  523. }
  524. declare module BABYLON {
  525. /**
  526. * Define options used to create a render target texture
  527. */
  528. export class RenderTargetCreationOptions {
  529. /**
  530. * Specifies is mipmaps must be generated
  531. */
  532. generateMipMaps?: boolean;
  533. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  534. generateDepthBuffer?: boolean;
  535. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  536. generateStencilBuffer?: boolean;
  537. /** Defines texture type (int by default) */
  538. type?: number;
  539. /** Defines sampling mode (trilinear by default) */
  540. samplingMode?: number;
  541. /** Defines format (RGBA by default) */
  542. format?: number;
  543. }
  544. }
  545. declare module BABYLON {
  546. /**
  547. * @hidden
  548. **/
  549. export class _TimeToken { private _startTimeQuery: Nullable<WebGLQuery>; private _endTimeQuery: Nullable<WebGLQuery>; private _timeElapsedQuery: Nullable<WebGLQuery>; private _timeElapsedQueryEnded: boolean;
  550. }
  551. }
  552. declare module BABYLON {
  553. /** Defines the cross module used constants to avoid circular dependncies */
  554. export class Constants {
  555. /** Defines that alpha blending is disabled */
  556. static readonly ALPHA_DISABLE: number;
  557. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  558. static readonly ALPHA_ADD: number;
  559. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  560. static readonly ALPHA_COMBINE: number;
  561. /** Defines that alpha blending to DEST - SRC * DEST */
  562. static readonly ALPHA_SUBTRACT: number;
  563. /** Defines that alpha blending to SRC * DEST */
  564. static readonly ALPHA_MULTIPLY: number;
  565. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  566. static readonly ALPHA_MAXIMIZED: number;
  567. /** Defines that alpha blending to SRC + DEST */
  568. static readonly ALPHA_ONEONE: number;
  569. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  570. static readonly ALPHA_PREMULTIPLIED: number;
  571. /**
  572. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  573. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  574. */
  575. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  576. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  577. static readonly ALPHA_INTERPOLATE: number;
  578. /**
  579. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  580. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  581. */
  582. static readonly ALPHA_SCREENMODE: number;
  583. /**
  584. * Defines that alpha blending to SRC + DST
  585. * Alpha will be set to SRC ALPHA + DST ALPHA
  586. */
  587. static readonly ALPHA_ONEONE_ONEONE: number;
  588. /**
  589. * Defines that alpha blending to SRC * DST ALPHA + DST
  590. * Alpha will be set to 0
  591. */
  592. static readonly ALPHA_ALPHATOCOLOR: number;
  593. /**
  594. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  595. */
  596. static readonly ALPHA_REVERSEONEMINUS: number;
  597. /**
  598. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  599. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  600. */
  601. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  602. /**
  603. * Defines that alpha blending to SRC + DST
  604. * Alpha will be set to SRC ALPHA
  605. */
  606. static readonly ALPHA_ONEONE_ONEZERO: number;
  607. /** Defines that alpha blending equation a SUM */
  608. static readonly ALPHA_EQUATION_ADD: number;
  609. /** Defines that alpha blending equation a SUBSTRACTION */
  610. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  611. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  612. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  613. /** Defines that alpha blending equation a MAX operation */
  614. static readonly ALPHA_EQUATION_MAX: number;
  615. /** Defines that alpha blending equation a MIN operation */
  616. static readonly ALPHA_EQUATION_MIN: number;
  617. /**
  618. * Defines that alpha blending equation a DARKEN operation:
  619. * It takes the min of the src and sums the alpha channels.
  620. */
  621. static readonly ALPHA_EQUATION_DARKEN: number;
  622. /** Defines that the ressource is not delayed*/
  623. static readonly DELAYLOADSTATE_NONE: number;
  624. /** Defines that the ressource was successfully delay loaded */
  625. static readonly DELAYLOADSTATE_LOADED: number;
  626. /** Defines that the ressource is currently delay loading */
  627. static readonly DELAYLOADSTATE_LOADING: number;
  628. /** Defines that the ressource is delayed and has not started loading */
  629. static readonly DELAYLOADSTATE_NOTLOADED: number;
  630. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  631. static readonly NEVER: number;
  632. /** 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 */
  633. static readonly ALWAYS: number;
  634. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  635. static readonly LESS: number;
  636. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  637. static readonly EQUAL: number;
  638. /** 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 */
  639. static readonly LEQUAL: number;
  640. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  641. static readonly GREATER: number;
  642. /** 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 */
  643. static readonly GEQUAL: number;
  644. /** 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 */
  645. static readonly NOTEQUAL: number;
  646. /** Passed to stencilOperation to specify that stencil value must be kept */
  647. static readonly KEEP: number;
  648. /** Passed to stencilOperation to specify that stencil value must be replaced */
  649. static readonly REPLACE: number;
  650. /** Passed to stencilOperation to specify that stencil value must be incremented */
  651. static readonly INCR: number;
  652. /** Passed to stencilOperation to specify that stencil value must be decremented */
  653. static readonly DECR: number;
  654. /** Passed to stencilOperation to specify that stencil value must be inverted */
  655. static readonly INVERT: number;
  656. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  657. static readonly INCR_WRAP: number;
  658. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  659. static readonly DECR_WRAP: number;
  660. /** Texture is not repeating outside of 0..1 UVs */
  661. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  662. /** Texture is repeating outside of 0..1 UVs */
  663. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  664. /** Texture is repeating and mirrored */
  665. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  666. /** ALPHA */
  667. static readonly TEXTUREFORMAT_ALPHA: number;
  668. /** LUMINANCE */
  669. static readonly TEXTUREFORMAT_LUMINANCE: number;
  670. /** LUMINANCE_ALPHA */
  671. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  672. /** RGB */
  673. static readonly TEXTUREFORMAT_RGB: number;
  674. /** RGBA */
  675. static readonly TEXTUREFORMAT_RGBA: number;
  676. /** RED */
  677. static readonly TEXTUREFORMAT_RED: number;
  678. /** RED (2nd reference) */
  679. static readonly TEXTUREFORMAT_R: number;
  680. /** RG */
  681. static readonly TEXTUREFORMAT_RG: number;
  682. /** RED_INTEGER */
  683. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  684. /** RED_INTEGER (2nd reference) */
  685. static readonly TEXTUREFORMAT_R_INTEGER: number;
  686. /** RG_INTEGER */
  687. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  688. /** RGB_INTEGER */
  689. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  690. /** RGBA_INTEGER */
  691. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  692. /** UNSIGNED_BYTE */
  693. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  694. /** UNSIGNED_BYTE (2nd reference) */
  695. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  696. /** FLOAT */
  697. static readonly TEXTURETYPE_FLOAT: number;
  698. /** HALF_FLOAT */
  699. static readonly TEXTURETYPE_HALF_FLOAT: number;
  700. /** BYTE */
  701. static readonly TEXTURETYPE_BYTE: number;
  702. /** SHORT */
  703. static readonly TEXTURETYPE_SHORT: number;
  704. /** UNSIGNED_SHORT */
  705. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  706. /** INT */
  707. static readonly TEXTURETYPE_INT: number;
  708. /** UNSIGNED_INT */
  709. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  710. /** UNSIGNED_SHORT_4_4_4_4 */
  711. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  712. /** UNSIGNED_SHORT_5_5_5_1 */
  713. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  714. /** UNSIGNED_SHORT_5_6_5 */
  715. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  716. /** UNSIGNED_INT_2_10_10_10_REV */
  717. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  718. /** UNSIGNED_INT_24_8 */
  719. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  720. /** UNSIGNED_INT_10F_11F_11F_REV */
  721. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  722. /** UNSIGNED_INT_5_9_9_9_REV */
  723. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  724. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  725. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  726. /** nearest is mag = nearest and min = nearest and mip = linear */
  727. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  728. /** Bilinear is mag = linear and min = linear and mip = nearest */
  729. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  730. /** Trilinear is mag = linear and min = linear and mip = linear */
  731. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  732. /** nearest is mag = nearest and min = nearest and mip = linear */
  733. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  734. /** Bilinear is mag = linear and min = linear and mip = nearest */
  735. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  736. /** Trilinear is mag = linear and min = linear and mip = linear */
  737. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  738. /** mag = nearest and min = nearest and mip = nearest */
  739. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  740. /** mag = nearest and min = linear and mip = nearest */
  741. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  742. /** mag = nearest and min = linear and mip = linear */
  743. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  744. /** mag = nearest and min = linear and mip = none */
  745. static readonly TEXTURE_NEAREST_LINEAR: number;
  746. /** mag = nearest and min = nearest and mip = none */
  747. static readonly TEXTURE_NEAREST_NEAREST: number;
  748. /** mag = linear and min = nearest and mip = nearest */
  749. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  750. /** mag = linear and min = nearest and mip = linear */
  751. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  752. /** mag = linear and min = linear and mip = none */
  753. static readonly TEXTURE_LINEAR_LINEAR: number;
  754. /** mag = linear and min = nearest and mip = none */
  755. static readonly TEXTURE_LINEAR_NEAREST: number;
  756. /** Explicit coordinates mode */
  757. static readonly TEXTURE_EXPLICIT_MODE: number;
  758. /** Spherical coordinates mode */
  759. static readonly TEXTURE_SPHERICAL_MODE: number;
  760. /** Planar coordinates mode */
  761. static readonly TEXTURE_PLANAR_MODE: number;
  762. /** Cubic coordinates mode */
  763. static readonly TEXTURE_CUBIC_MODE: number;
  764. /** Projection coordinates mode */
  765. static readonly TEXTURE_PROJECTION_MODE: number;
  766. /** Skybox coordinates mode */
  767. static readonly TEXTURE_SKYBOX_MODE: number;
  768. /** Inverse Cubic coordinates mode */
  769. static readonly TEXTURE_INVCUBIC_MODE: number;
  770. /** Equirectangular coordinates mode */
  771. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  772. /** Equirectangular Fixed coordinates mode */
  773. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  774. /** Equirectangular Fixed Mirrored coordinates mode */
  775. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  776. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  777. static readonly SCALEMODE_FLOOR: number;
  778. /** Defines that texture rescaling will look for the nearest power of 2 size */
  779. static readonly SCALEMODE_NEAREST: number;
  780. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  781. static readonly SCALEMODE_CEILING: number;
  782. /**
  783. * The dirty texture flag value
  784. */
  785. static readonly MATERIAL_TextureDirtyFlag: number;
  786. /**
  787. * The dirty light flag value
  788. */
  789. static readonly MATERIAL_LightDirtyFlag: number;
  790. /**
  791. * The dirty fresnel flag value
  792. */
  793. static readonly MATERIAL_FresnelDirtyFlag: number;
  794. /**
  795. * The dirty attribute flag value
  796. */
  797. static readonly MATERIAL_AttributesDirtyFlag: number;
  798. /**
  799. * The dirty misc flag value
  800. */
  801. static readonly MATERIAL_MiscDirtyFlag: number;
  802. /**
  803. * The all dirty flag value
  804. */
  805. static readonly MATERIAL_AllDirtyFlag: number;
  806. /**
  807. * Returns the triangle fill mode
  808. */
  809. static readonly MATERIAL_TriangleFillMode: number;
  810. /**
  811. * Returns the wireframe mode
  812. */
  813. static readonly MATERIAL_WireFrameFillMode: number;
  814. /**
  815. * Returns the point fill mode
  816. */
  817. static readonly MATERIAL_PointFillMode: number;
  818. /**
  819. * Returns the point list draw mode
  820. */
  821. static readonly MATERIAL_PointListDrawMode: number;
  822. /**
  823. * Returns the line list draw mode
  824. */
  825. static readonly MATERIAL_LineListDrawMode: number;
  826. /**
  827. * Returns the line loop draw mode
  828. */
  829. static readonly MATERIAL_LineLoopDrawMode: number;
  830. /**
  831. * Returns the line strip draw mode
  832. */
  833. static readonly MATERIAL_LineStripDrawMode: number;
  834. /**
  835. * Returns the triangle strip draw mode
  836. */
  837. static readonly MATERIAL_TriangleStripDrawMode: number;
  838. /**
  839. * Returns the triangle fan draw mode
  840. */
  841. static readonly MATERIAL_TriangleFanDrawMode: number;
  842. /**
  843. * Stores the clock-wise side orientation
  844. */
  845. static readonly MATERIAL_ClockWiseSideOrientation: number;
  846. /**
  847. * Stores the counter clock-wise side orientation
  848. */
  849. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  850. /**
  851. * Nothing
  852. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  853. */
  854. static readonly ACTION_NothingTrigger: number;
  855. /**
  856. * On pick
  857. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  858. */
  859. static readonly ACTION_OnPickTrigger: number;
  860. /**
  861. * On left pick
  862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  863. */
  864. static readonly ACTION_OnLeftPickTrigger: number;
  865. /**
  866. * On right pick
  867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  868. */
  869. static readonly ACTION_OnRightPickTrigger: number;
  870. /**
  871. * On center pick
  872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  873. */
  874. static readonly ACTION_OnCenterPickTrigger: number;
  875. /**
  876. * On pick down
  877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  878. */
  879. static readonly ACTION_OnPickDownTrigger: number;
  880. /**
  881. * On double pick
  882. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  883. */
  884. static readonly ACTION_OnDoublePickTrigger: number;
  885. /**
  886. * On pick up
  887. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  888. */
  889. static readonly ACTION_OnPickUpTrigger: number;
  890. /**
  891. * On pick out.
  892. * This trigger will only be raised if you also declared a OnPickDown
  893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  894. */
  895. static readonly ACTION_OnPickOutTrigger: number;
  896. /**
  897. * On long press
  898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  899. */
  900. static readonly ACTION_OnLongPressTrigger: number;
  901. /**
  902. * On pointer over
  903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  904. */
  905. static readonly ACTION_OnPointerOverTrigger: number;
  906. /**
  907. * On pointer out
  908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  909. */
  910. static readonly ACTION_OnPointerOutTrigger: number;
  911. /**
  912. * On every frame
  913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  914. */
  915. static readonly ACTION_OnEveryFrameTrigger: number;
  916. /**
  917. * On intersection enter
  918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  919. */
  920. static readonly ACTION_OnIntersectionEnterTrigger: number;
  921. /**
  922. * On intersection exit
  923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  924. */
  925. static readonly ACTION_OnIntersectionExitTrigger: number;
  926. /**
  927. * On key down
  928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  929. */
  930. static readonly ACTION_OnKeyDownTrigger: number;
  931. /**
  932. * On key up
  933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  934. */
  935. static readonly ACTION_OnKeyUpTrigger: number;
  936. /**
  937. * Billboard mode will only apply to Y axis
  938. */
  939. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  940. /**
  941. * Billboard mode will apply to all axes
  942. */
  943. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  944. /**
  945. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  946. */
  947. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  948. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  949. * Test order :
  950. * Is the bounding sphere outside the frustum ?
  951. * If not, are the bounding box vertices outside the frustum ?
  952. * It not, then the cullable object is in the frustum.
  953. */
  954. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  955. /** Culling strategy : Bounding Sphere Only.
  956. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  957. * It's also less accurate than the standard because some not visible objects can still be selected.
  958. * Test : is the bounding sphere outside the frustum ?
  959. * If not, then the cullable object is in the frustum.
  960. */
  961. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  962. /** Culling strategy : Optimistic Inclusion.
  963. * This in an inclusion test first, then the standard exclusion test.
  964. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  965. * 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.
  966. * Anyway, it's as accurate as the standard strategy.
  967. * Test :
  968. * Is the cullable object bounding sphere center in the frustum ?
  969. * If not, apply the default culling strategy.
  970. */
  971. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  972. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  973. * This in an inclusion test first, then the bounding sphere only exclusion test.
  974. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  975. * 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.
  976. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  977. * Test :
  978. * Is the cullable object bounding sphere center in the frustum ?
  979. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  980. */
  981. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  982. /**
  983. * No logging while loading
  984. */
  985. static readonly SCENELOADER_NO_LOGGING: number;
  986. /**
  987. * Minimal logging while loading
  988. */
  989. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  990. /**
  991. * Summary logging while loading
  992. */
  993. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  994. /**
  995. * Detailled logging while loading
  996. */
  997. static readonly SCENELOADER_DETAILED_LOGGING: number;
  998. }
  999. }
  1000. declare module BABYLON {
  1001. /**
  1002. * This represents the required contract to create a new type of texture loader.
  1003. */
  1004. export interface IInternalTextureLoader {
  1005. /**
  1006. * Defines wether the loader supports cascade loading the different faces.
  1007. */
  1008. supportCascades: boolean;
  1009. /**
  1010. * This returns if the loader support the current file information.
  1011. * @param extension defines the file extension of the file being loaded
  1012. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1013. * @param fallback defines the fallback internal texture if any
  1014. * @param isBase64 defines whether the texture is encoded as a base64
  1015. * @param isBuffer defines whether the texture data are stored as a buffer
  1016. * @returns true if the loader can load the specified file
  1017. */
  1018. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1019. /**
  1020. * Transform the url before loading if required.
  1021. * @param rootUrl the url of the texture
  1022. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1023. * @returns the transformed texture
  1024. */
  1025. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1026. /**
  1027. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1028. * @param rootUrl the url of the texture
  1029. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1030. * @returns the fallback texture
  1031. */
  1032. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1033. /**
  1034. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1035. * @param data contains the texture data
  1036. * @param texture defines the BabylonJS internal texture
  1037. * @param createPolynomials will be true if polynomials have been requested
  1038. * @param onLoad defines the callback to trigger once the texture is ready
  1039. * @param onError defines the callback to trigger in case of error
  1040. */
  1041. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1042. /**
  1043. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1044. * @param data contains the texture data
  1045. * @param texture defines the BabylonJS internal texture
  1046. * @param callback defines the method to call once ready to upload
  1047. */
  1048. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1049. }
  1050. }
  1051. declare module BABYLON {
  1052. /**
  1053. * Class used to store and describe the pipeline context associated with an effect
  1054. */
  1055. export interface IPipelineContext {
  1056. /**
  1057. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1058. */
  1059. isAsync: boolean;
  1060. /**
  1061. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1062. */
  1063. isReady: boolean;
  1064. /** @hidden */ private _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1065. }
  1066. }
  1067. declare module BABYLON {
  1068. /**
  1069. * Class used to store gfx data (like WebGLBuffer)
  1070. */
  1071. export class DataBuffer {
  1072. /**
  1073. * Gets or sets the number of objects referencing this buffer
  1074. */
  1075. references: number;
  1076. /** Gets or sets the size of the underlying buffer */
  1077. capacity: number;
  1078. /**
  1079. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1080. */
  1081. is32Bits: boolean;
  1082. /**
  1083. * Gets the underlying buffer
  1084. */
  1085. readonly underlyingResource: any;
  1086. }
  1087. }
  1088. declare module BABYLON {
  1089. /** @hidden */
  1090. export interface IShaderProcessor {
  1091. attributeProcessor?: (attribute: string) => string;
  1092. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1093. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1094. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1095. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1096. lineProcessor?: (line: string, isFragment: boolean) => string;
  1097. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1098. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1099. }
  1100. }
  1101. declare module BABYLON {
  1102. /** @hidden */
  1103. export interface ProcessingOptions {
  1104. defines: string[];
  1105. indexParameters: any;
  1106. isFragment: boolean;
  1107. shouldUseHighPrecisionShader: boolean;
  1108. supportsUniformBuffers: boolean;
  1109. shadersRepository: string;
  1110. includesShadersStore: {
  1111. [key: string]: string;
  1112. };
  1113. processor?: IShaderProcessor;
  1114. version: string;
  1115. platformName: string;
  1116. lookForClosingBracketForUniformBuffer?: boolean;
  1117. }
  1118. }
  1119. declare module BABYLON {
  1120. /**
  1121. * Helper to manipulate strings
  1122. */
  1123. export class StringTools {
  1124. /**
  1125. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  1126. * @param str Source string
  1127. * @param suffix Suffix to search for in the source string
  1128. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  1129. */
  1130. static EndsWith(str: string, suffix: string): boolean;
  1131. /**
  1132. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  1133. * @param str Source string
  1134. * @param suffix Suffix to search for in the source string
  1135. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  1136. */
  1137. static StartsWith(str: string, suffix: string): boolean;
  1138. /**
  1139. * Decodes a buffer into a string
  1140. * @param buffer The buffer to decode
  1141. * @returns The decoded string
  1142. */
  1143. static Decode(buffer: Uint8Array | Uint16Array): string;
  1144. }
  1145. }
  1146. declare module BABYLON {
  1147. /** @hidden */
  1148. export class ShaderCodeNode {
  1149. line: string;
  1150. children: ShaderCodeNode[];
  1151. additionalDefineKey?: string;
  1152. additionalDefineValue?: string;
  1153. isValid(preprocessors: {
  1154. [key: string]: string;
  1155. }): boolean;
  1156. process(preprocessors: {
  1157. [key: string]: string;
  1158. }, options: ProcessingOptions): string;
  1159. }
  1160. }
  1161. declare module BABYLON {
  1162. /** @hidden */
  1163. export class ShaderCodeCursor {
  1164. private _lines;
  1165. lineIndex: number;
  1166. readonly currentLine: string;
  1167. readonly canRead: boolean;
  1168. lines: string[];
  1169. }
  1170. }
  1171. declare module BABYLON {
  1172. /** @hidden */
  1173. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1174. process(preprocessors: {
  1175. [key: string]: string;
  1176. }, options: ProcessingOptions): string;
  1177. }
  1178. }
  1179. declare module BABYLON {
  1180. /** @hidden */
  1181. export class ShaderDefineExpression {
  1182. isTrue(preprocessors: {
  1183. [key: string]: string;
  1184. }): boolean;
  1185. }
  1186. }
  1187. declare module BABYLON {
  1188. /** @hidden */
  1189. export class ShaderCodeTestNode extends ShaderCodeNode {
  1190. testExpression: ShaderDefineExpression;
  1191. isValid(preprocessors: {
  1192. [key: string]: string;
  1193. }): boolean;
  1194. }
  1195. }
  1196. declare module BABYLON {
  1197. /** @hidden */
  1198. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1199. define: string;
  1200. not: boolean;
  1201. constructor(define: string, not?: boolean);
  1202. isTrue(preprocessors: {
  1203. [key: string]: string;
  1204. }): boolean;
  1205. }
  1206. }
  1207. declare module BABYLON {
  1208. /** @hidden */
  1209. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1210. leftOperand: ShaderDefineExpression;
  1211. rightOperand: ShaderDefineExpression;
  1212. isTrue(preprocessors: {
  1213. [key: string]: string;
  1214. }): boolean;
  1215. }
  1216. }
  1217. declare module BABYLON {
  1218. /** @hidden */
  1219. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1220. leftOperand: ShaderDefineExpression;
  1221. rightOperand: ShaderDefineExpression;
  1222. isTrue(preprocessors: {
  1223. [key: string]: string;
  1224. }): boolean;
  1225. }
  1226. }
  1227. declare module BABYLON {
  1228. /** @hidden */
  1229. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1230. define: string;
  1231. operand: string;
  1232. testValue: string;
  1233. constructor(define: string, operand: string, testValue: string);
  1234. isTrue(preprocessors: {
  1235. [key: string]: string;
  1236. }): boolean;
  1237. }
  1238. }
  1239. declare module BABYLON {
  1240. /**
  1241. * Class used to enable access to offline support
  1242. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1243. */
  1244. export interface IOfflineProvider {
  1245. /**
  1246. * Gets a boolean indicating if scene must be saved in the database
  1247. */
  1248. enableSceneOffline: boolean;
  1249. /**
  1250. * Gets a boolean indicating if textures must be saved in the database
  1251. */
  1252. enableTexturesOffline: boolean;
  1253. /**
  1254. * Open the offline support and make it available
  1255. * @param successCallback defines the callback to call on success
  1256. * @param errorCallback defines the callback to call on error
  1257. */
  1258. open(successCallback: () => void, errorCallback: () => void): void;
  1259. /**
  1260. * Loads an image from the offline support
  1261. * @param url defines the url to load from
  1262. * @param image defines the target DOM image
  1263. */
  1264. loadImage(url: string, image: HTMLImageElement): void;
  1265. /**
  1266. * Loads a file from offline support
  1267. * @param url defines the URL to load from
  1268. * @param sceneLoaded defines a callback to call on success
  1269. * @param progressCallBack defines a callback to call when progress changed
  1270. * @param errorCallback defines a callback to call on error
  1271. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1272. */
  1273. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1274. }
  1275. }
  1276. declare module BABYLON {
  1277. /**
  1278. * Class used to help managing file picking and drag'n'drop
  1279. * File Storage
  1280. */
  1281. export class FilesInputStore {
  1282. /**
  1283. * List of files ready to be loaded
  1284. */
  1285. static FilesToLoad: {
  1286. [key: string]: File;
  1287. };
  1288. }
  1289. }
  1290. declare module BABYLON {
  1291. /**
  1292. * Class used to define a retry strategy when error happens while loading assets
  1293. */
  1294. export class RetryStrategy {
  1295. /**
  1296. * Function used to defines an exponential back off strategy
  1297. * @param maxRetries defines the maximum number of retries (3 by default)
  1298. * @param baseInterval defines the interval between retries
  1299. * @returns the strategy function to use
  1300. */
  1301. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1302. }
  1303. }
  1304. declare module BABYLON {
  1305. /**
  1306. * @ignore
  1307. * Application error to support additional information when loading a file
  1308. */
  1309. export abstract class BaseError extends Error {
  1310. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1311. }
  1312. }
  1313. declare module BABYLON {
  1314. /** @ignore */
  1315. export class LoadFileError extends BaseError {
  1316. request?: WebRequest;
  1317. file?: File;
  1318. /**
  1319. * Creates a new LoadFileError
  1320. * @param message defines the message of the error
  1321. * @param request defines the optional web request
  1322. * @param file defines the optional file
  1323. */
  1324. constructor(message: string, object?: WebRequest | File);
  1325. }
  1326. /** @ignore */
  1327. export class RequestFileError extends BaseError {
  1328. request: WebRequest;
  1329. /**
  1330. * Creates a new LoadFileError
  1331. * @param message defines the message of the error
  1332. * @param request defines the optional web request
  1333. */
  1334. constructor(message: string, request: WebRequest);
  1335. }
  1336. /** @ignore */
  1337. export class ReadFileError extends BaseError {
  1338. file: File;
  1339. /**
  1340. * Creates a new ReadFileError
  1341. * @param message defines the message of the error
  1342. * @param file defines the optional file
  1343. */
  1344. constructor(message: string, file: File);
  1345. }
  1346. /**
  1347. * @hidden
  1348. */
  1349. export class FileTools {
  1350. /**
  1351. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1352. */
  1353. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1354. /**
  1355. * Gets or sets the base URL to use to load assets
  1356. */
  1357. static BaseUrl: string;
  1358. /**
  1359. * Default behaviour for cors in the application.
  1360. * It can be a string if the expected behavior is identical in the entire app.
  1361. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1362. */
  1363. static CorsBehavior: string | ((url: string | string[]) => string);
  1364. /**
  1365. * Gets or sets a function used to pre-process url before using them to load assets
  1366. */
  1367. static PreprocessUrl: (url: string) => string;
  1368. /**
  1369. * Removes unwanted characters from an url
  1370. * @param url defines the url to clean
  1371. * @returns the cleaned url
  1372. */
  1373. private static _CleanUrl;
  1374. /**
  1375. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1376. * @param url define the url we are trying
  1377. * @param element define the dom element where to configure the cors policy
  1378. */
  1379. static SetCorsBehavior(url: string | string[], element: {
  1380. crossOrigin: string | null;
  1381. }): void;
  1382. /**
  1383. * Encode an array buffer into a base64 string
  1384. * @param buffer defines the buffer to encode
  1385. * @returns a string containing the base64 version of the buffer
  1386. */
  1387. static ArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  1388. /**
  1389. * Loads an image as an HTMLImageElement.
  1390. * @param input url string, ArrayBuffer, or Blob to load
  1391. * @param onLoad callback called when the image successfully loads
  1392. * @param onError callback called when the image fails to load
  1393. * @param offlineProvider offline provider for caching
  1394. * @param mimeType optional mime type
  1395. * @returns the HTMLImageElement of the loaded image
  1396. */
  1397. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1398. /**
  1399. * Reads a file from a File object
  1400. * @param file defines the file to load
  1401. * @param onSuccess defines the callback to call when data is loaded
  1402. * @param onProgress defines the callback to call during loading process
  1403. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1404. * @param onError defines the callback to call when an error occurs
  1405. * @returns a file request object
  1406. */
  1407. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1408. /**
  1409. * Loads a file from a url
  1410. * @param url url to load
  1411. * @param onSuccess callback called when the file successfully loads
  1412. * @param onProgress callback called while file is loading (if the server supports this mode)
  1413. * @param offlineProvider defines the offline provider for caching
  1414. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1415. * @param onError callback called when the file fails to load
  1416. * @returns a file request object
  1417. */
  1418. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1419. /**
  1420. * Loads a file
  1421. * @param url url to load
  1422. * @param onSuccess callback called when the file successfully loads
  1423. * @param onProgress callback called while file is loading (if the server supports this mode)
  1424. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1425. * @param onError callback called when the file fails to load
  1426. * @param onOpened callback called when the web request is opened
  1427. * @returns a file request object
  1428. */
  1429. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1430. /**
  1431. * Checks if the loaded document was accessed via `file:`-Protocol.
  1432. * @returns boolean
  1433. */
  1434. static IsFileURL(): boolean;
  1435. }
  1436. }
  1437. declare module BABYLON {
  1438. /** @hidden */
  1439. export class ShaderProcessor {
  1440. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1441. private static _ProcessPrecision;
  1442. private static _ExtractOperation;
  1443. private static _BuildSubExpression;
  1444. private static _BuildExpression;
  1445. private static _MoveCursorWithinIf;
  1446. private static _MoveCursor;
  1447. private static _EvaluatePreProcessors;
  1448. private static _PreparePreProcessors;
  1449. private static _ProcessShaderConversion;
  1450. private static _ProcessIncludes;
  1451. }
  1452. }
  1453. declare module BABYLON {
  1454. /**
  1455. * @hidden
  1456. */
  1457. export interface IColor4Like {
  1458. r: float;
  1459. g: float;
  1460. b: float;
  1461. a: float;
  1462. }
  1463. /**
  1464. * @hidden
  1465. */
  1466. export interface IColor3Like {
  1467. r: float;
  1468. g: float;
  1469. b: float;
  1470. }
  1471. /**
  1472. * @hidden
  1473. */
  1474. export interface IVector4Like {
  1475. x: float;
  1476. y: float;
  1477. z: float;
  1478. w: float;
  1479. }
  1480. /**
  1481. * @hidden
  1482. */
  1483. export interface IVector3Like {
  1484. x: float;
  1485. y: float;
  1486. z: float;
  1487. }
  1488. /**
  1489. * @hidden
  1490. */
  1491. export interface IVector2Like {
  1492. x: float;
  1493. y: float;
  1494. }
  1495. /**
  1496. * @hidden
  1497. */
  1498. export interface IMatrixLike {
  1499. toArray(): DeepImmutable<Float32Array>;
  1500. updateFlag: int;
  1501. }
  1502. /**
  1503. * @hidden
  1504. */
  1505. export interface IViewportLike {
  1506. x: float;
  1507. y: float;
  1508. width: float;
  1509. height: float;
  1510. }
  1511. /**
  1512. * @hidden
  1513. */
  1514. export interface IPlaneLike {
  1515. normal: IVector3Like;
  1516. d: float;
  1517. normalize(): void;
  1518. }
  1519. }
  1520. declare module BABYLON {
  1521. /**
  1522. * Interface used to define common properties for effect fallbacks
  1523. */
  1524. export interface IEffectFallbacks {
  1525. /**
  1526. * Removes the defines that should be removed when falling back.
  1527. * @param currentDefines defines the current define statements for the shader.
  1528. * @param effect defines the current effect we try to compile
  1529. * @returns The resulting defines with defines of the current rank removed.
  1530. */
  1531. reduce(currentDefines: string, effect: Effect): string;
  1532. /**
  1533. * Removes the fallback from the bound mesh.
  1534. */
  1535. unBindMesh(): void;
  1536. /**
  1537. * Checks to see if more fallbacks are still availible.
  1538. */
  1539. hasMoreFallbacks: boolean;
  1540. }
  1541. }
  1542. declare module BABYLON {
  1543. /**
  1544. * Class used to evalaute queries containing `and` and `or` operators
  1545. */
  1546. export class AndOrNotEvaluator {
  1547. /**
  1548. * Evaluate a query
  1549. * @param query defines the query to evaluate
  1550. * @param evaluateCallback defines the callback used to filter result
  1551. * @returns true if the query matches
  1552. */
  1553. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1554. private static _HandleParenthesisContent;
  1555. private static _SimplifyNegation;
  1556. }
  1557. }
  1558. declare module BABYLON {
  1559. /**
  1560. * Class used to store custom tags
  1561. */
  1562. export class Tags {
  1563. /**
  1564. * Adds support for tags on the given object
  1565. * @param obj defines the object to use
  1566. */
  1567. static EnableFor(obj: any): void;
  1568. /**
  1569. * Removes tags support
  1570. * @param obj defines the object to use
  1571. */
  1572. static DisableFor(obj: any): void;
  1573. /**
  1574. * Gets a boolean indicating if the given object has tags
  1575. * @param obj defines the object to use
  1576. * @returns a boolean
  1577. */
  1578. static HasTags(obj: any): boolean;
  1579. /**
  1580. * Gets the tags available on a given object
  1581. * @param obj defines the object to use
  1582. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1583. * @returns the tags
  1584. */
  1585. static GetTags(obj: any, asString?: boolean): any;
  1586. /**
  1587. * Adds tags to an object
  1588. * @param obj defines the object to use
  1589. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1590. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1591. */
  1592. static AddTagsTo(obj: any, tagsString: string): void;
  1593. /**
  1594. * @hidden
  1595. */ private static _AddTagTo(obj: any, tag: string): void;
  1596. /**
  1597. * Removes specific tags from a specific object
  1598. * @param obj defines the object to use
  1599. * @param tagsString defines the tags to remove
  1600. */
  1601. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1602. /**
  1603. * @hidden
  1604. */ private static _RemoveTagFrom(obj: any, tag: string): void;
  1605. /**
  1606. * Defines if tags hosted on an object match a given query
  1607. * @param obj defines the object to use
  1608. * @param tagsQuery defines the tag query
  1609. * @returns a boolean
  1610. */
  1611. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1612. }
  1613. }
  1614. declare module BABYLON {
  1615. /**
  1616. * Scalar computation library
  1617. */
  1618. export class Scalar {
  1619. /**
  1620. * Two pi constants convenient for computation.
  1621. */
  1622. static TwoPi: number;
  1623. /**
  1624. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1625. * @param a number
  1626. * @param b number
  1627. * @param epsilon (default = 1.401298E-45)
  1628. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1629. */
  1630. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1631. /**
  1632. * Returns a string : the upper case translation of the number i to hexadecimal.
  1633. * @param i number
  1634. * @returns the upper case translation of the number i to hexadecimal.
  1635. */
  1636. static ToHex(i: number): string;
  1637. /**
  1638. * Returns -1 if value is negative and +1 is value is positive.
  1639. * @param value the value
  1640. * @returns the value itself if it's equal to zero.
  1641. */
  1642. static Sign(value: number): number;
  1643. /**
  1644. * Returns the value itself if it's between min and max.
  1645. * Returns min if the value is lower than min.
  1646. * Returns max if the value is greater than max.
  1647. * @param value the value to clmap
  1648. * @param min the min value to clamp to (default: 0)
  1649. * @param max the max value to clamp to (default: 1)
  1650. * @returns the clamped value
  1651. */
  1652. static Clamp(value: number, min?: number, max?: number): number;
  1653. /**
  1654. * the log2 of value.
  1655. * @param value the value to compute log2 of
  1656. * @returns the log2 of value.
  1657. */
  1658. static Log2(value: number): number;
  1659. /**
  1660. * Loops the value, so that it is never larger than length and never smaller than 0.
  1661. *
  1662. * This is similar to the modulo operator but it works with floating point numbers.
  1663. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1664. * With t = 5 and length = 2.5, the result would be 0.0.
  1665. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1666. * @param value the value
  1667. * @param length the length
  1668. * @returns the looped value
  1669. */
  1670. static Repeat(value: number, length: number): number;
  1671. /**
  1672. * Normalize the value between 0.0 and 1.0 using min and max values
  1673. * @param value value to normalize
  1674. * @param min max to normalize between
  1675. * @param max min to normalize between
  1676. * @returns the normalized value
  1677. */
  1678. static Normalize(value: number, min: number, max: number): number;
  1679. /**
  1680. * Denormalize the value from 0.0 and 1.0 using min and max values
  1681. * @param normalized value to denormalize
  1682. * @param min max to denormalize between
  1683. * @param max min to denormalize between
  1684. * @returns the denormalized value
  1685. */
  1686. static Denormalize(normalized: number, min: number, max: number): number;
  1687. /**
  1688. * Calculates the shortest difference between two given angles given in degrees.
  1689. * @param current current angle in degrees
  1690. * @param target target angle in degrees
  1691. * @returns the delta
  1692. */
  1693. static DeltaAngle(current: number, target: number): number;
  1694. /**
  1695. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1696. * @param tx value
  1697. * @param length length
  1698. * @returns The returned value will move back and forth between 0 and length
  1699. */
  1700. static PingPong(tx: number, length: number): number;
  1701. /**
  1702. * Interpolates between min and max with smoothing at the limits.
  1703. *
  1704. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1705. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1706. * @param from from
  1707. * @param to to
  1708. * @param tx value
  1709. * @returns the smooth stepped value
  1710. */
  1711. static SmoothStep(from: number, to: number, tx: number): number;
  1712. /**
  1713. * Moves a value current towards target.
  1714. *
  1715. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1716. * Negative values of maxDelta pushes the value away from target.
  1717. * @param current current value
  1718. * @param target target value
  1719. * @param maxDelta max distance to move
  1720. * @returns resulting value
  1721. */
  1722. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1723. /**
  1724. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1725. *
  1726. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1727. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1728. * @param current current value
  1729. * @param target target value
  1730. * @param maxDelta max distance to move
  1731. * @returns resulting angle
  1732. */
  1733. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1734. /**
  1735. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1736. * @param start start value
  1737. * @param end target value
  1738. * @param amount amount to lerp between
  1739. * @returns the lerped value
  1740. */
  1741. static Lerp(start: number, end: number, amount: number): number;
  1742. /**
  1743. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1744. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1745. * @param start start value
  1746. * @param end target value
  1747. * @param amount amount to lerp between
  1748. * @returns the lerped value
  1749. */
  1750. static LerpAngle(start: number, end: number, amount: number): number;
  1751. /**
  1752. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1753. * @param a start value
  1754. * @param b target value
  1755. * @param value value between a and b
  1756. * @returns the inverseLerp value
  1757. */
  1758. static InverseLerp(a: number, b: number, value: number): number;
  1759. /**
  1760. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1761. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1762. * @param value1 spline value
  1763. * @param tangent1 spline value
  1764. * @param value2 spline value
  1765. * @param tangent2 spline value
  1766. * @param amount input value
  1767. * @returns hermite result
  1768. */
  1769. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1770. /**
  1771. * Returns a random float number between and min and max values
  1772. * @param min min value of random
  1773. * @param max max value of random
  1774. * @returns random value
  1775. */
  1776. static RandomRange(min: number, max: number): number;
  1777. /**
  1778. * This function returns percentage of a number in a given range.
  1779. *
  1780. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1781. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1782. * @param number to convert to percentage
  1783. * @param min min range
  1784. * @param max max range
  1785. * @returns the percentage
  1786. */
  1787. static RangeToPercent(number: number, min: number, max: number): number;
  1788. /**
  1789. * This function returns number that corresponds to the percentage in a given range.
  1790. *
  1791. * PercentToRange(0.34,0,100) will return 34.
  1792. * @param percent to convert to number
  1793. * @param min min range
  1794. * @param max max range
  1795. * @returns the number
  1796. */
  1797. static PercentToRange(percent: number, min: number, max: number): number;
  1798. /**
  1799. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1800. * @param angle The angle to normalize in radian.
  1801. * @return The converted angle.
  1802. */
  1803. static NormalizeRadians(angle: number): number;
  1804. }
  1805. }
  1806. declare module BABYLON {
  1807. /**
  1808. * Constant used to convert a value to gamma space
  1809. * @ignorenaming
  1810. */
  1811. export const ToGammaSpace: number;
  1812. /**
  1813. * Constant used to convert a value to linear space
  1814. * @ignorenaming
  1815. */
  1816. export const ToLinearSpace = 2.2;
  1817. /**
  1818. * Constant used to define the minimal number value in Babylon.js
  1819. * @ignorenaming
  1820. */
  1821. let Epsilon: number;
  1822. }
  1823. declare module BABYLON {
  1824. /**
  1825. * Class used to represent a viewport on screen
  1826. */
  1827. export class Viewport {
  1828. /** viewport left coordinate */
  1829. x: number;
  1830. /** viewport top coordinate */
  1831. y: number;
  1832. /**viewport width */
  1833. width: number;
  1834. /** viewport height */
  1835. height: number;
  1836. /**
  1837. * Creates a Viewport object located at (x, y) and sized (width, height)
  1838. * @param x defines viewport left coordinate
  1839. * @param y defines viewport top coordinate
  1840. * @param width defines the viewport width
  1841. * @param height defines the viewport height
  1842. */
  1843. constructor(
  1844. /** viewport left coordinate */
  1845. x: number,
  1846. /** viewport top coordinate */
  1847. y: number,
  1848. /**viewport width */
  1849. width: number,
  1850. /** viewport height */
  1851. height: number);
  1852. /**
  1853. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1854. * @param renderWidth defines the rendering width
  1855. * @param renderHeight defines the rendering height
  1856. * @returns a new Viewport
  1857. */
  1858. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1859. /**
  1860. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1861. * @param renderWidth defines the rendering width
  1862. * @param renderHeight defines the rendering height
  1863. * @param ref defines the target viewport
  1864. * @returns the current viewport
  1865. */
  1866. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1867. /**
  1868. * Returns a new Viewport copied from the current one
  1869. * @returns a new Viewport
  1870. */
  1871. clone(): Viewport;
  1872. }
  1873. }
  1874. declare module BABYLON {
  1875. /**
  1876. * Class containing a set of static utilities functions for arrays.
  1877. */
  1878. export class ArrayTools {
  1879. /**
  1880. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1881. * @param size the number of element to construct and put in the array
  1882. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1883. * @returns a new array filled with new objects
  1884. */
  1885. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1886. }
  1887. }
  1888. declare module BABYLON {
  1889. /**
  1890. * Class representing a vector containing 2 coordinates
  1891. */
  1892. export class Vector2 {
  1893. /** defines the first coordinate */
  1894. x: number;
  1895. /** defines the second coordinate */
  1896. y: number;
  1897. /**
  1898. * Creates a new Vector2 from the given x and y coordinates
  1899. * @param x defines the first coordinate
  1900. * @param y defines the second coordinate
  1901. */
  1902. constructor(
  1903. /** defines the first coordinate */
  1904. x?: number,
  1905. /** defines the second coordinate */
  1906. y?: number);
  1907. /**
  1908. * Gets a string with the Vector2 coordinates
  1909. * @returns a string with the Vector2 coordinates
  1910. */
  1911. toString(): string;
  1912. /**
  1913. * Gets class name
  1914. * @returns the string "Vector2"
  1915. */
  1916. getClassName(): string;
  1917. /**
  1918. * Gets current vector hash code
  1919. * @returns the Vector2 hash code as a number
  1920. */
  1921. getHashCode(): number;
  1922. /**
  1923. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1924. * @param array defines the source array
  1925. * @param index defines the offset in source array
  1926. * @returns the current Vector2
  1927. */
  1928. toArray(array: FloatArray, index?: number): Vector2;
  1929. /**
  1930. * Copy the current vector to an array
  1931. * @returns a new array with 2 elements: the Vector2 coordinates.
  1932. */
  1933. asArray(): number[];
  1934. /**
  1935. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1936. * @param source defines the source Vector2
  1937. * @returns the current updated Vector2
  1938. */
  1939. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1940. /**
  1941. * Sets the Vector2 coordinates with the given floats
  1942. * @param x defines the first coordinate
  1943. * @param y defines the second coordinate
  1944. * @returns the current updated Vector2
  1945. */
  1946. copyFromFloats(x: number, y: number): Vector2;
  1947. /**
  1948. * Sets the Vector2 coordinates with the given floats
  1949. * @param x defines the first coordinate
  1950. * @param y defines the second coordinate
  1951. * @returns the current updated Vector2
  1952. */
  1953. set(x: number, y: number): Vector2;
  1954. /**
  1955. * Add another vector with the current one
  1956. * @param otherVector defines the other vector
  1957. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1958. */
  1959. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1960. /**
  1961. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1962. * @param otherVector defines the other vector
  1963. * @param result defines the target vector
  1964. * @returns the unmodified current Vector2
  1965. */
  1966. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1967. /**
  1968. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1969. * @param otherVector defines the other vector
  1970. * @returns the current updated Vector2
  1971. */
  1972. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1973. /**
  1974. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1975. * @param otherVector defines the other vector
  1976. * @returns a new Vector2
  1977. */
  1978. addVector3(otherVector: Vector3): Vector2;
  1979. /**
  1980. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1981. * @param otherVector defines the other vector
  1982. * @returns a new Vector2
  1983. */
  1984. subtract(otherVector: Vector2): Vector2;
  1985. /**
  1986. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1987. * @param otherVector defines the other vector
  1988. * @param result defines the target vector
  1989. * @returns the unmodified current Vector2
  1990. */
  1991. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1992. /**
  1993. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1994. * @param otherVector defines the other vector
  1995. * @returns the current updated Vector2
  1996. */
  1997. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1998. /**
  1999. * Multiplies in place the current Vector2 coordinates by the given ones
  2000. * @param otherVector defines the other vector
  2001. * @returns the current updated Vector2
  2002. */
  2003. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2004. /**
  2005. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2006. * @param otherVector defines the other vector
  2007. * @returns a new Vector2
  2008. */
  2009. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2010. /**
  2011. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2012. * @param otherVector defines the other vector
  2013. * @param result defines the target vector
  2014. * @returns the unmodified current Vector2
  2015. */
  2016. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2017. /**
  2018. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2019. * @param x defines the first coordinate
  2020. * @param y defines the second coordinate
  2021. * @returns a new Vector2
  2022. */
  2023. multiplyByFloats(x: number, y: number): Vector2;
  2024. /**
  2025. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2026. * @param otherVector defines the other vector
  2027. * @returns a new Vector2
  2028. */
  2029. divide(otherVector: Vector2): Vector2;
  2030. /**
  2031. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2032. * @param otherVector defines the other vector
  2033. * @param result defines the target vector
  2034. * @returns the unmodified current Vector2
  2035. */
  2036. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2037. /**
  2038. * Divides the current Vector2 coordinates by the given ones
  2039. * @param otherVector defines the other vector
  2040. * @returns the current updated Vector2
  2041. */
  2042. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2043. /**
  2044. * Gets a new Vector2 with current Vector2 negated coordinates
  2045. * @returns a new Vector2
  2046. */
  2047. negate(): Vector2;
  2048. /**
  2049. * Multiply the Vector2 coordinates by scale
  2050. * @param scale defines the scaling factor
  2051. * @returns the current updated Vector2
  2052. */
  2053. scaleInPlace(scale: number): Vector2;
  2054. /**
  2055. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2056. * @param scale defines the scaling factor
  2057. * @returns a new Vector2
  2058. */
  2059. scale(scale: number): Vector2;
  2060. /**
  2061. * Scale the current Vector2 values by a factor to a given Vector2
  2062. * @param scale defines the scale factor
  2063. * @param result defines the Vector2 object where to store the result
  2064. * @returns the unmodified current Vector2
  2065. */
  2066. scaleToRef(scale: number, result: Vector2): Vector2;
  2067. /**
  2068. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2069. * @param scale defines the scale factor
  2070. * @param result defines the Vector2 object where to store the result
  2071. * @returns the unmodified current Vector2
  2072. */
  2073. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2074. /**
  2075. * Gets a boolean if two vectors are equals
  2076. * @param otherVector defines the other vector
  2077. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2078. */
  2079. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2080. /**
  2081. * Gets a boolean if two vectors are equals (using an epsilon value)
  2082. * @param otherVector defines the other vector
  2083. * @param epsilon defines the minimal distance to consider equality
  2084. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2085. */
  2086. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2087. /**
  2088. * Gets a new Vector2 from current Vector2 floored values
  2089. * @returns a new Vector2
  2090. */
  2091. floor(): Vector2;
  2092. /**
  2093. * Gets a new Vector2 from current Vector2 floored values
  2094. * @returns a new Vector2
  2095. */
  2096. fract(): Vector2;
  2097. /**
  2098. * Gets the length of the vector
  2099. * @returns the vector length (float)
  2100. */
  2101. length(): number;
  2102. /**
  2103. * Gets the vector squared length
  2104. * @returns the vector squared length (float)
  2105. */
  2106. lengthSquared(): number;
  2107. /**
  2108. * Normalize the vector
  2109. * @returns the current updated Vector2
  2110. */
  2111. normalize(): Vector2;
  2112. /**
  2113. * Gets a new Vector2 copied from the Vector2
  2114. * @returns a new Vector2
  2115. */
  2116. clone(): Vector2;
  2117. /**
  2118. * Gets a new Vector2(0, 0)
  2119. * @returns a new Vector2
  2120. */
  2121. static Zero(): Vector2;
  2122. /**
  2123. * Gets a new Vector2(1, 1)
  2124. * @returns a new Vector2
  2125. */
  2126. static One(): Vector2;
  2127. /**
  2128. * Gets a new Vector2 set from the given index element of the given array
  2129. * @param array defines the data source
  2130. * @param offset defines the offset in the data source
  2131. * @returns a new Vector2
  2132. */
  2133. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2134. /**
  2135. * Sets "result" from the given index element of the given array
  2136. * @param array defines the data source
  2137. * @param offset defines the offset in the data source
  2138. * @param result defines the target vector
  2139. */
  2140. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2141. /**
  2142. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2143. * @param value1 defines 1st point of control
  2144. * @param value2 defines 2nd point of control
  2145. * @param value3 defines 3rd point of control
  2146. * @param value4 defines 4th point of control
  2147. * @param amount defines the interpolation factor
  2148. * @returns a new Vector2
  2149. */
  2150. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2151. /**
  2152. * 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".
  2153. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2154. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2155. * @param value defines the value to clamp
  2156. * @param min defines the lower limit
  2157. * @param max defines the upper limit
  2158. * @returns a new Vector2
  2159. */
  2160. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2161. /**
  2162. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2163. * @param value1 defines the 1st control point
  2164. * @param tangent1 defines the outgoing tangent
  2165. * @param value2 defines the 2nd control point
  2166. * @param tangent2 defines the incoming tangent
  2167. * @param amount defines the interpolation factor
  2168. * @returns a new Vector2
  2169. */
  2170. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2171. /**
  2172. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2173. * @param start defines the start vector
  2174. * @param end defines the end vector
  2175. * @param amount defines the interpolation factor
  2176. * @returns a new Vector2
  2177. */
  2178. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2179. /**
  2180. * Gets the dot product of the vector "left" and the vector "right"
  2181. * @param left defines first vector
  2182. * @param right defines second vector
  2183. * @returns the dot product (float)
  2184. */
  2185. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2186. /**
  2187. * Returns a new Vector2 equal to the normalized given vector
  2188. * @param vector defines the vector to normalize
  2189. * @returns a new Vector2
  2190. */
  2191. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2192. /**
  2193. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2194. * @param left defines 1st vector
  2195. * @param right defines 2nd vector
  2196. * @returns a new Vector2
  2197. */
  2198. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2199. /**
  2200. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2201. * @param left defines 1st vector
  2202. * @param right defines 2nd vector
  2203. * @returns a new Vector2
  2204. */
  2205. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2206. /**
  2207. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2208. * @param vector defines the vector to transform
  2209. * @param transformation defines the matrix to apply
  2210. * @returns a new Vector2
  2211. */
  2212. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2213. /**
  2214. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2215. * @param vector defines the vector to transform
  2216. * @param transformation defines the matrix to apply
  2217. * @param result defines the target vector
  2218. */
  2219. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2220. /**
  2221. * Determines if a given vector is included in a triangle
  2222. * @param p defines the vector to test
  2223. * @param p0 defines 1st triangle point
  2224. * @param p1 defines 2nd triangle point
  2225. * @param p2 defines 3rd triangle point
  2226. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2227. */
  2228. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2229. /**
  2230. * Gets the distance between the vectors "value1" and "value2"
  2231. * @param value1 defines first vector
  2232. * @param value2 defines second vector
  2233. * @returns the distance between vectors
  2234. */
  2235. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2236. /**
  2237. * Returns the squared distance between the vectors "value1" and "value2"
  2238. * @param value1 defines first vector
  2239. * @param value2 defines second vector
  2240. * @returns the squared distance between vectors
  2241. */
  2242. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2243. /**
  2244. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2245. * @param value1 defines first vector
  2246. * @param value2 defines second vector
  2247. * @returns a new Vector2
  2248. */
  2249. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2250. /**
  2251. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2252. * @param p defines the middle point
  2253. * @param segA defines one point of the segment
  2254. * @param segB defines the other point of the segment
  2255. * @returns the shortest distance
  2256. */
  2257. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2258. }
  2259. /**
  2260. * Classed used to store (x,y,z) vector representation
  2261. * A Vector3 is the main object used in 3D geometry
  2262. * It can represent etiher the coordinates of a point the space, either a direction
  2263. * Reminder: js uses a left handed forward facing system
  2264. */
  2265. export class Vector3 {
  2266. /**
  2267. * Defines the first coordinates (on X axis)
  2268. */
  2269. x: number;
  2270. /**
  2271. * Defines the second coordinates (on Y axis)
  2272. */
  2273. y: number;
  2274. /**
  2275. * Defines the third coordinates (on Z axis)
  2276. */
  2277. z: number;
  2278. private static _UpReadOnly;
  2279. private static _ZeroReadOnly;
  2280. /**
  2281. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2282. * @param x defines the first coordinates (on X axis)
  2283. * @param y defines the second coordinates (on Y axis)
  2284. * @param z defines the third coordinates (on Z axis)
  2285. */
  2286. constructor(
  2287. /**
  2288. * Defines the first coordinates (on X axis)
  2289. */
  2290. x?: number,
  2291. /**
  2292. * Defines the second coordinates (on Y axis)
  2293. */
  2294. y?: number,
  2295. /**
  2296. * Defines the third coordinates (on Z axis)
  2297. */
  2298. z?: number);
  2299. /**
  2300. * Creates a string representation of the Vector3
  2301. * @returns a string with the Vector3 coordinates.
  2302. */
  2303. toString(): string;
  2304. /**
  2305. * Gets the class name
  2306. * @returns the string "Vector3"
  2307. */
  2308. getClassName(): string;
  2309. /**
  2310. * Creates the Vector3 hash code
  2311. * @returns a number which tends to be unique between Vector3 instances
  2312. */
  2313. getHashCode(): number;
  2314. /**
  2315. * Creates an array containing three elements : the coordinates of the Vector3
  2316. * @returns a new array of numbers
  2317. */
  2318. asArray(): number[];
  2319. /**
  2320. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2321. * @param array defines the destination array
  2322. * @param index defines the offset in the destination array
  2323. * @returns the current Vector3
  2324. */
  2325. toArray(array: FloatArray, index?: number): Vector3;
  2326. /**
  2327. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2328. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2329. */
  2330. toQuaternion(): Quaternion;
  2331. /**
  2332. * Adds the given vector to the current Vector3
  2333. * @param otherVector defines the second operand
  2334. * @returns the current updated Vector3
  2335. */
  2336. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2337. /**
  2338. * Adds the given coordinates to the current Vector3
  2339. * @param x defines the x coordinate of the operand
  2340. * @param y defines the y coordinate of the operand
  2341. * @param z defines the z coordinate of the operand
  2342. * @returns the current updated Vector3
  2343. */
  2344. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2345. /**
  2346. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2347. * @param otherVector defines the second operand
  2348. * @returns the resulting Vector3
  2349. */
  2350. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2351. /**
  2352. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2353. * @param otherVector defines the second operand
  2354. * @param result defines the Vector3 object where to store the result
  2355. * @returns the current Vector3
  2356. */
  2357. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2358. /**
  2359. * Subtract the given vector from the current Vector3
  2360. * @param otherVector defines the second operand
  2361. * @returns the current updated Vector3
  2362. */
  2363. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2364. /**
  2365. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2366. * @param otherVector defines the second operand
  2367. * @returns the resulting Vector3
  2368. */
  2369. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2370. /**
  2371. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2372. * @param otherVector defines the second operand
  2373. * @param result defines the Vector3 object where to store the result
  2374. * @returns the current Vector3
  2375. */
  2376. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2377. /**
  2378. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2379. * @param x defines the x coordinate of the operand
  2380. * @param y defines the y coordinate of the operand
  2381. * @param z defines the z coordinate of the operand
  2382. * @returns the resulting Vector3
  2383. */
  2384. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2385. /**
  2386. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2387. * @param x defines the x coordinate of the operand
  2388. * @param y defines the y coordinate of the operand
  2389. * @param z defines the z coordinate of the operand
  2390. * @param result defines the Vector3 object where to store the result
  2391. * @returns the current Vector3
  2392. */
  2393. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2394. /**
  2395. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2396. * @returns a new Vector3
  2397. */
  2398. negate(): Vector3;
  2399. /**
  2400. * Multiplies the Vector3 coordinates by the float "scale"
  2401. * @param scale defines the multiplier factor
  2402. * @returns the current updated Vector3
  2403. */
  2404. scaleInPlace(scale: number): Vector3;
  2405. /**
  2406. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2407. * @param scale defines the multiplier factor
  2408. * @returns a new Vector3
  2409. */
  2410. scale(scale: number): Vector3;
  2411. /**
  2412. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2413. * @param scale defines the multiplier factor
  2414. * @param result defines the Vector3 object where to store the result
  2415. * @returns the current Vector3
  2416. */
  2417. scaleToRef(scale: number, result: Vector3): Vector3;
  2418. /**
  2419. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2420. * @param scale defines the scale factor
  2421. * @param result defines the Vector3 object where to store the result
  2422. * @returns the unmodified current Vector3
  2423. */
  2424. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2425. /**
  2426. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2427. * @param otherVector defines the second operand
  2428. * @returns true if both vectors are equals
  2429. */
  2430. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2431. /**
  2432. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2433. * @param otherVector defines the second operand
  2434. * @param epsilon defines the minimal distance to define values as equals
  2435. * @returns true if both vectors are distant less than epsilon
  2436. */
  2437. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2438. /**
  2439. * Returns true if the current Vector3 coordinates equals the given floats
  2440. * @param x defines the x coordinate of the operand
  2441. * @param y defines the y coordinate of the operand
  2442. * @param z defines the z coordinate of the operand
  2443. * @returns true if both vectors are equals
  2444. */
  2445. equalsToFloats(x: number, y: number, z: number): boolean;
  2446. /**
  2447. * Multiplies the current Vector3 coordinates by the given ones
  2448. * @param otherVector defines the second operand
  2449. * @returns the current updated Vector3
  2450. */
  2451. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2452. /**
  2453. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2454. * @param otherVector defines the second operand
  2455. * @returns the new Vector3
  2456. */
  2457. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2458. /**
  2459. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2460. * @param otherVector defines the second operand
  2461. * @param result defines the Vector3 object where to store the result
  2462. * @returns the current Vector3
  2463. */
  2464. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2465. /**
  2466. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2467. * @param x defines the x coordinate of the operand
  2468. * @param y defines the y coordinate of the operand
  2469. * @param z defines the z coordinate of the operand
  2470. * @returns the new Vector3
  2471. */
  2472. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2473. /**
  2474. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2475. * @param otherVector defines the second operand
  2476. * @returns the new Vector3
  2477. */
  2478. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2479. /**
  2480. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2481. * @param otherVector defines the second operand
  2482. * @param result defines the Vector3 object where to store the result
  2483. * @returns the current Vector3
  2484. */
  2485. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2486. /**
  2487. * Divides the current Vector3 coordinates by the given ones.
  2488. * @param otherVector defines the second operand
  2489. * @returns the current updated Vector3
  2490. */
  2491. divideInPlace(otherVector: Vector3): Vector3;
  2492. /**
  2493. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2494. * @param other defines the second operand
  2495. * @returns the current updated Vector3
  2496. */
  2497. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2498. /**
  2499. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2500. * @param other defines the second operand
  2501. * @returns the current updated Vector3
  2502. */
  2503. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2504. /**
  2505. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2506. * @param x defines the x coordinate of the operand
  2507. * @param y defines the y coordinate of the operand
  2508. * @param z defines the z coordinate of the operand
  2509. * @returns the current updated Vector3
  2510. */
  2511. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2512. /**
  2513. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2514. * @param x defines the x coordinate of the operand
  2515. * @param y defines the y coordinate of the operand
  2516. * @param z defines the z coordinate of the operand
  2517. * @returns the current updated Vector3
  2518. */
  2519. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2520. /**
  2521. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2522. * Check if is non uniform within a certain amount of decimal places to account for this
  2523. * @param epsilon the amount the values can differ
  2524. * @returns if the the vector is non uniform to a certain number of decimal places
  2525. */
  2526. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2527. /**
  2528. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2529. */
  2530. readonly isNonUniform: boolean;
  2531. /**
  2532. * Gets a new Vector3 from current Vector3 floored values
  2533. * @returns a new Vector3
  2534. */
  2535. floor(): Vector3;
  2536. /**
  2537. * Gets a new Vector3 from current Vector3 floored values
  2538. * @returns a new Vector3
  2539. */
  2540. fract(): Vector3;
  2541. /**
  2542. * Gets the length of the Vector3
  2543. * @returns the length of the Vector3
  2544. */
  2545. length(): number;
  2546. /**
  2547. * Gets the squared length of the Vector3
  2548. * @returns squared length of the Vector3
  2549. */
  2550. lengthSquared(): number;
  2551. /**
  2552. * Normalize the current Vector3.
  2553. * Please note that this is an in place operation.
  2554. * @returns the current updated Vector3
  2555. */
  2556. normalize(): Vector3;
  2557. /**
  2558. * Reorders the x y z properties of the vector in place
  2559. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2560. * @returns the current updated vector
  2561. */
  2562. reorderInPlace(order: string): this;
  2563. /**
  2564. * Rotates the vector around 0,0,0 by a quaternion
  2565. * @param quaternion the rotation quaternion
  2566. * @param result vector to store the result
  2567. * @returns the resulting vector
  2568. */
  2569. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2570. /**
  2571. * Rotates a vector around a given point
  2572. * @param quaternion the rotation quaternion
  2573. * @param point the point to rotate around
  2574. * @param result vector to store the result
  2575. * @returns the resulting vector
  2576. */
  2577. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2578. /**
  2579. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2580. * The cross product is then orthogonal to both current and "other"
  2581. * @param other defines the right operand
  2582. * @returns the cross product
  2583. */
  2584. cross(other: Vector3): Vector3;
  2585. /**
  2586. * Normalize the current Vector3 with the given input length.
  2587. * Please note that this is an in place operation.
  2588. * @param len the length of the vector
  2589. * @returns the current updated Vector3
  2590. */
  2591. normalizeFromLength(len: number): Vector3;
  2592. /**
  2593. * Normalize the current Vector3 to a new vector
  2594. * @returns the new Vector3
  2595. */
  2596. normalizeToNew(): Vector3;
  2597. /**
  2598. * Normalize the current Vector3 to the reference
  2599. * @param reference define the Vector3 to update
  2600. * @returns the updated Vector3
  2601. */
  2602. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2603. /**
  2604. * Creates a new Vector3 copied from the current Vector3
  2605. * @returns the new Vector3
  2606. */
  2607. clone(): Vector3;
  2608. /**
  2609. * Copies the given vector coordinates to the current Vector3 ones
  2610. * @param source defines the source Vector3
  2611. * @returns the current updated Vector3
  2612. */
  2613. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2614. /**
  2615. * Copies the given floats to the current Vector3 coordinates
  2616. * @param x defines the x coordinate of the operand
  2617. * @param y defines the y coordinate of the operand
  2618. * @param z defines the z coordinate of the operand
  2619. * @returns the current updated Vector3
  2620. */
  2621. copyFromFloats(x: number, y: number, z: number): Vector3;
  2622. /**
  2623. * Copies the given floats to the current Vector3 coordinates
  2624. * @param x defines the x coordinate of the operand
  2625. * @param y defines the y coordinate of the operand
  2626. * @param z defines the z coordinate of the operand
  2627. * @returns the current updated Vector3
  2628. */
  2629. set(x: number, y: number, z: number): Vector3;
  2630. /**
  2631. * Copies the given float to the current Vector3 coordinates
  2632. * @param v defines the x, y and z coordinates of the operand
  2633. * @returns the current updated Vector3
  2634. */
  2635. setAll(v: number): Vector3;
  2636. /**
  2637. * Get the clip factor between two vectors
  2638. * @param vector0 defines the first operand
  2639. * @param vector1 defines the second operand
  2640. * @param axis defines the axis to use
  2641. * @param size defines the size along the axis
  2642. * @returns the clip factor
  2643. */
  2644. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2645. /**
  2646. * Get angle between two vectors
  2647. * @param vector0 angle between vector0 and vector1
  2648. * @param vector1 angle between vector0 and vector1
  2649. * @param normal direction of the normal
  2650. * @return the angle between vector0 and vector1
  2651. */
  2652. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2653. /**
  2654. * Returns a new Vector3 set from the index "offset" of the given array
  2655. * @param array defines the source array
  2656. * @param offset defines the offset in the source array
  2657. * @returns the new Vector3
  2658. */
  2659. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2660. /**
  2661. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2662. * This function is deprecated. Use FromArray instead
  2663. * @param array defines the source array
  2664. * @param offset defines the offset in the source array
  2665. * @returns the new Vector3
  2666. */
  2667. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2668. /**
  2669. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2670. * @param array defines the source array
  2671. * @param offset defines the offset in the source array
  2672. * @param result defines the Vector3 where to store the result
  2673. */
  2674. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2675. /**
  2676. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2677. * This function is deprecated. Use FromArrayToRef instead.
  2678. * @param array defines the source array
  2679. * @param offset defines the offset in the source array
  2680. * @param result defines the Vector3 where to store the result
  2681. */
  2682. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2683. /**
  2684. * Sets the given vector "result" with the given floats.
  2685. * @param x defines the x coordinate of the source
  2686. * @param y defines the y coordinate of the source
  2687. * @param z defines the z coordinate of the source
  2688. * @param result defines the Vector3 where to store the result
  2689. */
  2690. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2691. /**
  2692. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2693. * @returns a new empty Vector3
  2694. */
  2695. static Zero(): Vector3;
  2696. /**
  2697. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2698. * @returns a new unit Vector3
  2699. */
  2700. static One(): Vector3;
  2701. /**
  2702. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2703. * @returns a new up Vector3
  2704. */
  2705. static Up(): Vector3;
  2706. /**
  2707. * Gets a up Vector3 that must not be updated
  2708. */
  2709. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2710. /**
  2711. * Gets a zero Vector3 that must not be updated
  2712. */
  2713. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2714. /**
  2715. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2716. * @returns a new down Vector3
  2717. */
  2718. static Down(): Vector3;
  2719. /**
  2720. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2721. * @returns a new forward Vector3
  2722. */
  2723. static Forward(): Vector3;
  2724. /**
  2725. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2726. * @returns a new forward Vector3
  2727. */
  2728. static Backward(): Vector3;
  2729. /**
  2730. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2731. * @returns a new right Vector3
  2732. */
  2733. static Right(): Vector3;
  2734. /**
  2735. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2736. * @returns a new left Vector3
  2737. */
  2738. static Left(): Vector3;
  2739. /**
  2740. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2741. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2742. * @param vector defines the Vector3 to transform
  2743. * @param transformation defines the transformation matrix
  2744. * @returns the transformed Vector3
  2745. */
  2746. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2747. /**
  2748. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2749. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2750. * @param vector defines the Vector3 to transform
  2751. * @param transformation defines the transformation matrix
  2752. * @param result defines the Vector3 where to store the result
  2753. */
  2754. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2755. /**
  2756. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2757. * This method computes tranformed coordinates only, not transformed direction vectors
  2758. * @param x define the x coordinate of the source vector
  2759. * @param y define the y coordinate of the source vector
  2760. * @param z define the z coordinate of the source vector
  2761. * @param transformation defines the transformation matrix
  2762. * @param result defines the Vector3 where to store the result
  2763. */
  2764. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2765. /**
  2766. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2767. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2768. * @param vector defines the Vector3 to transform
  2769. * @param transformation defines the transformation matrix
  2770. * @returns the new Vector3
  2771. */
  2772. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2773. /**
  2774. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2775. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2776. * @param vector defines the Vector3 to transform
  2777. * @param transformation defines the transformation matrix
  2778. * @param result defines the Vector3 where to store the result
  2779. */
  2780. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2781. /**
  2782. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2783. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2784. * @param x define the x coordinate of the source vector
  2785. * @param y define the y coordinate of the source vector
  2786. * @param z define the z coordinate of the source vector
  2787. * @param transformation defines the transformation matrix
  2788. * @param result defines the Vector3 where to store the result
  2789. */
  2790. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2791. /**
  2792. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2793. * @param value1 defines the first control point
  2794. * @param value2 defines the second control point
  2795. * @param value3 defines the third control point
  2796. * @param value4 defines the fourth control point
  2797. * @param amount defines the amount on the spline to use
  2798. * @returns the new Vector3
  2799. */
  2800. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2801. /**
  2802. * 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"
  2803. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2804. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2805. * @param value defines the current value
  2806. * @param min defines the lower range value
  2807. * @param max defines the upper range value
  2808. * @returns the new Vector3
  2809. */
  2810. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2811. /**
  2812. * 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"
  2813. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2814. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2815. * @param value defines the current value
  2816. * @param min defines the lower range value
  2817. * @param max defines the upper range value
  2818. * @param result defines the Vector3 where to store the result
  2819. */
  2820. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2821. /**
  2822. * Checks if a given vector is inside a specific range
  2823. * @param v defines the vector to test
  2824. * @param min defines the minimum range
  2825. * @param max defines the maximum range
  2826. */
  2827. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2828. /**
  2829. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2830. * @param value1 defines the first control point
  2831. * @param tangent1 defines the first tangent vector
  2832. * @param value2 defines the second control point
  2833. * @param tangent2 defines the second tangent vector
  2834. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2835. * @returns the new Vector3
  2836. */
  2837. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2838. /**
  2839. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2840. * @param start defines the start value
  2841. * @param end defines the end value
  2842. * @param amount max defines amount between both (between 0 and 1)
  2843. * @returns the new Vector3
  2844. */
  2845. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2846. /**
  2847. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2848. * @param start defines the start value
  2849. * @param end defines the end value
  2850. * @param amount max defines amount between both (between 0 and 1)
  2851. * @param result defines the Vector3 where to store the result
  2852. */
  2853. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2854. /**
  2855. * Returns the dot product (float) between the vectors "left" and "right"
  2856. * @param left defines the left operand
  2857. * @param right defines the right operand
  2858. * @returns the dot product
  2859. */
  2860. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2861. /**
  2862. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2863. * The cross product is then orthogonal to both "left" and "right"
  2864. * @param left defines the left operand
  2865. * @param right defines the right operand
  2866. * @returns the cross product
  2867. */
  2868. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2869. /**
  2870. * Sets the given vector "result" with the cross product of "left" and "right"
  2871. * The cross product is then orthogonal to both "left" and "right"
  2872. * @param left defines the left operand
  2873. * @param right defines the right operand
  2874. * @param result defines the Vector3 where to store the result
  2875. */
  2876. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2877. /**
  2878. * Returns a new Vector3 as the normalization of the given vector
  2879. * @param vector defines the Vector3 to normalize
  2880. * @returns the new Vector3
  2881. */
  2882. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2883. /**
  2884. * Sets the given vector "result" with the normalization of the given first vector
  2885. * @param vector defines the Vector3 to normalize
  2886. * @param result defines the Vector3 where to store the result
  2887. */
  2888. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2889. /**
  2890. * Project a Vector3 onto screen space
  2891. * @param vector defines the Vector3 to project
  2892. * @param world defines the world matrix to use
  2893. * @param transform defines the transform (view x projection) matrix to use
  2894. * @param viewport defines the screen viewport to use
  2895. * @returns the new Vector3
  2896. */
  2897. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2898. /** @hidden */ private static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2899. /**
  2900. * Unproject from screen space to object space
  2901. * @param source defines the screen space Vector3 to use
  2902. * @param viewportWidth defines the current width of the viewport
  2903. * @param viewportHeight defines the current height of the viewport
  2904. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2905. * @param transform defines the transform (view x projection) matrix to use
  2906. * @returns the new Vector3
  2907. */
  2908. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2909. /**
  2910. * Unproject from screen space to object space
  2911. * @param source defines the screen space Vector3 to use
  2912. * @param viewportWidth defines the current width of the viewport
  2913. * @param viewportHeight defines the current height of the viewport
  2914. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2915. * @param view defines the view matrix to use
  2916. * @param projection defines the projection matrix to use
  2917. * @returns the new Vector3
  2918. */
  2919. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2920. /**
  2921. * Unproject from screen space to object space
  2922. * @param source defines the screen space Vector3 to use
  2923. * @param viewportWidth defines the current width of the viewport
  2924. * @param viewportHeight defines the current height of the viewport
  2925. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2926. * @param view defines the view matrix to use
  2927. * @param projection defines the projection matrix to use
  2928. * @param result defines the Vector3 where to store the result
  2929. */
  2930. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2931. /**
  2932. * Unproject from screen space to object space
  2933. * @param sourceX defines the screen space x coordinate to use
  2934. * @param sourceY defines the screen space y coordinate to use
  2935. * @param sourceZ defines the screen space z coordinate to use
  2936. * @param viewportWidth defines the current width of the viewport
  2937. * @param viewportHeight defines the current height of the viewport
  2938. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2939. * @param view defines the view matrix to use
  2940. * @param projection defines the projection matrix to use
  2941. * @param result defines the Vector3 where to store the result
  2942. */
  2943. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2944. /**
  2945. * Gets the minimal coordinate values between two Vector3
  2946. * @param left defines the first operand
  2947. * @param right defines the second operand
  2948. * @returns the new Vector3
  2949. */
  2950. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2951. /**
  2952. * Gets the maximal coordinate values between two Vector3
  2953. * @param left defines the first operand
  2954. * @param right defines the second operand
  2955. * @returns the new Vector3
  2956. */
  2957. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2958. /**
  2959. * Returns the distance between the vectors "value1" and "value2"
  2960. * @param value1 defines the first operand
  2961. * @param value2 defines the second operand
  2962. * @returns the distance
  2963. */
  2964. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2965. /**
  2966. * Returns the squared distance between the vectors "value1" and "value2"
  2967. * @param value1 defines the first operand
  2968. * @param value2 defines the second operand
  2969. * @returns the squared distance
  2970. */
  2971. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2972. /**
  2973. * Returns a new Vector3 located at the center between "value1" and "value2"
  2974. * @param value1 defines the first operand
  2975. * @param value2 defines the second operand
  2976. * @returns the new Vector3
  2977. */
  2978. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2979. /**
  2980. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2981. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2982. * to something in order to rotate it from its local system to the given target system
  2983. * Note: axis1, axis2 and axis3 are normalized during this operation
  2984. * @param axis1 defines the first axis
  2985. * @param axis2 defines the second axis
  2986. * @param axis3 defines the third axis
  2987. * @returns a new Vector3
  2988. */
  2989. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2990. /**
  2991. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2992. * @param axis1 defines the first axis
  2993. * @param axis2 defines the second axis
  2994. * @param axis3 defines the third axis
  2995. * @param ref defines the Vector3 where to store the result
  2996. */
  2997. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2998. }
  2999. /**
  3000. * Vector4 class created for EulerAngle class conversion to Quaternion
  3001. */
  3002. export class Vector4 {
  3003. /** x value of the vector */
  3004. x: number;
  3005. /** y value of the vector */
  3006. y: number;
  3007. /** z value of the vector */
  3008. z: number;
  3009. /** w value of the vector */
  3010. w: number;
  3011. /**
  3012. * Creates a Vector4 object from the given floats.
  3013. * @param x x value of the vector
  3014. * @param y y value of the vector
  3015. * @param z z value of the vector
  3016. * @param w w value of the vector
  3017. */
  3018. constructor(
  3019. /** x value of the vector */
  3020. x: number,
  3021. /** y value of the vector */
  3022. y: number,
  3023. /** z value of the vector */
  3024. z: number,
  3025. /** w value of the vector */
  3026. w: number);
  3027. /**
  3028. * Returns the string with the Vector4 coordinates.
  3029. * @returns a string containing all the vector values
  3030. */
  3031. toString(): string;
  3032. /**
  3033. * Returns the string "Vector4".
  3034. * @returns "Vector4"
  3035. */
  3036. getClassName(): string;
  3037. /**
  3038. * Returns the Vector4 hash code.
  3039. * @returns a unique hash code
  3040. */
  3041. getHashCode(): number;
  3042. /**
  3043. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3044. * @returns the resulting array
  3045. */
  3046. asArray(): number[];
  3047. /**
  3048. * Populates the given array from the given index with the Vector4 coordinates.
  3049. * @param array array to populate
  3050. * @param index index of the array to start at (default: 0)
  3051. * @returns the Vector4.
  3052. */
  3053. toArray(array: FloatArray, index?: number): Vector4;
  3054. /**
  3055. * Adds the given vector to the current Vector4.
  3056. * @param otherVector the vector to add
  3057. * @returns the updated Vector4.
  3058. */
  3059. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3060. /**
  3061. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3062. * @param otherVector the vector to add
  3063. * @returns the resulting vector
  3064. */
  3065. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3066. /**
  3067. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3068. * @param otherVector the vector to add
  3069. * @param result the vector to store the result
  3070. * @returns the current Vector4.
  3071. */
  3072. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3073. /**
  3074. * Subtract in place the given vector from the current Vector4.
  3075. * @param otherVector the vector to subtract
  3076. * @returns the updated Vector4.
  3077. */
  3078. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3079. /**
  3080. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3081. * @param otherVector the vector to add
  3082. * @returns the new vector with the result
  3083. */
  3084. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3085. /**
  3086. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3087. * @param otherVector the vector to subtract
  3088. * @param result the vector to store the result
  3089. * @returns the current Vector4.
  3090. */
  3091. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3092. /**
  3093. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3094. */
  3095. /**
  3096. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3097. * @param x value to subtract
  3098. * @param y value to subtract
  3099. * @param z value to subtract
  3100. * @param w value to subtract
  3101. * @returns new vector containing the result
  3102. */
  3103. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3104. /**
  3105. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3106. * @param x value to subtract
  3107. * @param y value to subtract
  3108. * @param z value to subtract
  3109. * @param w value to subtract
  3110. * @param result the vector to store the result in
  3111. * @returns the current Vector4.
  3112. */
  3113. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3114. /**
  3115. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3116. * @returns a new vector with the negated values
  3117. */
  3118. negate(): Vector4;
  3119. /**
  3120. * Multiplies the current Vector4 coordinates by scale (float).
  3121. * @param scale the number to scale with
  3122. * @returns the updated Vector4.
  3123. */
  3124. scaleInPlace(scale: number): Vector4;
  3125. /**
  3126. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3127. * @param scale the number to scale with
  3128. * @returns a new vector with the result
  3129. */
  3130. scale(scale: number): Vector4;
  3131. /**
  3132. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3133. * @param scale the number to scale with
  3134. * @param result a vector to store the result in
  3135. * @returns the current Vector4.
  3136. */
  3137. scaleToRef(scale: number, result: Vector4): Vector4;
  3138. /**
  3139. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3140. * @param scale defines the scale factor
  3141. * @param result defines the Vector4 object where to store the result
  3142. * @returns the unmodified current Vector4
  3143. */
  3144. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3145. /**
  3146. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3147. * @param otherVector the vector to compare against
  3148. * @returns true if they are equal
  3149. */
  3150. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3151. /**
  3152. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3153. * @param otherVector vector to compare against
  3154. * @param epsilon (Default: very small number)
  3155. * @returns true if they are equal
  3156. */
  3157. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3158. /**
  3159. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3160. * @param x x value to compare against
  3161. * @param y y value to compare against
  3162. * @param z z value to compare against
  3163. * @param w w value to compare against
  3164. * @returns true if equal
  3165. */
  3166. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3167. /**
  3168. * Multiplies in place the current Vector4 by the given one.
  3169. * @param otherVector vector to multiple with
  3170. * @returns the updated Vector4.
  3171. */
  3172. multiplyInPlace(otherVector: Vector4): Vector4;
  3173. /**
  3174. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3175. * @param otherVector vector to multiple with
  3176. * @returns resulting new vector
  3177. */
  3178. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3179. /**
  3180. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3181. * @param otherVector vector to multiple with
  3182. * @param result vector to store the result
  3183. * @returns the current Vector4.
  3184. */
  3185. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3186. /**
  3187. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3188. * @param x x value multiply with
  3189. * @param y y value multiply with
  3190. * @param z z value multiply with
  3191. * @param w w value multiply with
  3192. * @returns resulting new vector
  3193. */
  3194. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3195. /**
  3196. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3197. * @param otherVector vector to devide with
  3198. * @returns resulting new vector
  3199. */
  3200. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3201. /**
  3202. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3203. * @param otherVector vector to devide with
  3204. * @param result vector to store the result
  3205. * @returns the current Vector4.
  3206. */
  3207. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3208. /**
  3209. * Divides the current Vector3 coordinates by the given ones.
  3210. * @param otherVector vector to devide with
  3211. * @returns the updated Vector3.
  3212. */
  3213. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3214. /**
  3215. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3216. * @param other defines the second operand
  3217. * @returns the current updated Vector4
  3218. */
  3219. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3220. /**
  3221. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3222. * @param other defines the second operand
  3223. * @returns the current updated Vector4
  3224. */
  3225. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3226. /**
  3227. * Gets a new Vector4 from current Vector4 floored values
  3228. * @returns a new Vector4
  3229. */
  3230. floor(): Vector4;
  3231. /**
  3232. * Gets a new Vector4 from current Vector3 floored values
  3233. * @returns a new Vector4
  3234. */
  3235. fract(): Vector4;
  3236. /**
  3237. * Returns the Vector4 length (float).
  3238. * @returns the length
  3239. */
  3240. length(): number;
  3241. /**
  3242. * Returns the Vector4 squared length (float).
  3243. * @returns the length squared
  3244. */
  3245. lengthSquared(): number;
  3246. /**
  3247. * Normalizes in place the Vector4.
  3248. * @returns the updated Vector4.
  3249. */
  3250. normalize(): Vector4;
  3251. /**
  3252. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3253. * @returns this converted to a new vector3
  3254. */
  3255. toVector3(): Vector3;
  3256. /**
  3257. * Returns a new Vector4 copied from the current one.
  3258. * @returns the new cloned vector
  3259. */
  3260. clone(): Vector4;
  3261. /**
  3262. * Updates the current Vector4 with the given one coordinates.
  3263. * @param source the source vector to copy from
  3264. * @returns the updated Vector4.
  3265. */
  3266. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3267. /**
  3268. * Updates the current Vector4 coordinates with the given floats.
  3269. * @param x float to copy from
  3270. * @param y float to copy from
  3271. * @param z float to copy from
  3272. * @param w float to copy from
  3273. * @returns the updated Vector4.
  3274. */
  3275. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3276. /**
  3277. * Updates the current Vector4 coordinates with the given floats.
  3278. * @param x float to set from
  3279. * @param y float to set from
  3280. * @param z float to set from
  3281. * @param w float to set from
  3282. * @returns the updated Vector4.
  3283. */
  3284. set(x: number, y: number, z: number, w: number): Vector4;
  3285. /**
  3286. * Copies the given float to the current Vector3 coordinates
  3287. * @param v defines the x, y, z and w coordinates of the operand
  3288. * @returns the current updated Vector3
  3289. */
  3290. setAll(v: number): Vector4;
  3291. /**
  3292. * Returns a new Vector4 set from the starting index of the given array.
  3293. * @param array the array to pull values from
  3294. * @param offset the offset into the array to start at
  3295. * @returns the new vector
  3296. */
  3297. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3298. /**
  3299. * Updates the given vector "result" from the starting index of the given array.
  3300. * @param array the array to pull values from
  3301. * @param offset the offset into the array to start at
  3302. * @param result the vector to store the result in
  3303. */
  3304. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3305. /**
  3306. * Updates the given vector "result" from the starting index of the given Float32Array.
  3307. * @param array the array to pull values from
  3308. * @param offset the offset into the array to start at
  3309. * @param result the vector to store the result in
  3310. */
  3311. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3312. /**
  3313. * Updates the given vector "result" coordinates from the given floats.
  3314. * @param x float to set from
  3315. * @param y float to set from
  3316. * @param z float to set from
  3317. * @param w float to set from
  3318. * @param result the vector to the floats in
  3319. */
  3320. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3321. /**
  3322. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3323. * @returns the new vector
  3324. */
  3325. static Zero(): Vector4;
  3326. /**
  3327. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3328. * @returns the new vector
  3329. */
  3330. static One(): Vector4;
  3331. /**
  3332. * Returns a new normalized Vector4 from the given one.
  3333. * @param vector the vector to normalize
  3334. * @returns the vector
  3335. */
  3336. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3337. /**
  3338. * Updates the given vector "result" from the normalization of the given one.
  3339. * @param vector the vector to normalize
  3340. * @param result the vector to store the result in
  3341. */
  3342. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3343. /**
  3344. * Returns a vector with the minimum values from the left and right vectors
  3345. * @param left left vector to minimize
  3346. * @param right right vector to minimize
  3347. * @returns a new vector with the minimum of the left and right vector values
  3348. */
  3349. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3350. /**
  3351. * Returns a vector with the maximum values from the left and right vectors
  3352. * @param left left vector to maximize
  3353. * @param right right vector to maximize
  3354. * @returns a new vector with the maximum of the left and right vector values
  3355. */
  3356. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3357. /**
  3358. * Returns the distance (float) between the vectors "value1" and "value2".
  3359. * @param value1 value to calulate the distance between
  3360. * @param value2 value to calulate the distance between
  3361. * @return the distance between the two vectors
  3362. */
  3363. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3364. /**
  3365. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3366. * @param value1 value to calulate the distance between
  3367. * @param value2 value to calulate the distance between
  3368. * @return the distance between the two vectors squared
  3369. */
  3370. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3371. /**
  3372. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3373. * @param value1 value to calulate the center between
  3374. * @param value2 value to calulate the center between
  3375. * @return the center between the two vectors
  3376. */
  3377. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3378. /**
  3379. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3380. * This methods computes transformed normalized direction vectors only.
  3381. * @param vector the vector to transform
  3382. * @param transformation the transformation matrix to apply
  3383. * @returns the new vector
  3384. */
  3385. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3386. /**
  3387. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3388. * This methods computes transformed normalized direction vectors only.
  3389. * @param vector the vector to transform
  3390. * @param transformation the transformation matrix to apply
  3391. * @param result the vector to store the result in
  3392. */
  3393. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3394. /**
  3395. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3396. * This methods computes transformed normalized direction vectors only.
  3397. * @param x value to transform
  3398. * @param y value to transform
  3399. * @param z value to transform
  3400. * @param w value to transform
  3401. * @param transformation the transformation matrix to apply
  3402. * @param result the vector to store the results in
  3403. */
  3404. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3405. /**
  3406. * Creates a new Vector4 from a Vector3
  3407. * @param source defines the source data
  3408. * @param w defines the 4th component (default is 0)
  3409. * @returns a new Vector4
  3410. */
  3411. static FromVector3(source: Vector3, w?: number): Vector4;
  3412. }
  3413. /**
  3414. * Class used to store quaternion data
  3415. * @see https://en.wikipedia.org/wiki/Quaternion
  3416. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3417. */
  3418. export class Quaternion {
  3419. /** defines the first component (0 by default) */
  3420. x: number;
  3421. /** defines the second component (0 by default) */
  3422. y: number;
  3423. /** defines the third component (0 by default) */
  3424. z: number;
  3425. /** defines the fourth component (1.0 by default) */
  3426. w: number;
  3427. /**
  3428. * Creates a new Quaternion from the given floats
  3429. * @param x defines the first component (0 by default)
  3430. * @param y defines the second component (0 by default)
  3431. * @param z defines the third component (0 by default)
  3432. * @param w defines the fourth component (1.0 by default)
  3433. */
  3434. constructor(
  3435. /** defines the first component (0 by default) */
  3436. x?: number,
  3437. /** defines the second component (0 by default) */
  3438. y?: number,
  3439. /** defines the third component (0 by default) */
  3440. z?: number,
  3441. /** defines the fourth component (1.0 by default) */
  3442. w?: number);
  3443. /**
  3444. * Gets a string representation for the current quaternion
  3445. * @returns a string with the Quaternion coordinates
  3446. */
  3447. toString(): string;
  3448. /**
  3449. * Gets the class name of the quaternion
  3450. * @returns the string "Quaternion"
  3451. */
  3452. getClassName(): string;
  3453. /**
  3454. * Gets a hash code for this quaternion
  3455. * @returns the quaternion hash code
  3456. */
  3457. getHashCode(): number;
  3458. /**
  3459. * Copy the quaternion to an array
  3460. * @returns a new array populated with 4 elements from the quaternion coordinates
  3461. */
  3462. asArray(): number[];
  3463. /**
  3464. * Check if two quaternions are equals
  3465. * @param otherQuaternion defines the second operand
  3466. * @return true if the current quaternion and the given one coordinates are strictly equals
  3467. */
  3468. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3469. /**
  3470. * Clone the current quaternion
  3471. * @returns a new quaternion copied from the current one
  3472. */
  3473. clone(): Quaternion;
  3474. /**
  3475. * Copy a quaternion to the current one
  3476. * @param other defines the other quaternion
  3477. * @returns the updated current quaternion
  3478. */
  3479. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3480. /**
  3481. * Updates the current quaternion with the given float coordinates
  3482. * @param x defines the x coordinate
  3483. * @param y defines the y coordinate
  3484. * @param z defines the z coordinate
  3485. * @param w defines the w coordinate
  3486. * @returns the updated current quaternion
  3487. */
  3488. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3489. /**
  3490. * Updates the current quaternion from the given float coordinates
  3491. * @param x defines the x coordinate
  3492. * @param y defines the y coordinate
  3493. * @param z defines the z coordinate
  3494. * @param w defines the w coordinate
  3495. * @returns the updated current quaternion
  3496. */
  3497. set(x: number, y: number, z: number, w: number): Quaternion;
  3498. /**
  3499. * Adds two quaternions
  3500. * @param other defines the second operand
  3501. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3502. */
  3503. add(other: DeepImmutable<Quaternion>): Quaternion;
  3504. /**
  3505. * Add a quaternion to the current one
  3506. * @param other defines the quaternion to add
  3507. * @returns the current quaternion
  3508. */
  3509. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3510. /**
  3511. * Subtract two quaternions
  3512. * @param other defines the second operand
  3513. * @returns a new quaternion as the subtraction result of the given one from the current one
  3514. */
  3515. subtract(other: Quaternion): Quaternion;
  3516. /**
  3517. * Multiplies the current quaternion by a scale factor
  3518. * @param value defines the scale factor
  3519. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3520. */
  3521. scale(value: number): Quaternion;
  3522. /**
  3523. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3524. * @param scale defines the scale factor
  3525. * @param result defines the Quaternion object where to store the result
  3526. * @returns the unmodified current quaternion
  3527. */
  3528. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3529. /**
  3530. * Multiplies in place the current quaternion by a scale factor
  3531. * @param value defines the scale factor
  3532. * @returns the current modified quaternion
  3533. */
  3534. scaleInPlace(value: number): Quaternion;
  3535. /**
  3536. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3537. * @param scale defines the scale factor
  3538. * @param result defines the Quaternion object where to store the result
  3539. * @returns the unmodified current quaternion
  3540. */
  3541. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3542. /**
  3543. * Multiplies two quaternions
  3544. * @param q1 defines the second operand
  3545. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3546. */
  3547. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3548. /**
  3549. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3550. * @param q1 defines the second operand
  3551. * @param result defines the target quaternion
  3552. * @returns the current quaternion
  3553. */
  3554. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3555. /**
  3556. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3557. * @param q1 defines the second operand
  3558. * @returns the currentupdated quaternion
  3559. */
  3560. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3561. /**
  3562. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3563. * @param ref defines the target quaternion
  3564. * @returns the current quaternion
  3565. */
  3566. conjugateToRef(ref: Quaternion): Quaternion;
  3567. /**
  3568. * Conjugates in place (1-q) the current quaternion
  3569. * @returns the current updated quaternion
  3570. */
  3571. conjugateInPlace(): Quaternion;
  3572. /**
  3573. * Conjugates in place (1-q) the current quaternion
  3574. * @returns a new quaternion
  3575. */
  3576. conjugate(): Quaternion;
  3577. /**
  3578. * Gets length of current quaternion
  3579. * @returns the quaternion length (float)
  3580. */
  3581. length(): number;
  3582. /**
  3583. * Normalize in place the current quaternion
  3584. * @returns the current updated quaternion
  3585. */
  3586. normalize(): Quaternion;
  3587. /**
  3588. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3589. * @param order is a reserved parameter and is ignore for now
  3590. * @returns a new Vector3 containing the Euler angles
  3591. */
  3592. toEulerAngles(order?: string): Vector3;
  3593. /**
  3594. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3595. * @param result defines the vector which will be filled with the Euler angles
  3596. * @param order is a reserved parameter and is ignore for now
  3597. * @returns the current unchanged quaternion
  3598. */
  3599. toEulerAnglesToRef(result: Vector3): Quaternion;
  3600. /**
  3601. * Updates the given rotation matrix with the current quaternion values
  3602. * @param result defines the target matrix
  3603. * @returns the current unchanged quaternion
  3604. */
  3605. toRotationMatrix(result: Matrix): Quaternion;
  3606. /**
  3607. * Updates the current quaternion from the given rotation matrix values
  3608. * @param matrix defines the source matrix
  3609. * @returns the current updated quaternion
  3610. */
  3611. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3612. /**
  3613. * Creates a new quaternion from a rotation matrix
  3614. * @param matrix defines the source matrix
  3615. * @returns a new quaternion created from the given rotation matrix values
  3616. */
  3617. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3618. /**
  3619. * Updates the given quaternion with the given rotation matrix values
  3620. * @param matrix defines the source matrix
  3621. * @param result defines the target quaternion
  3622. */
  3623. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3624. /**
  3625. * Returns the dot product (float) between the quaternions "left" and "right"
  3626. * @param left defines the left operand
  3627. * @param right defines the right operand
  3628. * @returns the dot product
  3629. */
  3630. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3631. /**
  3632. * Checks if the two quaternions are close to each other
  3633. * @param quat0 defines the first quaternion to check
  3634. * @param quat1 defines the second quaternion to check
  3635. * @returns true if the two quaternions are close to each other
  3636. */
  3637. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3638. /**
  3639. * Creates an empty quaternion
  3640. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3641. */
  3642. static Zero(): Quaternion;
  3643. /**
  3644. * Inverse a given quaternion
  3645. * @param q defines the source quaternion
  3646. * @returns a new quaternion as the inverted current quaternion
  3647. */
  3648. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3649. /**
  3650. * Inverse a given quaternion
  3651. * @param q defines the source quaternion
  3652. * @param result the quaternion the result will be stored in
  3653. * @returns the result quaternion
  3654. */
  3655. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3656. /**
  3657. * Creates an identity quaternion
  3658. * @returns the identity quaternion
  3659. */
  3660. static Identity(): Quaternion;
  3661. /**
  3662. * Gets a boolean indicating if the given quaternion is identity
  3663. * @param quaternion defines the quaternion to check
  3664. * @returns true if the quaternion is identity
  3665. */
  3666. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3667. /**
  3668. * Creates a quaternion from a rotation around an axis
  3669. * @param axis defines the axis to use
  3670. * @param angle defines the angle to use
  3671. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3672. */
  3673. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3674. /**
  3675. * Creates a rotation around an axis and stores it into the given quaternion
  3676. * @param axis defines the axis to use
  3677. * @param angle defines the angle to use
  3678. * @param result defines the target quaternion
  3679. * @returns the target quaternion
  3680. */
  3681. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3682. /**
  3683. * Creates a new quaternion from data stored into an array
  3684. * @param array defines the data source
  3685. * @param offset defines the offset in the source array where the data starts
  3686. * @returns a new quaternion
  3687. */
  3688. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3689. /**
  3690. * Create a quaternion from Euler rotation angles
  3691. * @param x Pitch
  3692. * @param y Yaw
  3693. * @param z Roll
  3694. * @returns the new Quaternion
  3695. */
  3696. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3697. /**
  3698. * Updates a quaternion from Euler rotation angles
  3699. * @param x Pitch
  3700. * @param y Yaw
  3701. * @param z Roll
  3702. * @param result the quaternion to store the result
  3703. * @returns the updated quaternion
  3704. */
  3705. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3706. /**
  3707. * Create a quaternion from Euler rotation vector
  3708. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3709. * @returns the new Quaternion
  3710. */
  3711. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3712. /**
  3713. * Updates a quaternion from Euler rotation vector
  3714. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3715. * @param result the quaternion to store the result
  3716. * @returns the updated quaternion
  3717. */
  3718. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3719. /**
  3720. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3721. * @param yaw defines the rotation around Y axis
  3722. * @param pitch defines the rotation around X axis
  3723. * @param roll defines the rotation around Z axis
  3724. * @returns the new quaternion
  3725. */
  3726. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3727. /**
  3728. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3729. * @param yaw defines the rotation around Y axis
  3730. * @param pitch defines the rotation around X axis
  3731. * @param roll defines the rotation around Z axis
  3732. * @param result defines the target quaternion
  3733. */
  3734. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3735. /**
  3736. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3737. * @param alpha defines the rotation around first axis
  3738. * @param beta defines the rotation around second axis
  3739. * @param gamma defines the rotation around third axis
  3740. * @returns the new quaternion
  3741. */
  3742. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3743. /**
  3744. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3745. * @param alpha defines the rotation around first axis
  3746. * @param beta defines the rotation around second axis
  3747. * @param gamma defines the rotation around third axis
  3748. * @param result defines the target quaternion
  3749. */
  3750. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3751. /**
  3752. * 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)
  3753. * @param axis1 defines the first axis
  3754. * @param axis2 defines the second axis
  3755. * @param axis3 defines the third axis
  3756. * @returns the new quaternion
  3757. */
  3758. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3759. /**
  3760. * 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
  3761. * @param axis1 defines the first axis
  3762. * @param axis2 defines the second axis
  3763. * @param axis3 defines the third axis
  3764. * @param ref defines the target quaternion
  3765. */
  3766. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3767. /**
  3768. * Interpolates between two quaternions
  3769. * @param left defines first quaternion
  3770. * @param right defines second quaternion
  3771. * @param amount defines the gradient to use
  3772. * @returns the new interpolated quaternion
  3773. */
  3774. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3775. /**
  3776. * Interpolates between two quaternions and stores it into a target quaternion
  3777. * @param left defines first quaternion
  3778. * @param right defines second quaternion
  3779. * @param amount defines the gradient to use
  3780. * @param result defines the target quaternion
  3781. */
  3782. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3783. /**
  3784. * Interpolate between two quaternions using Hermite interpolation
  3785. * @param value1 defines first quaternion
  3786. * @param tangent1 defines the incoming tangent
  3787. * @param value2 defines second quaternion
  3788. * @param tangent2 defines the outgoing tangent
  3789. * @param amount defines the target quaternion
  3790. * @returns the new interpolated quaternion
  3791. */
  3792. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3793. }
  3794. /**
  3795. * Class used to store matrix data (4x4)
  3796. */
  3797. export class Matrix {
  3798. private static _updateFlagSeed;
  3799. private static _identityReadOnly;
  3800. private _isIdentity;
  3801. private _isIdentityDirty;
  3802. private _isIdentity3x2;
  3803. private _isIdentity3x2Dirty;
  3804. /**
  3805. * Gets the update flag of the matrix which is an unique number for the matrix.
  3806. * It will be incremented every time the matrix data change.
  3807. * You can use it to speed the comparison between two versions of the same matrix.
  3808. */
  3809. updateFlag: number;
  3810. private readonly _m;
  3811. /**
  3812. * Gets the internal data of the matrix
  3813. */
  3814. readonly m: DeepImmutable<Float32Array>;
  3815. /** @hidden */ private _markAsUpdated(): void;
  3816. /** @hidden */
  3817. private _updateIdentityStatus;
  3818. /**
  3819. * Creates an empty matrix (filled with zeros)
  3820. */
  3821. constructor();
  3822. /**
  3823. * Check if the current matrix is identity
  3824. * @returns true is the matrix is the identity matrix
  3825. */
  3826. isIdentity(): boolean;
  3827. /**
  3828. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3829. * @returns true is the matrix is the identity matrix
  3830. */
  3831. isIdentityAs3x2(): boolean;
  3832. /**
  3833. * Gets the determinant of the matrix
  3834. * @returns the matrix determinant
  3835. */
  3836. determinant(): number;
  3837. /**
  3838. * Returns the matrix as a Float32Array
  3839. * @returns the matrix underlying array
  3840. */
  3841. toArray(): DeepImmutable<Float32Array>;
  3842. /**
  3843. * Returns the matrix as a Float32Array
  3844. * @returns the matrix underlying array.
  3845. */
  3846. asArray(): DeepImmutable<Float32Array>;
  3847. /**
  3848. * Inverts the current matrix in place
  3849. * @returns the current inverted matrix
  3850. */
  3851. invert(): Matrix;
  3852. /**
  3853. * Sets all the matrix elements to zero
  3854. * @returns the current matrix
  3855. */
  3856. reset(): Matrix;
  3857. /**
  3858. * Adds the current matrix with a second one
  3859. * @param other defines the matrix to add
  3860. * @returns a new matrix as the addition of the current matrix and the given one
  3861. */
  3862. add(other: DeepImmutable<Matrix>): Matrix;
  3863. /**
  3864. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3865. * @param other defines the matrix to add
  3866. * @param result defines the target matrix
  3867. * @returns the current matrix
  3868. */
  3869. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3870. /**
  3871. * Adds in place the given matrix to the current matrix
  3872. * @param other defines the second operand
  3873. * @returns the current updated matrix
  3874. */
  3875. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3876. /**
  3877. * Sets the given matrix to the current inverted Matrix
  3878. * @param other defines the target matrix
  3879. * @returns the unmodified current matrix
  3880. */
  3881. invertToRef(other: Matrix): Matrix;
  3882. /**
  3883. * add a value at the specified position in the current Matrix
  3884. * @param index the index of the value within the matrix. between 0 and 15.
  3885. * @param value the value to be added
  3886. * @returns the current updated matrix
  3887. */
  3888. addAtIndex(index: number, value: number): Matrix;
  3889. /**
  3890. * mutiply the specified position in the current Matrix by a value
  3891. * @param index the index of the value within the matrix. between 0 and 15.
  3892. * @param value the value to be added
  3893. * @returns the current updated matrix
  3894. */
  3895. multiplyAtIndex(index: number, value: number): Matrix;
  3896. /**
  3897. * Inserts the translation vector (using 3 floats) in the current matrix
  3898. * @param x defines the 1st component of the translation
  3899. * @param y defines the 2nd component of the translation
  3900. * @param z defines the 3rd component of the translation
  3901. * @returns the current updated matrix
  3902. */
  3903. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3904. /**
  3905. * Adds the translation vector (using 3 floats) in the current matrix
  3906. * @param x defines the 1st component of the translation
  3907. * @param y defines the 2nd component of the translation
  3908. * @param z defines the 3rd component of the translation
  3909. * @returns the current updated matrix
  3910. */
  3911. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3912. /**
  3913. * Inserts the translation vector in the current matrix
  3914. * @param vector3 defines the translation to insert
  3915. * @returns the current updated matrix
  3916. */
  3917. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3918. /**
  3919. * Gets the translation value of the current matrix
  3920. * @returns a new Vector3 as the extracted translation from the matrix
  3921. */
  3922. getTranslation(): Vector3;
  3923. /**
  3924. * Fill a Vector3 with the extracted translation from the matrix
  3925. * @param result defines the Vector3 where to store the translation
  3926. * @returns the current matrix
  3927. */
  3928. getTranslationToRef(result: Vector3): Matrix;
  3929. /**
  3930. * Remove rotation and scaling part from the matrix
  3931. * @returns the updated matrix
  3932. */
  3933. removeRotationAndScaling(): Matrix;
  3934. /**
  3935. * Multiply two matrices
  3936. * @param other defines the second operand
  3937. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3938. */
  3939. multiply(other: DeepImmutable<Matrix>): Matrix;
  3940. /**
  3941. * Copy the current matrix from the given one
  3942. * @param other defines the source matrix
  3943. * @returns the current updated matrix
  3944. */
  3945. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3946. /**
  3947. * Populates the given array from the starting index with the current matrix values
  3948. * @param array defines the target array
  3949. * @param offset defines the offset in the target array where to start storing values
  3950. * @returns the current matrix
  3951. */
  3952. copyToArray(array: Float32Array, offset?: number): Matrix;
  3953. /**
  3954. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3955. * @param other defines the second operand
  3956. * @param result defines the matrix where to store the multiplication
  3957. * @returns the current matrix
  3958. */
  3959. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3960. /**
  3961. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3962. * @param other defines the second operand
  3963. * @param result defines the array where to store the multiplication
  3964. * @param offset defines the offset in the target array where to start storing values
  3965. * @returns the current matrix
  3966. */
  3967. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3968. /**
  3969. * Check equality between this matrix and a second one
  3970. * @param value defines the second matrix to compare
  3971. * @returns true is the current matrix and the given one values are strictly equal
  3972. */
  3973. equals(value: DeepImmutable<Matrix>): boolean;
  3974. /**
  3975. * Clone the current matrix
  3976. * @returns a new matrix from the current matrix
  3977. */
  3978. clone(): Matrix;
  3979. /**
  3980. * Returns the name of the current matrix class
  3981. * @returns the string "Matrix"
  3982. */
  3983. getClassName(): string;
  3984. /**
  3985. * Gets the hash code of the current matrix
  3986. * @returns the hash code
  3987. */
  3988. getHashCode(): number;
  3989. /**
  3990. * Decomposes the current Matrix into a translation, rotation and scaling components
  3991. * @param scale defines the scale vector3 given as a reference to update
  3992. * @param rotation defines the rotation quaternion given as a reference to update
  3993. * @param translation defines the translation vector3 given as a reference to update
  3994. * @returns true if operation was successful
  3995. */
  3996. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3997. /**
  3998. * Gets specific row of the matrix
  3999. * @param index defines the number of the row to get
  4000. * @returns the index-th row of the current matrix as a new Vector4
  4001. */
  4002. getRow(index: number): Nullable<Vector4>;
  4003. /**
  4004. * Sets the index-th row of the current matrix to the vector4 values
  4005. * @param index defines the number of the row to set
  4006. * @param row defines the target vector4
  4007. * @returns the updated current matrix
  4008. */
  4009. setRow(index: number, row: Vector4): Matrix;
  4010. /**
  4011. * Compute the transpose of the matrix
  4012. * @returns the new transposed matrix
  4013. */
  4014. transpose(): Matrix;
  4015. /**
  4016. * Compute the transpose of the matrix and store it in a given matrix
  4017. * @param result defines the target matrix
  4018. * @returns the current matrix
  4019. */
  4020. transposeToRef(result: Matrix): Matrix;
  4021. /**
  4022. * Sets the index-th row of the current matrix with the given 4 x float values
  4023. * @param index defines the row index
  4024. * @param x defines the x component to set
  4025. * @param y defines the y component to set
  4026. * @param z defines the z component to set
  4027. * @param w defines the w component to set
  4028. * @returns the updated current matrix
  4029. */
  4030. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4031. /**
  4032. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4033. * @param scale defines the scale factor
  4034. * @returns a new matrix
  4035. */
  4036. scale(scale: number): Matrix;
  4037. /**
  4038. * Scale the current matrix values by a factor to a given result matrix
  4039. * @param scale defines the scale factor
  4040. * @param result defines the matrix to store the result
  4041. * @returns the current matrix
  4042. */
  4043. scaleToRef(scale: number, result: Matrix): Matrix;
  4044. /**
  4045. * Scale the current matrix values by a factor and add the result to a given matrix
  4046. * @param scale defines the scale factor
  4047. * @param result defines the Matrix to store the result
  4048. * @returns the current matrix
  4049. */
  4050. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4051. /**
  4052. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4053. * @param ref matrix to store the result
  4054. */
  4055. toNormalMatrix(ref: Matrix): void;
  4056. /**
  4057. * Gets only rotation part of the current matrix
  4058. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4059. */
  4060. getRotationMatrix(): Matrix;
  4061. /**
  4062. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4063. * @param result defines the target matrix to store data to
  4064. * @returns the current matrix
  4065. */
  4066. getRotationMatrixToRef(result: Matrix): Matrix;
  4067. /**
  4068. * Toggles model matrix from being right handed to left handed in place and vice versa
  4069. */
  4070. toggleModelMatrixHandInPlace(): void;
  4071. /**
  4072. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4073. */
  4074. toggleProjectionMatrixHandInPlace(): void;
  4075. /**
  4076. * Creates a matrix from an array
  4077. * @param array defines the source array
  4078. * @param offset defines an offset in the source array
  4079. * @returns a new Matrix set from the starting index of the given array
  4080. */
  4081. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4082. /**
  4083. * Copy the content of an array into a given matrix
  4084. * @param array defines the source array
  4085. * @param offset defines an offset in the source array
  4086. * @param result defines the target matrix
  4087. */
  4088. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4089. /**
  4090. * Stores an array into a matrix after having multiplied each component by a given factor
  4091. * @param array defines the source array
  4092. * @param offset defines the offset in the source array
  4093. * @param scale defines the scaling factor
  4094. * @param result defines the target matrix
  4095. */
  4096. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4097. /**
  4098. * Gets an identity matrix that must not be updated
  4099. */
  4100. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4101. /**
  4102. * Stores a list of values (16) inside a given matrix
  4103. * @param initialM11 defines 1st value of 1st row
  4104. * @param initialM12 defines 2nd value of 1st row
  4105. * @param initialM13 defines 3rd value of 1st row
  4106. * @param initialM14 defines 4th value of 1st row
  4107. * @param initialM21 defines 1st value of 2nd row
  4108. * @param initialM22 defines 2nd value of 2nd row
  4109. * @param initialM23 defines 3rd value of 2nd row
  4110. * @param initialM24 defines 4th value of 2nd row
  4111. * @param initialM31 defines 1st value of 3rd row
  4112. * @param initialM32 defines 2nd value of 3rd row
  4113. * @param initialM33 defines 3rd value of 3rd row
  4114. * @param initialM34 defines 4th value of 3rd row
  4115. * @param initialM41 defines 1st value of 4th row
  4116. * @param initialM42 defines 2nd value of 4th row
  4117. * @param initialM43 defines 3rd value of 4th row
  4118. * @param initialM44 defines 4th value of 4th row
  4119. * @param result defines the target matrix
  4120. */
  4121. 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;
  4122. /**
  4123. * Creates new matrix from a list of values (16)
  4124. * @param initialM11 defines 1st value of 1st row
  4125. * @param initialM12 defines 2nd value of 1st row
  4126. * @param initialM13 defines 3rd value of 1st row
  4127. * @param initialM14 defines 4th value of 1st row
  4128. * @param initialM21 defines 1st value of 2nd row
  4129. * @param initialM22 defines 2nd value of 2nd row
  4130. * @param initialM23 defines 3rd value of 2nd row
  4131. * @param initialM24 defines 4th value of 2nd row
  4132. * @param initialM31 defines 1st value of 3rd row
  4133. * @param initialM32 defines 2nd value of 3rd row
  4134. * @param initialM33 defines 3rd value of 3rd row
  4135. * @param initialM34 defines 4th value of 3rd row
  4136. * @param initialM41 defines 1st value of 4th row
  4137. * @param initialM42 defines 2nd value of 4th row
  4138. * @param initialM43 defines 3rd value of 4th row
  4139. * @param initialM44 defines 4th value of 4th row
  4140. * @returns the new matrix
  4141. */
  4142. 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;
  4143. /**
  4144. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4145. * @param scale defines the scale vector3
  4146. * @param rotation defines the rotation quaternion
  4147. * @param translation defines the translation vector3
  4148. * @returns a new matrix
  4149. */
  4150. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4151. /**
  4152. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4153. * @param scale defines the scale vector3
  4154. * @param rotation defines the rotation quaternion
  4155. * @param translation defines the translation vector3
  4156. * @param result defines the target matrix
  4157. */
  4158. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4159. /**
  4160. * Creates a new identity matrix
  4161. * @returns a new identity matrix
  4162. */
  4163. static Identity(): Matrix;
  4164. /**
  4165. * Creates a new identity matrix and stores the result in a given matrix
  4166. * @param result defines the target matrix
  4167. */
  4168. static IdentityToRef(result: Matrix): void;
  4169. /**
  4170. * Creates a new zero matrix
  4171. * @returns a new zero matrix
  4172. */
  4173. static Zero(): Matrix;
  4174. /**
  4175. * Creates a new rotation matrix for "angle" radians around the X axis
  4176. * @param angle defines the angle (in radians) to use
  4177. * @return the new matrix
  4178. */
  4179. static RotationX(angle: number): Matrix;
  4180. /**
  4181. * Creates a new matrix as the invert of a given matrix
  4182. * @param source defines the source matrix
  4183. * @returns the new matrix
  4184. */
  4185. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4186. /**
  4187. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4188. * @param angle defines the angle (in radians) to use
  4189. * @param result defines the target matrix
  4190. */
  4191. static RotationXToRef(angle: number, result: Matrix): void;
  4192. /**
  4193. * Creates a new rotation matrix for "angle" radians around the Y axis
  4194. * @param angle defines the angle (in radians) to use
  4195. * @return the new matrix
  4196. */
  4197. static RotationY(angle: number): Matrix;
  4198. /**
  4199. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4200. * @param angle defines the angle (in radians) to use
  4201. * @param result defines the target matrix
  4202. */
  4203. static RotationYToRef(angle: number, result: Matrix): void;
  4204. /**
  4205. * Creates a new rotation matrix for "angle" radians around the Z axis
  4206. * @param angle defines the angle (in radians) to use
  4207. * @return the new matrix
  4208. */
  4209. static RotationZ(angle: number): Matrix;
  4210. /**
  4211. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4212. * @param angle defines the angle (in radians) to use
  4213. * @param result defines the target matrix
  4214. */
  4215. static RotationZToRef(angle: number, result: Matrix): void;
  4216. /**
  4217. * Creates a new rotation matrix for "angle" radians around the given axis
  4218. * @param axis defines the axis to use
  4219. * @param angle defines the angle (in radians) to use
  4220. * @return the new matrix
  4221. */
  4222. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4223. /**
  4224. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4225. * @param axis defines the axis to use
  4226. * @param angle defines the angle (in radians) to use
  4227. * @param result defines the target matrix
  4228. */
  4229. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4230. /**
  4231. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4232. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4233. * @param from defines the vector to align
  4234. * @param to defines the vector to align to
  4235. * @param result defines the target matrix
  4236. */
  4237. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4238. /**
  4239. * Creates a rotation matrix
  4240. * @param yaw defines the yaw angle in radians (Y axis)
  4241. * @param pitch defines the pitch angle in radians (X axis)
  4242. * @param roll defines the roll angle in radians (X axis)
  4243. * @returns the new rotation matrix
  4244. */
  4245. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4246. /**
  4247. * Creates a rotation matrix and stores it in a given matrix
  4248. * @param yaw defines the yaw angle in radians (Y axis)
  4249. * @param pitch defines the pitch angle in radians (X axis)
  4250. * @param roll defines the roll angle in radians (X axis)
  4251. * @param result defines the target matrix
  4252. */
  4253. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4254. /**
  4255. * Creates a scaling matrix
  4256. * @param x defines the scale factor on X axis
  4257. * @param y defines the scale factor on Y axis
  4258. * @param z defines the scale factor on Z axis
  4259. * @returns the new matrix
  4260. */
  4261. static Scaling(x: number, y: number, z: number): Matrix;
  4262. /**
  4263. * Creates a scaling matrix and stores it in a given matrix
  4264. * @param x defines the scale factor on X axis
  4265. * @param y defines the scale factor on Y axis
  4266. * @param z defines the scale factor on Z axis
  4267. * @param result defines the target matrix
  4268. */
  4269. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4270. /**
  4271. * Creates a translation matrix
  4272. * @param x defines the translation on X axis
  4273. * @param y defines the translation on Y axis
  4274. * @param z defines the translationon Z axis
  4275. * @returns the new matrix
  4276. */
  4277. static Translation(x: number, y: number, z: number): Matrix;
  4278. /**
  4279. * Creates a translation matrix and stores it in a given matrix
  4280. * @param x defines the translation on X axis
  4281. * @param y defines the translation on Y axis
  4282. * @param z defines the translationon Z axis
  4283. * @param result defines the target matrix
  4284. */
  4285. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4286. /**
  4287. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4288. * @param startValue defines the start value
  4289. * @param endValue defines the end value
  4290. * @param gradient defines the gradient factor
  4291. * @returns the new matrix
  4292. */
  4293. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4294. /**
  4295. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4296. * @param startValue defines the start value
  4297. * @param endValue defines the end value
  4298. * @param gradient defines the gradient factor
  4299. * @param result defines the Matrix object where to store data
  4300. */
  4301. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4302. /**
  4303. * Builds a new matrix whose values are computed by:
  4304. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4305. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4306. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4307. * @param startValue defines the first matrix
  4308. * @param endValue defines the second matrix
  4309. * @param gradient defines the gradient between the two matrices
  4310. * @returns the new matrix
  4311. */
  4312. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4313. /**
  4314. * Update a matrix to values which are computed by:
  4315. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4316. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4317. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4318. * @param startValue defines the first matrix
  4319. * @param endValue defines the second matrix
  4320. * @param gradient defines the gradient between the two matrices
  4321. * @param result defines the target matrix
  4322. */
  4323. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4324. /**
  4325. * 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"
  4326. * This function works in left handed mode
  4327. * @param eye defines the final position of the entity
  4328. * @param target defines where the entity should look at
  4329. * @param up defines the up vector for the entity
  4330. * @returns the new matrix
  4331. */
  4332. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4333. /**
  4334. * 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".
  4335. * This function works in left handed mode
  4336. * @param eye defines the final position of the entity
  4337. * @param target defines where the entity should look at
  4338. * @param up defines the up vector for the entity
  4339. * @param result defines the target matrix
  4340. */
  4341. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4342. /**
  4343. * 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"
  4344. * This function works in right handed mode
  4345. * @param eye defines the final position of the entity
  4346. * @param target defines where the entity should look at
  4347. * @param up defines the up vector for the entity
  4348. * @returns the new matrix
  4349. */
  4350. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4351. /**
  4352. * 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".
  4353. * This function works in right handed mode
  4354. * @param eye defines the final position of the entity
  4355. * @param target defines where the entity should look at
  4356. * @param up defines the up vector for the entity
  4357. * @param result defines the target matrix
  4358. */
  4359. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4360. /**
  4361. * Create a left-handed orthographic projection matrix
  4362. * @param width defines the viewport width
  4363. * @param height defines the viewport height
  4364. * @param znear defines the near clip plane
  4365. * @param zfar defines the far clip plane
  4366. * @returns a new matrix as a left-handed orthographic projection matrix
  4367. */
  4368. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4369. /**
  4370. * Store a left-handed orthographic projection to a given matrix
  4371. * @param width defines the viewport width
  4372. * @param height defines the viewport height
  4373. * @param znear defines the near clip plane
  4374. * @param zfar defines the far clip plane
  4375. * @param result defines the target matrix
  4376. */
  4377. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4378. /**
  4379. * Create a left-handed orthographic projection matrix
  4380. * @param left defines the viewport left coordinate
  4381. * @param right defines the viewport right coordinate
  4382. * @param bottom defines the viewport bottom coordinate
  4383. * @param top defines the viewport top coordinate
  4384. * @param znear defines the near clip plane
  4385. * @param zfar defines the far clip plane
  4386. * @returns a new matrix as a left-handed orthographic projection matrix
  4387. */
  4388. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4389. /**
  4390. * Stores a left-handed orthographic projection into a given matrix
  4391. * @param left defines the viewport left coordinate
  4392. * @param right defines the viewport right coordinate
  4393. * @param bottom defines the viewport bottom coordinate
  4394. * @param top defines the viewport top coordinate
  4395. * @param znear defines the near clip plane
  4396. * @param zfar defines the far clip plane
  4397. * @param result defines the target matrix
  4398. */
  4399. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4400. /**
  4401. * Creates a right-handed orthographic projection matrix
  4402. * @param left defines the viewport left coordinate
  4403. * @param right defines the viewport right coordinate
  4404. * @param bottom defines the viewport bottom coordinate
  4405. * @param top defines the viewport top coordinate
  4406. * @param znear defines the near clip plane
  4407. * @param zfar defines the far clip plane
  4408. * @returns a new matrix as a right-handed orthographic projection matrix
  4409. */
  4410. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4411. /**
  4412. * Stores a right-handed orthographic projection into a given matrix
  4413. * @param left defines the viewport left coordinate
  4414. * @param right defines the viewport right coordinate
  4415. * @param bottom defines the viewport bottom coordinate
  4416. * @param top defines the viewport top coordinate
  4417. * @param znear defines the near clip plane
  4418. * @param zfar defines the far clip plane
  4419. * @param result defines the target matrix
  4420. */
  4421. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4422. /**
  4423. * Creates a left-handed perspective projection matrix
  4424. * @param width defines the viewport width
  4425. * @param height defines the viewport height
  4426. * @param znear defines the near clip plane
  4427. * @param zfar defines the far clip plane
  4428. * @returns a new matrix as a left-handed perspective projection matrix
  4429. */
  4430. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4431. /**
  4432. * Creates a left-handed perspective projection matrix
  4433. * @param fov defines the horizontal field of view
  4434. * @param aspect defines the aspect ratio
  4435. * @param znear defines the near clip plane
  4436. * @param zfar defines the far clip plane
  4437. * @returns a new matrix as a left-handed perspective projection matrix
  4438. */
  4439. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4440. /**
  4441. * Stores a left-handed perspective projection into a given matrix
  4442. * @param fov defines the horizontal field of view
  4443. * @param aspect defines the aspect ratio
  4444. * @param znear defines the near clip plane
  4445. * @param zfar defines the far clip plane
  4446. * @param result defines the target matrix
  4447. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4448. */
  4449. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4450. /**
  4451. * Creates a right-handed perspective projection matrix
  4452. * @param fov defines the horizontal field of view
  4453. * @param aspect defines the aspect ratio
  4454. * @param znear defines the near clip plane
  4455. * @param zfar defines the far clip plane
  4456. * @returns a new matrix as a right-handed perspective projection matrix
  4457. */
  4458. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4459. /**
  4460. * Stores a right-handed perspective projection into a given matrix
  4461. * @param fov defines the horizontal field of view
  4462. * @param aspect defines the aspect ratio
  4463. * @param znear defines the near clip plane
  4464. * @param zfar defines the far clip plane
  4465. * @param result defines the target matrix
  4466. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4467. */
  4468. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4469. /**
  4470. * Stores a perspective projection for WebVR info a given matrix
  4471. * @param fov defines the field of view
  4472. * @param znear defines the near clip plane
  4473. * @param zfar defines the far clip plane
  4474. * @param result defines the target matrix
  4475. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4476. */
  4477. static PerspectiveFovWebVRToRef(fov: {
  4478. upDegrees: number;
  4479. downDegrees: number;
  4480. leftDegrees: number;
  4481. rightDegrees: number;
  4482. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4483. /**
  4484. * Computes a complete transformation matrix
  4485. * @param viewport defines the viewport to use
  4486. * @param world defines the world matrix
  4487. * @param view defines the view matrix
  4488. * @param projection defines the projection matrix
  4489. * @param zmin defines the near clip plane
  4490. * @param zmax defines the far clip plane
  4491. * @returns the transformation matrix
  4492. */
  4493. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4494. /**
  4495. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4496. * @param matrix defines the matrix to use
  4497. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4498. */
  4499. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4500. /**
  4501. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4502. * @param matrix defines the matrix to use
  4503. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4504. */
  4505. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4506. /**
  4507. * Compute the transpose of a given matrix
  4508. * @param matrix defines the matrix to transpose
  4509. * @returns the new matrix
  4510. */
  4511. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4512. /**
  4513. * Compute the transpose of a matrix and store it in a target matrix
  4514. * @param matrix defines the matrix to transpose
  4515. * @param result defines the target matrix
  4516. */
  4517. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4518. /**
  4519. * Computes a reflection matrix from a plane
  4520. * @param plane defines the reflection plane
  4521. * @returns a new matrix
  4522. */
  4523. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4524. /**
  4525. * Computes a reflection matrix from a plane
  4526. * @param plane defines the reflection plane
  4527. * @param result defines the target matrix
  4528. */
  4529. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4530. /**
  4531. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4532. * @param xaxis defines the value of the 1st axis
  4533. * @param yaxis defines the value of the 2nd axis
  4534. * @param zaxis defines the value of the 3rd axis
  4535. * @param result defines the target matrix
  4536. */
  4537. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4538. /**
  4539. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4540. * @param quat defines the quaternion to use
  4541. * @param result defines the target matrix
  4542. */
  4543. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4544. }
  4545. /**
  4546. * @hidden
  4547. */
  4548. export class TmpVectors {
  4549. static Vector2: Vector2[];
  4550. static Vector3: Vector3[];
  4551. static Vector4: Vector4[];
  4552. static Quaternion: Quaternion[];
  4553. static Matrix: Matrix[];
  4554. }
  4555. }
  4556. declare module BABYLON {
  4557. /**
  4558. * Defines potential orientation for back face culling
  4559. */
  4560. export enum Orientation {
  4561. /**
  4562. * Clockwise
  4563. */
  4564. CW = 0,
  4565. /** Counter clockwise */
  4566. CCW = 1
  4567. }
  4568. /** Class used to represent a Bezier curve */
  4569. export class BezierCurve {
  4570. /**
  4571. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4572. * @param t defines the time
  4573. * @param x1 defines the left coordinate on X axis
  4574. * @param y1 defines the left coordinate on Y axis
  4575. * @param x2 defines the right coordinate on X axis
  4576. * @param y2 defines the right coordinate on Y axis
  4577. * @returns the interpolated value
  4578. */
  4579. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4580. }
  4581. /**
  4582. * Defines angle representation
  4583. */
  4584. export class Angle {
  4585. private _radians;
  4586. /**
  4587. * Creates an Angle object of "radians" radians (float).
  4588. * @param radians the angle in radians
  4589. */
  4590. constructor(radians: number);
  4591. /**
  4592. * Get value in degrees
  4593. * @returns the Angle value in degrees (float)
  4594. */
  4595. degrees(): number;
  4596. /**
  4597. * Get value in radians
  4598. * @returns the Angle value in radians (float)
  4599. */
  4600. radians(): number;
  4601. /**
  4602. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4603. * @param a defines first vector
  4604. * @param b defines second vector
  4605. * @returns a new Angle
  4606. */
  4607. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4608. /**
  4609. * Gets a new Angle object from the given float in radians
  4610. * @param radians defines the angle value in radians
  4611. * @returns a new Angle
  4612. */
  4613. static FromRadians(radians: number): Angle;
  4614. /**
  4615. * Gets a new Angle object from the given float in degrees
  4616. * @param degrees defines the angle value in degrees
  4617. * @returns a new Angle
  4618. */
  4619. static FromDegrees(degrees: number): Angle;
  4620. }
  4621. /**
  4622. * This represents an arc in a 2d space.
  4623. */
  4624. export class Arc2 {
  4625. /** Defines the start point of the arc */
  4626. startPoint: Vector2;
  4627. /** Defines the mid point of the arc */
  4628. midPoint: Vector2;
  4629. /** Defines the end point of the arc */
  4630. endPoint: Vector2;
  4631. /**
  4632. * Defines the center point of the arc.
  4633. */
  4634. centerPoint: Vector2;
  4635. /**
  4636. * Defines the radius of the arc.
  4637. */
  4638. radius: number;
  4639. /**
  4640. * Defines the angle of the arc (from mid point to end point).
  4641. */
  4642. angle: Angle;
  4643. /**
  4644. * Defines the start angle of the arc (from start point to middle point).
  4645. */
  4646. startAngle: Angle;
  4647. /**
  4648. * Defines the orientation of the arc (clock wise/counter clock wise).
  4649. */
  4650. orientation: Orientation;
  4651. /**
  4652. * Creates an Arc object from the three given points : start, middle and end.
  4653. * @param startPoint Defines the start point of the arc
  4654. * @param midPoint Defines the midlle point of the arc
  4655. * @param endPoint Defines the end point of the arc
  4656. */
  4657. constructor(
  4658. /** Defines the start point of the arc */
  4659. startPoint: Vector2,
  4660. /** Defines the mid point of the arc */
  4661. midPoint: Vector2,
  4662. /** Defines the end point of the arc */
  4663. endPoint: Vector2);
  4664. }
  4665. /**
  4666. * Represents a 2D path made up of multiple 2D points
  4667. */
  4668. export class Path2 {
  4669. private _points;
  4670. private _length;
  4671. /**
  4672. * If the path start and end point are the same
  4673. */
  4674. closed: boolean;
  4675. /**
  4676. * Creates a Path2 object from the starting 2D coordinates x and y.
  4677. * @param x the starting points x value
  4678. * @param y the starting points y value
  4679. */
  4680. constructor(x: number, y: number);
  4681. /**
  4682. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4683. * @param x the added points x value
  4684. * @param y the added points y value
  4685. * @returns the updated Path2.
  4686. */
  4687. addLineTo(x: number, y: number): Path2;
  4688. /**
  4689. * 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.
  4690. * @param midX middle point x value
  4691. * @param midY middle point y value
  4692. * @param endX end point x value
  4693. * @param endY end point y value
  4694. * @param numberOfSegments (default: 36)
  4695. * @returns the updated Path2.
  4696. */
  4697. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4698. /**
  4699. * Closes the Path2.
  4700. * @returns the Path2.
  4701. */
  4702. close(): Path2;
  4703. /**
  4704. * Gets the sum of the distance between each sequential point in the path
  4705. * @returns the Path2 total length (float).
  4706. */
  4707. length(): number;
  4708. /**
  4709. * Gets the points which construct the path
  4710. * @returns the Path2 internal array of points.
  4711. */
  4712. getPoints(): Vector2[];
  4713. /**
  4714. * Retreives the point at the distance aways from the starting point
  4715. * @param normalizedLengthPosition the length along the path to retreive the point from
  4716. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4717. */
  4718. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4719. /**
  4720. * Creates a new path starting from an x and y position
  4721. * @param x starting x value
  4722. * @param y starting y value
  4723. * @returns a new Path2 starting at the coordinates (x, y).
  4724. */
  4725. static StartingAt(x: number, y: number): Path2;
  4726. }
  4727. /**
  4728. * Represents a 3D path made up of multiple 3D points
  4729. */
  4730. export class Path3D {
  4731. /**
  4732. * an array of Vector3, the curve axis of the Path3D
  4733. */
  4734. path: Vector3[];
  4735. private _curve;
  4736. private _distances;
  4737. private _tangents;
  4738. private _normals;
  4739. private _binormals;
  4740. private _raw;
  4741. /**
  4742. * new Path3D(path, normal, raw)
  4743. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4744. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4745. * @param path an array of Vector3, the curve axis of the Path3D
  4746. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4747. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4748. */
  4749. constructor(
  4750. /**
  4751. * an array of Vector3, the curve axis of the Path3D
  4752. */
  4753. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4754. /**
  4755. * Returns the Path3D array of successive Vector3 designing its curve.
  4756. * @returns the Path3D array of successive Vector3 designing its curve.
  4757. */
  4758. getCurve(): Vector3[];
  4759. /**
  4760. * Returns an array populated with tangent vectors on each Path3D curve point.
  4761. * @returns an array populated with tangent vectors on each Path3D curve point.
  4762. */
  4763. getTangents(): Vector3[];
  4764. /**
  4765. * Returns an array populated with normal vectors on each Path3D curve point.
  4766. * @returns an array populated with normal vectors on each Path3D curve point.
  4767. */
  4768. getNormals(): Vector3[];
  4769. /**
  4770. * Returns an array populated with binormal vectors on each Path3D curve point.
  4771. * @returns an array populated with binormal vectors on each Path3D curve point.
  4772. */
  4773. getBinormals(): Vector3[];
  4774. /**
  4775. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4776. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4777. */
  4778. getDistances(): number[];
  4779. /**
  4780. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4781. * @param path path which all values are copied into the curves points
  4782. * @param firstNormal which should be projected onto the curve
  4783. * @returns the same object updated.
  4784. */
  4785. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4786. private _compute;
  4787. private _getFirstNonNullVector;
  4788. private _getLastNonNullVector;
  4789. private _normalVector;
  4790. }
  4791. /**
  4792. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4793. * A Curve3 is designed from a series of successive Vector3.
  4794. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4795. */
  4796. export class Curve3 {
  4797. private _points;
  4798. private _length;
  4799. /**
  4800. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4801. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4802. * @param v1 (Vector3) the control point
  4803. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4804. * @param nbPoints (integer) the wanted number of points in the curve
  4805. * @returns the created Curve3
  4806. */
  4807. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4808. /**
  4809. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4810. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4811. * @param v1 (Vector3) the first control point
  4812. * @param v2 (Vector3) the second control point
  4813. * @param v3 (Vector3) the end point of the Cubic Bezier
  4814. * @param nbPoints (integer) the wanted number of points in the curve
  4815. * @returns the created Curve3
  4816. */
  4817. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4818. /**
  4819. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4820. * @param p1 (Vector3) the origin point of the Hermite Spline
  4821. * @param t1 (Vector3) the tangent vector at the origin point
  4822. * @param p2 (Vector3) the end point of the Hermite Spline
  4823. * @param t2 (Vector3) the tangent vector at the end point
  4824. * @param nbPoints (integer) the wanted number of points in the curve
  4825. * @returns the created Curve3
  4826. */
  4827. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4828. /**
  4829. * Returns a Curve3 object along a CatmullRom Spline curve :
  4830. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4831. * @param nbPoints (integer) the wanted number of points between each curve control points
  4832. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4833. * @returns the created Curve3
  4834. */
  4835. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4836. /**
  4837. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4838. * A Curve3 is designed from a series of successive Vector3.
  4839. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4840. * @param points points which make up the curve
  4841. */
  4842. constructor(points: Vector3[]);
  4843. /**
  4844. * @returns the Curve3 stored array of successive Vector3
  4845. */
  4846. getPoints(): Vector3[];
  4847. /**
  4848. * @returns the computed length (float) of the curve.
  4849. */
  4850. length(): number;
  4851. /**
  4852. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4853. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4854. * curveA and curveB keep unchanged.
  4855. * @param curve the curve to continue from this curve
  4856. * @returns the newly constructed curve
  4857. */
  4858. continue(curve: DeepImmutable<Curve3>): Curve3;
  4859. private _computeLength;
  4860. }
  4861. }
  4862. declare module BABYLON {
  4863. /**
  4864. * This represents the main contract an easing function should follow.
  4865. * Easing functions are used throughout the animation system.
  4866. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4867. */
  4868. export interface IEasingFunction {
  4869. /**
  4870. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4871. * of the easing function.
  4872. * The link below provides some of the most common examples of easing functions.
  4873. * @see https://easings.net/
  4874. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4875. * @returns the corresponding value on the curve defined by the easing function
  4876. */
  4877. ease(gradient: number): number;
  4878. }
  4879. /**
  4880. * Base class used for every default easing function.
  4881. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4882. */
  4883. export class EasingFunction implements IEasingFunction {
  4884. /**
  4885. * Interpolation follows the mathematical formula associated with the easing function.
  4886. */
  4887. static readonly EASINGMODE_EASEIN: number;
  4888. /**
  4889. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4890. */
  4891. static readonly EASINGMODE_EASEOUT: number;
  4892. /**
  4893. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4894. */
  4895. static readonly EASINGMODE_EASEINOUT: number;
  4896. private _easingMode;
  4897. /**
  4898. * Sets the easing mode of the current function.
  4899. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4900. */
  4901. setEasingMode(easingMode: number): void;
  4902. /**
  4903. * Gets the current easing mode.
  4904. * @returns the easing mode
  4905. */
  4906. getEasingMode(): number;
  4907. /**
  4908. * @hidden
  4909. */
  4910. easeInCore(gradient: number): number;
  4911. /**
  4912. * Given an input gradient between 0 and 1, this returns the corresponding value
  4913. * of the easing function.
  4914. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4915. * @returns the corresponding value on the curve defined by the easing function
  4916. */
  4917. ease(gradient: number): number;
  4918. }
  4919. /**
  4920. * Easing function with a circle shape (see link below).
  4921. * @see https://easings.net/#easeInCirc
  4922. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4923. */
  4924. export class CircleEase extends EasingFunction implements IEasingFunction {
  4925. /** @hidden */
  4926. easeInCore(gradient: number): number;
  4927. }
  4928. /**
  4929. * Easing function with a ease back shape (see link below).
  4930. * @see https://easings.net/#easeInBack
  4931. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4932. */
  4933. export class BackEase extends EasingFunction implements IEasingFunction {
  4934. /** Defines the amplitude of the function */
  4935. amplitude: number;
  4936. /**
  4937. * Instantiates a back ease easing
  4938. * @see https://easings.net/#easeInBack
  4939. * @param amplitude Defines the amplitude of the function
  4940. */
  4941. constructor(
  4942. /** Defines the amplitude of the function */
  4943. amplitude?: number);
  4944. /** @hidden */
  4945. easeInCore(gradient: number): number;
  4946. }
  4947. /**
  4948. * Easing function with a bouncing shape (see link below).
  4949. * @see https://easings.net/#easeInBounce
  4950. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4951. */
  4952. export class BounceEase extends EasingFunction implements IEasingFunction {
  4953. /** Defines the number of bounces */
  4954. bounces: number;
  4955. /** Defines the amplitude of the bounce */
  4956. bounciness: number;
  4957. /**
  4958. * Instantiates a bounce easing
  4959. * @see https://easings.net/#easeInBounce
  4960. * @param bounces Defines the number of bounces
  4961. * @param bounciness Defines the amplitude of the bounce
  4962. */
  4963. constructor(
  4964. /** Defines the number of bounces */
  4965. bounces?: number,
  4966. /** Defines the amplitude of the bounce */
  4967. bounciness?: number);
  4968. /** @hidden */
  4969. easeInCore(gradient: number): number;
  4970. }
  4971. /**
  4972. * Easing function with a power of 3 shape (see link below).
  4973. * @see https://easings.net/#easeInCubic
  4974. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4975. */
  4976. export class CubicEase extends EasingFunction implements IEasingFunction {
  4977. /** @hidden */
  4978. easeInCore(gradient: number): number;
  4979. }
  4980. /**
  4981. * Easing function with an elastic shape (see link below).
  4982. * @see https://easings.net/#easeInElastic
  4983. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4984. */
  4985. export class ElasticEase extends EasingFunction implements IEasingFunction {
  4986. /** Defines the number of oscillations*/
  4987. oscillations: number;
  4988. /** Defines the amplitude of the oscillations*/
  4989. springiness: number;
  4990. /**
  4991. * Instantiates an elastic easing function
  4992. * @see https://easings.net/#easeInElastic
  4993. * @param oscillations Defines the number of oscillations
  4994. * @param springiness Defines the amplitude of the oscillations
  4995. */
  4996. constructor(
  4997. /** Defines the number of oscillations*/
  4998. oscillations?: number,
  4999. /** Defines the amplitude of the oscillations*/
  5000. springiness?: number);
  5001. /** @hidden */
  5002. easeInCore(gradient: number): number;
  5003. }
  5004. /**
  5005. * Easing function with an exponential shape (see link below).
  5006. * @see https://easings.net/#easeInExpo
  5007. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5008. */
  5009. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5010. /** Defines the exponent of the function */
  5011. exponent: number;
  5012. /**
  5013. * Instantiates an exponential easing function
  5014. * @see https://easings.net/#easeInExpo
  5015. * @param exponent Defines the exponent of the function
  5016. */
  5017. constructor(
  5018. /** Defines the exponent of the function */
  5019. exponent?: number);
  5020. /** @hidden */
  5021. easeInCore(gradient: number): number;
  5022. }
  5023. /**
  5024. * Easing function with a power shape (see link below).
  5025. * @see https://easings.net/#easeInQuad
  5026. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5027. */
  5028. export class PowerEase extends EasingFunction implements IEasingFunction {
  5029. /** Defines the power of the function */
  5030. power: number;
  5031. /**
  5032. * Instantiates an power base easing function
  5033. * @see https://easings.net/#easeInQuad
  5034. * @param power Defines the power of the function
  5035. */
  5036. constructor(
  5037. /** Defines the power of the function */
  5038. power?: number);
  5039. /** @hidden */
  5040. easeInCore(gradient: number): number;
  5041. }
  5042. /**
  5043. * Easing function with a power of 2 shape (see link below).
  5044. * @see https://easings.net/#easeInQuad
  5045. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5046. */
  5047. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5048. /** @hidden */
  5049. easeInCore(gradient: number): number;
  5050. }
  5051. /**
  5052. * Easing function with a power of 4 shape (see link below).
  5053. * @see https://easings.net/#easeInQuart
  5054. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5055. */
  5056. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5057. /** @hidden */
  5058. easeInCore(gradient: number): number;
  5059. }
  5060. /**
  5061. * Easing function with a power of 5 shape (see link below).
  5062. * @see https://easings.net/#easeInQuint
  5063. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5064. */
  5065. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5066. /** @hidden */
  5067. easeInCore(gradient: number): number;
  5068. }
  5069. /**
  5070. * Easing function with a sin shape (see link below).
  5071. * @see https://easings.net/#easeInSine
  5072. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5073. */
  5074. export class SineEase extends EasingFunction implements IEasingFunction {
  5075. /** @hidden */
  5076. easeInCore(gradient: number): number;
  5077. }
  5078. /**
  5079. * Easing function with a bezier shape (see link below).
  5080. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5081. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5082. */
  5083. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5084. /** Defines the x component of the start tangent in the bezier curve */
  5085. x1: number;
  5086. /** Defines the y component of the start tangent in the bezier curve */
  5087. y1: number;
  5088. /** Defines the x component of the end tangent in the bezier curve */
  5089. x2: number;
  5090. /** Defines the y component of the end tangent in the bezier curve */
  5091. y2: number;
  5092. /**
  5093. * Instantiates a bezier function
  5094. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5095. * @param x1 Defines the x component of the start tangent in the bezier curve
  5096. * @param y1 Defines the y component of the start tangent in the bezier curve
  5097. * @param x2 Defines the x component of the end tangent in the bezier curve
  5098. * @param y2 Defines the y component of the end tangent in the bezier curve
  5099. */
  5100. constructor(
  5101. /** Defines the x component of the start tangent in the bezier curve */
  5102. x1?: number,
  5103. /** Defines the y component of the start tangent in the bezier curve */
  5104. y1?: number,
  5105. /** Defines the x component of the end tangent in the bezier curve */
  5106. x2?: number,
  5107. /** Defines the y component of the end tangent in the bezier curve */
  5108. y2?: number);
  5109. /** @hidden */
  5110. easeInCore(gradient: number): number;
  5111. }
  5112. }
  5113. declare module BABYLON {
  5114. /**
  5115. * Class used to hold a RBG color
  5116. */
  5117. export class Color3 {
  5118. /**
  5119. * Defines the red component (between 0 and 1, default is 0)
  5120. */
  5121. r: number;
  5122. /**
  5123. * Defines the green component (between 0 and 1, default is 0)
  5124. */
  5125. g: number;
  5126. /**
  5127. * Defines the blue component (between 0 and 1, default is 0)
  5128. */
  5129. b: number;
  5130. /**
  5131. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5132. * @param r defines the red component (between 0 and 1, default is 0)
  5133. * @param g defines the green component (between 0 and 1, default is 0)
  5134. * @param b defines the blue component (between 0 and 1, default is 0)
  5135. */
  5136. constructor(
  5137. /**
  5138. * Defines the red component (between 0 and 1, default is 0)
  5139. */
  5140. r?: number,
  5141. /**
  5142. * Defines the green component (between 0 and 1, default is 0)
  5143. */
  5144. g?: number,
  5145. /**
  5146. * Defines the blue component (between 0 and 1, default is 0)
  5147. */
  5148. b?: number);
  5149. /**
  5150. * Creates a string with the Color3 current values
  5151. * @returns the string representation of the Color3 object
  5152. */
  5153. toString(): string;
  5154. /**
  5155. * Returns the string "Color3"
  5156. * @returns "Color3"
  5157. */
  5158. getClassName(): string;
  5159. /**
  5160. * Compute the Color3 hash code
  5161. * @returns an unique number that can be used to hash Color3 objects
  5162. */
  5163. getHashCode(): number;
  5164. /**
  5165. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5166. * @param array defines the array where to store the r,g,b components
  5167. * @param index defines an optional index in the target array to define where to start storing values
  5168. * @returns the current Color3 object
  5169. */
  5170. toArray(array: FloatArray, index?: number): Color3;
  5171. /**
  5172. * Returns a new Color4 object from the current Color3 and the given alpha
  5173. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5174. * @returns a new Color4 object
  5175. */
  5176. toColor4(alpha?: number): Color4;
  5177. /**
  5178. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5179. * @returns the new array
  5180. */
  5181. asArray(): number[];
  5182. /**
  5183. * Returns the luminance value
  5184. * @returns a float value
  5185. */
  5186. toLuminance(): number;
  5187. /**
  5188. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5189. * @param otherColor defines the second operand
  5190. * @returns the new Color3 object
  5191. */
  5192. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5193. /**
  5194. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5195. * @param otherColor defines the second operand
  5196. * @param result defines the Color3 object where to store the result
  5197. * @returns the current Color3
  5198. */
  5199. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5200. /**
  5201. * Determines equality between Color3 objects
  5202. * @param otherColor defines the second operand
  5203. * @returns true if the rgb values are equal to the given ones
  5204. */
  5205. equals(otherColor: DeepImmutable<Color3>): boolean;
  5206. /**
  5207. * Determines equality between the current Color3 object and a set of r,b,g values
  5208. * @param r defines the red component to check
  5209. * @param g defines the green component to check
  5210. * @param b defines the blue component to check
  5211. * @returns true if the rgb values are equal to the given ones
  5212. */
  5213. equalsFloats(r: number, g: number, b: number): boolean;
  5214. /**
  5215. * Multiplies in place each rgb value by scale
  5216. * @param scale defines the scaling factor
  5217. * @returns the updated Color3
  5218. */
  5219. scale(scale: number): Color3;
  5220. /**
  5221. * Multiplies the rgb values by scale and stores the result into "result"
  5222. * @param scale defines the scaling factor
  5223. * @param result defines the Color3 object where to store the result
  5224. * @returns the unmodified current Color3
  5225. */
  5226. scaleToRef(scale: number, result: Color3): Color3;
  5227. /**
  5228. * Scale the current Color3 values by a factor and add the result to a given Color3
  5229. * @param scale defines the scale factor
  5230. * @param result defines color to store the result into
  5231. * @returns the unmodified current Color3
  5232. */
  5233. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5234. /**
  5235. * Clamps the rgb values by the min and max values and stores the result into "result"
  5236. * @param min defines minimum clamping value (default is 0)
  5237. * @param max defines maximum clamping value (default is 1)
  5238. * @param result defines color to store the result into
  5239. * @returns the original Color3
  5240. */
  5241. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5242. /**
  5243. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5244. * @param otherColor defines the second operand
  5245. * @returns the new Color3
  5246. */
  5247. add(otherColor: DeepImmutable<Color3>): Color3;
  5248. /**
  5249. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5250. * @param otherColor defines the second operand
  5251. * @param result defines Color3 object to store the result into
  5252. * @returns the unmodified current Color3
  5253. */
  5254. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5255. /**
  5256. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5257. * @param otherColor defines the second operand
  5258. * @returns the new Color3
  5259. */
  5260. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5261. /**
  5262. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5263. * @param otherColor defines the second operand
  5264. * @param result defines Color3 object to store the result into
  5265. * @returns the unmodified current Color3
  5266. */
  5267. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5268. /**
  5269. * Copy the current object
  5270. * @returns a new Color3 copied the current one
  5271. */
  5272. clone(): Color3;
  5273. /**
  5274. * Copies the rgb values from the source in the current Color3
  5275. * @param source defines the source Color3 object
  5276. * @returns the updated Color3 object
  5277. */
  5278. copyFrom(source: DeepImmutable<Color3>): Color3;
  5279. /**
  5280. * Updates the Color3 rgb values from the given floats
  5281. * @param r defines the red component to read from
  5282. * @param g defines the green component to read from
  5283. * @param b defines the blue component to read from
  5284. * @returns the current Color3 object
  5285. */
  5286. copyFromFloats(r: number, g: number, b: number): Color3;
  5287. /**
  5288. * Updates the Color3 rgb values from the given floats
  5289. * @param r defines the red component to read from
  5290. * @param g defines the green component to read from
  5291. * @param b defines the blue component to read from
  5292. * @returns the current Color3 object
  5293. */
  5294. set(r: number, g: number, b: number): Color3;
  5295. /**
  5296. * Compute the Color3 hexadecimal code as a string
  5297. * @returns a string containing the hexadecimal representation of the Color3 object
  5298. */
  5299. toHexString(): string;
  5300. /**
  5301. * Computes a new Color3 converted from the current one to linear space
  5302. * @returns a new Color3 object
  5303. */
  5304. toLinearSpace(): Color3;
  5305. /**
  5306. * Converts current color in rgb space to HSV values
  5307. * @returns a new color3 representing the HSV values
  5308. */
  5309. toHSV(): Color3;
  5310. /**
  5311. * Converts current color in rgb space to HSV values
  5312. * @param result defines the Color3 where to store the HSV values
  5313. */
  5314. toHSVToRef(result: Color3): void;
  5315. /**
  5316. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5317. * @param convertedColor defines the Color3 object where to store the linear space version
  5318. * @returns the unmodified Color3
  5319. */
  5320. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5321. /**
  5322. * Computes a new Color3 converted from the current one to gamma space
  5323. * @returns a new Color3 object
  5324. */
  5325. toGammaSpace(): Color3;
  5326. /**
  5327. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5328. * @param convertedColor defines the Color3 object where to store the gamma space version
  5329. * @returns the unmodified Color3
  5330. */
  5331. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5332. private static _BlackReadOnly;
  5333. /**
  5334. * Convert Hue, saturation and value to a Color3 (RGB)
  5335. * @param hue defines the hue
  5336. * @param saturation defines the saturation
  5337. * @param value defines the value
  5338. * @param result defines the Color3 where to store the RGB values
  5339. */
  5340. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5341. /**
  5342. * Creates a new Color3 from the string containing valid hexadecimal values
  5343. * @param hex defines a string containing valid hexadecimal values
  5344. * @returns a new Color3 object
  5345. */
  5346. static FromHexString(hex: string): Color3;
  5347. /**
  5348. * Creates a new Color3 from the starting index of the given array
  5349. * @param array defines the source array
  5350. * @param offset defines an offset in the source array
  5351. * @returns a new Color3 object
  5352. */
  5353. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5354. /**
  5355. * Creates a new Color3 from integer values (< 256)
  5356. * @param r defines the red component to read from (value between 0 and 255)
  5357. * @param g defines the green component to read from (value between 0 and 255)
  5358. * @param b defines the blue component to read from (value between 0 and 255)
  5359. * @returns a new Color3 object
  5360. */
  5361. static FromInts(r: number, g: number, b: number): Color3;
  5362. /**
  5363. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5364. * @param start defines the start Color3 value
  5365. * @param end defines the end Color3 value
  5366. * @param amount defines the gradient value between start and end
  5367. * @returns a new Color3 object
  5368. */
  5369. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5370. /**
  5371. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5372. * @param left defines the start value
  5373. * @param right defines the end value
  5374. * @param amount defines the gradient factor
  5375. * @param result defines the Color3 object where to store the result
  5376. */
  5377. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5378. /**
  5379. * Returns a Color3 value containing a red color
  5380. * @returns a new Color3 object
  5381. */
  5382. static Red(): Color3;
  5383. /**
  5384. * Returns a Color3 value containing a green color
  5385. * @returns a new Color3 object
  5386. */
  5387. static Green(): Color3;
  5388. /**
  5389. * Returns a Color3 value containing a blue color
  5390. * @returns a new Color3 object
  5391. */
  5392. static Blue(): Color3;
  5393. /**
  5394. * Returns a Color3 value containing a black color
  5395. * @returns a new Color3 object
  5396. */
  5397. static Black(): Color3;
  5398. /**
  5399. * Gets a Color3 value containing a black color that must not be updated
  5400. */
  5401. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5402. /**
  5403. * Returns a Color3 value containing a white color
  5404. * @returns a new Color3 object
  5405. */
  5406. static White(): Color3;
  5407. /**
  5408. * Returns a Color3 value containing a purple color
  5409. * @returns a new Color3 object
  5410. */
  5411. static Purple(): Color3;
  5412. /**
  5413. * Returns a Color3 value containing a magenta color
  5414. * @returns a new Color3 object
  5415. */
  5416. static Magenta(): Color3;
  5417. /**
  5418. * Returns a Color3 value containing a yellow color
  5419. * @returns a new Color3 object
  5420. */
  5421. static Yellow(): Color3;
  5422. /**
  5423. * Returns a Color3 value containing a gray color
  5424. * @returns a new Color3 object
  5425. */
  5426. static Gray(): Color3;
  5427. /**
  5428. * Returns a Color3 value containing a teal color
  5429. * @returns a new Color3 object
  5430. */
  5431. static Teal(): Color3;
  5432. /**
  5433. * Returns a Color3 value containing a random color
  5434. * @returns a new Color3 object
  5435. */
  5436. static Random(): Color3;
  5437. }
  5438. /**
  5439. * Class used to hold a RBGA color
  5440. */
  5441. export class Color4 {
  5442. /**
  5443. * Defines the red component (between 0 and 1, default is 0)
  5444. */
  5445. r: number;
  5446. /**
  5447. * Defines the green component (between 0 and 1, default is 0)
  5448. */
  5449. g: number;
  5450. /**
  5451. * Defines the blue component (between 0 and 1, default is 0)
  5452. */
  5453. b: number;
  5454. /**
  5455. * Defines the alpha component (between 0 and 1, default is 1)
  5456. */
  5457. a: number;
  5458. /**
  5459. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5460. * @param r defines the red component (between 0 and 1, default is 0)
  5461. * @param g defines the green component (between 0 and 1, default is 0)
  5462. * @param b defines the blue component (between 0 and 1, default is 0)
  5463. * @param a defines the alpha component (between 0 and 1, default is 1)
  5464. */
  5465. constructor(
  5466. /**
  5467. * Defines the red component (between 0 and 1, default is 0)
  5468. */
  5469. r?: number,
  5470. /**
  5471. * Defines the green component (between 0 and 1, default is 0)
  5472. */
  5473. g?: number,
  5474. /**
  5475. * Defines the blue component (between 0 and 1, default is 0)
  5476. */
  5477. b?: number,
  5478. /**
  5479. * Defines the alpha component (between 0 and 1, default is 1)
  5480. */
  5481. a?: number);
  5482. /**
  5483. * Adds in place the given Color4 values to the current Color4 object
  5484. * @param right defines the second operand
  5485. * @returns the current updated Color4 object
  5486. */
  5487. addInPlace(right: DeepImmutable<Color4>): Color4;
  5488. /**
  5489. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5490. * @returns the new array
  5491. */
  5492. asArray(): number[];
  5493. /**
  5494. * Stores from the starting index in the given array the Color4 successive values
  5495. * @param array defines the array where to store the r,g,b components
  5496. * @param index defines an optional index in the target array to define where to start storing values
  5497. * @returns the current Color4 object
  5498. */
  5499. toArray(array: number[], index?: number): Color4;
  5500. /**
  5501. * Determines equality between Color4 objects
  5502. * @param otherColor defines the second operand
  5503. * @returns true if the rgba values are equal to the given ones
  5504. */
  5505. equals(otherColor: DeepImmutable<Color4>): boolean;
  5506. /**
  5507. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5508. * @param right defines the second operand
  5509. * @returns a new Color4 object
  5510. */
  5511. add(right: DeepImmutable<Color4>): Color4;
  5512. /**
  5513. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5514. * @param right defines the second operand
  5515. * @returns a new Color4 object
  5516. */
  5517. subtract(right: DeepImmutable<Color4>): Color4;
  5518. /**
  5519. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5520. * @param right defines the second operand
  5521. * @param result defines the Color4 object where to store the result
  5522. * @returns the current Color4 object
  5523. */
  5524. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5525. /**
  5526. * Creates a new Color4 with the current Color4 values multiplied by scale
  5527. * @param scale defines the scaling factor to apply
  5528. * @returns a new Color4 object
  5529. */
  5530. scale(scale: number): Color4;
  5531. /**
  5532. * Multiplies the current Color4 values by scale and stores the result in "result"
  5533. * @param scale defines the scaling factor to apply
  5534. * @param result defines the Color4 object where to store the result
  5535. * @returns the current unmodified Color4
  5536. */
  5537. scaleToRef(scale: number, result: Color4): Color4;
  5538. /**
  5539. * Scale the current Color4 values by a factor and add the result to a given Color4
  5540. * @param scale defines the scale factor
  5541. * @param result defines the Color4 object where to store the result
  5542. * @returns the unmodified current Color4
  5543. */
  5544. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5545. /**
  5546. * Clamps the rgb values by the min and max values and stores the result into "result"
  5547. * @param min defines minimum clamping value (default is 0)
  5548. * @param max defines maximum clamping value (default is 1)
  5549. * @param result defines color to store the result into.
  5550. * @returns the cuurent Color4
  5551. */
  5552. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5553. /**
  5554. * Multipy an Color4 value by another and return a new Color4 object
  5555. * @param color defines the Color4 value to multiply by
  5556. * @returns a new Color4 object
  5557. */
  5558. multiply(color: Color4): Color4;
  5559. /**
  5560. * Multipy a Color4 value by another and push the result in a reference value
  5561. * @param color defines the Color4 value to multiply by
  5562. * @param result defines the Color4 to fill the result in
  5563. * @returns the result Color4
  5564. */
  5565. multiplyToRef(color: Color4, result: Color4): Color4;
  5566. /**
  5567. * Creates a string with the Color4 current values
  5568. * @returns the string representation of the Color4 object
  5569. */
  5570. toString(): string;
  5571. /**
  5572. * Returns the string "Color4"
  5573. * @returns "Color4"
  5574. */
  5575. getClassName(): string;
  5576. /**
  5577. * Compute the Color4 hash code
  5578. * @returns an unique number that can be used to hash Color4 objects
  5579. */
  5580. getHashCode(): number;
  5581. /**
  5582. * Creates a new Color4 copied from the current one
  5583. * @returns a new Color4 object
  5584. */
  5585. clone(): Color4;
  5586. /**
  5587. * Copies the given Color4 values into the current one
  5588. * @param source defines the source Color4 object
  5589. * @returns the current updated Color4 object
  5590. */
  5591. copyFrom(source: Color4): Color4;
  5592. /**
  5593. * Copies the given float values into the current one
  5594. * @param r defines the red component to read from
  5595. * @param g defines the green component to read from
  5596. * @param b defines the blue component to read from
  5597. * @param a defines the alpha component to read from
  5598. * @returns the current updated Color4 object
  5599. */
  5600. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5601. /**
  5602. * Copies the given float values into the current one
  5603. * @param r defines the red component to read from
  5604. * @param g defines the green component to read from
  5605. * @param b defines the blue component to read from
  5606. * @param a defines the alpha component to read from
  5607. * @returns the current updated Color4 object
  5608. */
  5609. set(r: number, g: number, b: number, a: number): Color4;
  5610. /**
  5611. * Compute the Color4 hexadecimal code as a string
  5612. * @returns a string containing the hexadecimal representation of the Color4 object
  5613. */
  5614. toHexString(): string;
  5615. /**
  5616. * Computes a new Color4 converted from the current one to linear space
  5617. * @returns a new Color4 object
  5618. */
  5619. toLinearSpace(): Color4;
  5620. /**
  5621. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5622. * @param convertedColor defines the Color4 object where to store the linear space version
  5623. * @returns the unmodified Color4
  5624. */
  5625. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5626. /**
  5627. * Computes a new Color4 converted from the current one to gamma space
  5628. * @returns a new Color4 object
  5629. */
  5630. toGammaSpace(): Color4;
  5631. /**
  5632. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5633. * @param convertedColor defines the Color4 object where to store the gamma space version
  5634. * @returns the unmodified Color4
  5635. */
  5636. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5637. /**
  5638. * Creates a new Color4 from the string containing valid hexadecimal values
  5639. * @param hex defines a string containing valid hexadecimal values
  5640. * @returns a new Color4 object
  5641. */
  5642. static FromHexString(hex: string): Color4;
  5643. /**
  5644. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5645. * @param left defines the start value
  5646. * @param right defines the end value
  5647. * @param amount defines the gradient factor
  5648. * @returns a new Color4 object
  5649. */
  5650. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5651. /**
  5652. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5653. * @param left defines the start value
  5654. * @param right defines the end value
  5655. * @param amount defines the gradient factor
  5656. * @param result defines the Color4 object where to store data
  5657. */
  5658. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5659. /**
  5660. * Creates a new Color4 from a Color3 and an alpha value
  5661. * @param color3 defines the source Color3 to read from
  5662. * @param alpha defines the alpha component (1.0 by default)
  5663. * @returns a new Color4 object
  5664. */
  5665. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5666. /**
  5667. * Creates a new Color4 from the starting index element of the given array
  5668. * @param array defines the source array to read from
  5669. * @param offset defines the offset in the source array
  5670. * @returns a new Color4 object
  5671. */
  5672. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5673. /**
  5674. * Creates a new Color3 from integer values (< 256)
  5675. * @param r defines the red component to read from (value between 0 and 255)
  5676. * @param g defines the green component to read from (value between 0 and 255)
  5677. * @param b defines the blue component to read from (value between 0 and 255)
  5678. * @param a defines the alpha component to read from (value between 0 and 255)
  5679. * @returns a new Color3 object
  5680. */
  5681. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5682. /**
  5683. * Check the content of a given array and convert it to an array containing RGBA data
  5684. * If the original array was already containing count * 4 values then it is returned directly
  5685. * @param colors defines the array to check
  5686. * @param count defines the number of RGBA data to expect
  5687. * @returns an array containing count * 4 values (RGBA)
  5688. */
  5689. static CheckColors4(colors: number[], count: number): number[];
  5690. }
  5691. /**
  5692. * @hidden
  5693. */
  5694. export class TmpColors {
  5695. static Color3: Color3[];
  5696. static Color4: Color4[];
  5697. }
  5698. }
  5699. declare module BABYLON {
  5700. /**
  5701. * Defines an interface which represents an animation key frame
  5702. */
  5703. export interface IAnimationKey {
  5704. /**
  5705. * Frame of the key frame
  5706. */
  5707. frame: number;
  5708. /**
  5709. * Value at the specifies key frame
  5710. */
  5711. value: any;
  5712. /**
  5713. * The input tangent for the cubic hermite spline
  5714. */
  5715. inTangent?: any;
  5716. /**
  5717. * The output tangent for the cubic hermite spline
  5718. */
  5719. outTangent?: any;
  5720. /**
  5721. * The animation interpolation type
  5722. */
  5723. interpolation?: AnimationKeyInterpolation;
  5724. }
  5725. /**
  5726. * Enum for the animation key frame interpolation type
  5727. */
  5728. export enum AnimationKeyInterpolation {
  5729. /**
  5730. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5731. */
  5732. STEP = 1
  5733. }
  5734. }
  5735. declare module BABYLON {
  5736. /**
  5737. * Represents the range of an animation
  5738. */
  5739. export class AnimationRange {
  5740. /**The name of the animation range**/
  5741. name: string;
  5742. /**The starting frame of the animation */
  5743. from: number;
  5744. /**The ending frame of the animation*/
  5745. to: number;
  5746. /**
  5747. * Initializes the range of an animation
  5748. * @param name The name of the animation range
  5749. * @param from The starting frame of the animation
  5750. * @param to The ending frame of the animation
  5751. */
  5752. constructor(
  5753. /**The name of the animation range**/
  5754. name: string,
  5755. /**The starting frame of the animation */
  5756. from: number,
  5757. /**The ending frame of the animation*/
  5758. to: number);
  5759. /**
  5760. * Makes a copy of the animation range
  5761. * @returns A copy of the animation range
  5762. */
  5763. clone(): AnimationRange;
  5764. }
  5765. }
  5766. declare module BABYLON {
  5767. /**
  5768. * Composed of a frame, and an action function
  5769. */
  5770. export class AnimationEvent {
  5771. /** The frame for which the event is triggered **/
  5772. frame: number;
  5773. /** The event to perform when triggered **/
  5774. action: (currentFrame: number) => void;
  5775. /** Specifies if the event should be triggered only once**/
  5776. onlyOnce?: boolean | undefined;
  5777. /**
  5778. * Specifies if the animation event is done
  5779. */
  5780. isDone: boolean;
  5781. /**
  5782. * Initializes the animation event
  5783. * @param frame The frame for which the event is triggered
  5784. * @param action The event to perform when triggered
  5785. * @param onlyOnce Specifies if the event should be triggered only once
  5786. */
  5787. constructor(
  5788. /** The frame for which the event is triggered **/
  5789. frame: number,
  5790. /** The event to perform when triggered **/
  5791. action: (currentFrame: number) => void,
  5792. /** Specifies if the event should be triggered only once**/
  5793. onlyOnce?: boolean | undefined);
  5794. /** @hidden */ private _clone(): AnimationEvent;
  5795. }
  5796. }
  5797. declare module BABYLON {
  5798. /**
  5799. * Interface used to define a behavior
  5800. */
  5801. export interface Behavior<T> {
  5802. /** gets or sets behavior's name */
  5803. name: string;
  5804. /**
  5805. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5806. */
  5807. init(): void;
  5808. /**
  5809. * Called when the behavior is attached to a target
  5810. * @param target defines the target where the behavior is attached to
  5811. */
  5812. attach(target: T): void;
  5813. /**
  5814. * Called when the behavior is detached from its target
  5815. */
  5816. detach(): void;
  5817. }
  5818. /**
  5819. * Interface implemented by classes supporting behaviors
  5820. */
  5821. export interface IBehaviorAware<T> {
  5822. /**
  5823. * Attach a behavior
  5824. * @param behavior defines the behavior to attach
  5825. * @returns the current host
  5826. */
  5827. addBehavior(behavior: Behavior<T>): T;
  5828. /**
  5829. * Remove a behavior from the current object
  5830. * @param behavior defines the behavior to detach
  5831. * @returns the current host
  5832. */
  5833. removeBehavior(behavior: Behavior<T>): T;
  5834. /**
  5835. * Gets a behavior using its name to search
  5836. * @param name defines the name to search
  5837. * @returns the behavior or null if not found
  5838. */
  5839. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5840. }
  5841. }
  5842. declare module BABYLON {
  5843. /**
  5844. * Defines an array and its length.
  5845. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5846. */
  5847. export interface ISmartArrayLike<T> {
  5848. /**
  5849. * The data of the array.
  5850. */
  5851. data: Array<T>;
  5852. /**
  5853. * The active length of the array.
  5854. */
  5855. length: number;
  5856. }
  5857. /**
  5858. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5859. */
  5860. export class SmartArray<T> implements ISmartArrayLike<T> {
  5861. /**
  5862. * The full set of data from the array.
  5863. */
  5864. data: Array<T>;
  5865. /**
  5866. * The active length of the array.
  5867. */
  5868. length: number;
  5869. protected _id: number;
  5870. /**
  5871. * Instantiates a Smart Array.
  5872. * @param capacity defines the default capacity of the array.
  5873. */
  5874. constructor(capacity: number);
  5875. /**
  5876. * Pushes a value at the end of the active data.
  5877. * @param value defines the object to push in the array.
  5878. */
  5879. push(value: T): void;
  5880. /**
  5881. * Iterates over the active data and apply the lambda to them.
  5882. * @param func defines the action to apply on each value.
  5883. */
  5884. forEach(func: (content: T) => void): void;
  5885. /**
  5886. * Sorts the full sets of data.
  5887. * @param compareFn defines the comparison function to apply.
  5888. */
  5889. sort(compareFn: (a: T, b: T) => number): void;
  5890. /**
  5891. * Resets the active data to an empty array.
  5892. */
  5893. reset(): void;
  5894. /**
  5895. * Releases all the data from the array as well as the array.
  5896. */
  5897. dispose(): void;
  5898. /**
  5899. * Concats the active data with a given array.
  5900. * @param array defines the data to concatenate with.
  5901. */
  5902. concat(array: any): void;
  5903. /**
  5904. * Returns the position of a value in the active data.
  5905. * @param value defines the value to find the index for
  5906. * @returns the index if found in the active data otherwise -1
  5907. */
  5908. indexOf(value: T): number;
  5909. /**
  5910. * Returns whether an element is part of the active data.
  5911. * @param value defines the value to look for
  5912. * @returns true if found in the active data otherwise false
  5913. */
  5914. contains(value: T): boolean;
  5915. private static _GlobalId;
  5916. }
  5917. /**
  5918. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5919. * The data in this array can only be present once
  5920. */
  5921. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  5922. private _duplicateId;
  5923. /**
  5924. * Pushes a value at the end of the active data.
  5925. * THIS DOES NOT PREVENT DUPPLICATE DATA
  5926. * @param value defines the object to push in the array.
  5927. */
  5928. push(value: T): void;
  5929. /**
  5930. * Pushes a value at the end of the active data.
  5931. * If the data is already present, it won t be added again
  5932. * @param value defines the object to push in the array.
  5933. * @returns true if added false if it was already present
  5934. */
  5935. pushNoDuplicate(value: T): boolean;
  5936. /**
  5937. * Resets the active data to an empty array.
  5938. */
  5939. reset(): void;
  5940. /**
  5941. * Concats the active data with a given array.
  5942. * This ensures no dupplicate will be present in the result.
  5943. * @param array defines the data to concatenate with.
  5944. */
  5945. concatWithNoDuplicate(array: any): void;
  5946. }
  5947. }
  5948. declare module BABYLON {
  5949. /**
  5950. * @ignore
  5951. * This is a list of all the different input types that are available in the application.
  5952. * Fo instance: ArcRotateCameraGamepadInput...
  5953. */
  5954. export var CameraInputTypes: {};
  5955. /**
  5956. * This is the contract to implement in order to create a new input class.
  5957. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  5958. */
  5959. export interface ICameraInput<TCamera extends Camera> {
  5960. /**
  5961. * Defines the camera the input is attached to.
  5962. */
  5963. camera: Nullable<TCamera>;
  5964. /**
  5965. * Gets the class name of the current intput.
  5966. * @returns the class name
  5967. */
  5968. getClassName(): string;
  5969. /**
  5970. * Get the friendly name associated with the input class.
  5971. * @returns the input friendly name
  5972. */
  5973. getSimpleName(): string;
  5974. /**
  5975. * Attach the input controls to a specific dom element to get the input from.
  5976. * @param element Defines the element the controls should be listened from
  5977. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  5978. */
  5979. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5980. /**
  5981. * Detach the current controls from the specified dom element.
  5982. * @param element Defines the element to stop listening the inputs from
  5983. */
  5984. detachControl(element: Nullable<HTMLElement>): void;
  5985. /**
  5986. * Update the current camera state depending on the inputs that have been used this frame.
  5987. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  5988. */
  5989. checkInputs?: () => void;
  5990. }
  5991. /**
  5992. * Represents a map of input types to input instance or input index to input instance.
  5993. */
  5994. export interface CameraInputsMap<TCamera extends Camera> {
  5995. /**
  5996. * Accessor to the input by input type.
  5997. */
  5998. [name: string]: ICameraInput<TCamera>;
  5999. /**
  6000. * Accessor to the input by input index.
  6001. */
  6002. [idx: number]: ICameraInput<TCamera>;
  6003. }
  6004. /**
  6005. * This represents the input manager used within a camera.
  6006. * It helps dealing with all the different kind of input attached to a camera.
  6007. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6008. */
  6009. export class CameraInputsManager<TCamera extends Camera> {
  6010. /**
  6011. * Defines the list of inputs attahed to the camera.
  6012. */
  6013. attached: CameraInputsMap<TCamera>;
  6014. /**
  6015. * Defines the dom element the camera is collecting inputs from.
  6016. * This is null if the controls have not been attached.
  6017. */
  6018. attachedElement: Nullable<HTMLElement>;
  6019. /**
  6020. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6021. */
  6022. noPreventDefault: boolean;
  6023. /**
  6024. * Defined the camera the input manager belongs to.
  6025. */
  6026. camera: TCamera;
  6027. /**
  6028. * Update the current camera state depending on the inputs that have been used this frame.
  6029. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6030. */
  6031. checkInputs: () => void;
  6032. /**
  6033. * Instantiate a new Camera Input Manager.
  6034. * @param camera Defines the camera the input manager blongs to
  6035. */
  6036. constructor(camera: TCamera);
  6037. /**
  6038. * Add an input method to a camera
  6039. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6040. * @param input camera input method
  6041. */
  6042. add(input: ICameraInput<TCamera>): void;
  6043. /**
  6044. * Remove a specific input method from a camera
  6045. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6046. * @param inputToRemove camera input method
  6047. */
  6048. remove(inputToRemove: ICameraInput<TCamera>): void;
  6049. /**
  6050. * Remove a specific input type from a camera
  6051. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6052. * @param inputType the type of the input to remove
  6053. */
  6054. removeByType(inputType: string): void;
  6055. private _addCheckInputs;
  6056. /**
  6057. * Attach the input controls to the currently attached dom element to listen the events from.
  6058. * @param input Defines the input to attach
  6059. */
  6060. attachInput(input: ICameraInput<TCamera>): void;
  6061. /**
  6062. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6063. * @param element Defines the dom element to collect the events from
  6064. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6065. */
  6066. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6067. /**
  6068. * Detach the current manager inputs controls from a specific dom element.
  6069. * @param element Defines the dom element to collect the events from
  6070. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6071. */
  6072. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6073. /**
  6074. * Rebuild the dynamic inputCheck function from the current list of
  6075. * defined inputs in the manager.
  6076. */
  6077. rebuildInputCheck(): void;
  6078. /**
  6079. * Remove all attached input methods from a camera
  6080. */
  6081. clear(): void;
  6082. /**
  6083. * Serialize the current input manager attached to a camera.
  6084. * This ensures than once parsed,
  6085. * the input associated to the camera will be identical to the current ones
  6086. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6087. */
  6088. serialize(serializedCamera: any): void;
  6089. /**
  6090. * Parses an input manager serialized JSON to restore the previous list of inputs
  6091. * and states associated to a camera.
  6092. * @param parsedCamera Defines the JSON to parse
  6093. */
  6094. parse(parsedCamera: any): void;
  6095. }
  6096. }
  6097. declare module BABYLON {
  6098. /**
  6099. * Class used to store data that will be store in GPU memory
  6100. */
  6101. export class Buffer {
  6102. private _engine;
  6103. private _buffer;
  6104. /** @hidden */ private _data: Nullable<DataArray>;
  6105. private _updatable;
  6106. private _instanced;
  6107. private _divisor;
  6108. /**
  6109. * Gets the byte stride.
  6110. */
  6111. readonly byteStride: number;
  6112. /**
  6113. * Constructor
  6114. * @param engine the engine
  6115. * @param data the data to use for this buffer
  6116. * @param updatable whether the data is updatable
  6117. * @param stride the stride (optional)
  6118. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6119. * @param instanced whether the buffer is instanced (optional)
  6120. * @param useBytes set to true if the stride in in bytes (optional)
  6121. * @param divisor sets an optional divisor for instances (1 by default)
  6122. */
  6123. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6124. /**
  6125. * Create a new VertexBuffer based on the current buffer
  6126. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6127. * @param offset defines offset in the buffer (0 by default)
  6128. * @param size defines the size in floats of attributes (position is 3 for instance)
  6129. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6130. * @param instanced defines if the vertex buffer contains indexed data
  6131. * @param useBytes defines if the offset and stride are in bytes *
  6132. * @param divisor sets an optional divisor for instances (1 by default)
  6133. * @returns the new vertex buffer
  6134. */
  6135. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6136. /**
  6137. * Gets a boolean indicating if the Buffer is updatable?
  6138. * @returns true if the buffer is updatable
  6139. */
  6140. isUpdatable(): boolean;
  6141. /**
  6142. * Gets current buffer's data
  6143. * @returns a DataArray or null
  6144. */
  6145. getData(): Nullable<DataArray>;
  6146. /**
  6147. * Gets underlying native buffer
  6148. * @returns underlying native buffer
  6149. */
  6150. getBuffer(): Nullable<DataBuffer>;
  6151. /**
  6152. * Gets the stride in float32 units (i.e. byte stride / 4).
  6153. * May not be an integer if the byte stride is not divisible by 4.
  6154. * DEPRECATED. Use byteStride instead.
  6155. * @returns the stride in float32 units
  6156. */
  6157. getStrideSize(): number;
  6158. /**
  6159. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6160. * @param data defines the data to store
  6161. */
  6162. create(data?: Nullable<DataArray>): void;
  6163. /** @hidden */ private _rebuild(): void;
  6164. /**
  6165. * Update current buffer data
  6166. * @param data defines the data to store
  6167. */
  6168. update(data: DataArray): void;
  6169. /**
  6170. * Updates the data directly.
  6171. * @param data the new data
  6172. * @param offset the new offset
  6173. * @param vertexCount the vertex count (optional)
  6174. * @param useBytes set to true if the offset is in bytes
  6175. */
  6176. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6177. /**
  6178. * Release all resources
  6179. */
  6180. dispose(): void;
  6181. }
  6182. /**
  6183. * Specialized buffer used to store vertex data
  6184. */
  6185. export class VertexBuffer {
  6186. /** @hidden */ private _buffer: Buffer;
  6187. private _kind;
  6188. private _size;
  6189. private _ownsBuffer;
  6190. private _instanced;
  6191. private _instanceDivisor;
  6192. /**
  6193. * The byte type.
  6194. */
  6195. static readonly BYTE: number;
  6196. /**
  6197. * The unsigned byte type.
  6198. */
  6199. static readonly UNSIGNED_BYTE: number;
  6200. /**
  6201. * The short type.
  6202. */
  6203. static readonly SHORT: number;
  6204. /**
  6205. * The unsigned short type.
  6206. */
  6207. static readonly UNSIGNED_SHORT: number;
  6208. /**
  6209. * The integer type.
  6210. */
  6211. static readonly INT: number;
  6212. /**
  6213. * The unsigned integer type.
  6214. */
  6215. static readonly UNSIGNED_INT: number;
  6216. /**
  6217. * The float type.
  6218. */
  6219. static readonly FLOAT: number;
  6220. /**
  6221. * Gets or sets the instance divisor when in instanced mode
  6222. */
  6223. instanceDivisor: number;
  6224. /**
  6225. * Gets the byte stride.
  6226. */
  6227. readonly byteStride: number;
  6228. /**
  6229. * Gets the byte offset.
  6230. */
  6231. readonly byteOffset: number;
  6232. /**
  6233. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6234. */
  6235. readonly normalized: boolean;
  6236. /**
  6237. * Gets the data type of each component in the array.
  6238. */
  6239. readonly type: number;
  6240. /**
  6241. * Constructor
  6242. * @param engine the engine
  6243. * @param data the data to use for this vertex buffer
  6244. * @param kind the vertex buffer kind
  6245. * @param updatable whether the data is updatable
  6246. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6247. * @param stride the stride (optional)
  6248. * @param instanced whether the buffer is instanced (optional)
  6249. * @param offset the offset of the data (optional)
  6250. * @param size the number of components (optional)
  6251. * @param type the type of the component (optional)
  6252. * @param normalized whether the data contains normalized data (optional)
  6253. * @param useBytes set to true if stride and offset are in bytes (optional)
  6254. * @param divisor defines the instance divisor to use (1 by default)
  6255. */
  6256. 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, divisor?: number);
  6257. /** @hidden */ private _rebuild(): void;
  6258. /**
  6259. * Returns the kind of the VertexBuffer (string)
  6260. * @returns a string
  6261. */
  6262. getKind(): string;
  6263. /**
  6264. * Gets a boolean indicating if the VertexBuffer is updatable?
  6265. * @returns true if the buffer is updatable
  6266. */
  6267. isUpdatable(): boolean;
  6268. /**
  6269. * Gets current buffer's data
  6270. * @returns a DataArray or null
  6271. */
  6272. getData(): Nullable<DataArray>;
  6273. /**
  6274. * Gets underlying native buffer
  6275. * @returns underlying native buffer
  6276. */
  6277. getBuffer(): Nullable<DataBuffer>;
  6278. /**
  6279. * Gets the stride in float32 units (i.e. byte stride / 4).
  6280. * May not be an integer if the byte stride is not divisible by 4.
  6281. * DEPRECATED. Use byteStride instead.
  6282. * @returns the stride in float32 units
  6283. */
  6284. getStrideSize(): number;
  6285. /**
  6286. * Returns the offset as a multiple of the type byte length.
  6287. * DEPRECATED. Use byteOffset instead.
  6288. * @returns the offset in bytes
  6289. */
  6290. getOffset(): number;
  6291. /**
  6292. * Returns the number of components per vertex attribute (integer)
  6293. * @returns the size in float
  6294. */
  6295. getSize(): number;
  6296. /**
  6297. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6298. * @returns true if this buffer is instanced
  6299. */
  6300. getIsInstanced(): boolean;
  6301. /**
  6302. * Returns the instancing divisor, zero for non-instanced (integer).
  6303. * @returns a number
  6304. */
  6305. getInstanceDivisor(): number;
  6306. /**
  6307. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6308. * @param data defines the data to store
  6309. */
  6310. create(data?: DataArray): void;
  6311. /**
  6312. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6313. * This function will create a new buffer if the current one is not updatable
  6314. * @param data defines the data to store
  6315. */
  6316. update(data: DataArray): void;
  6317. /**
  6318. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6319. * Returns the directly updated WebGLBuffer.
  6320. * @param data the new data
  6321. * @param offset the new offset
  6322. * @param useBytes set to true if the offset is in bytes
  6323. */
  6324. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6325. /**
  6326. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6327. */
  6328. dispose(): void;
  6329. /**
  6330. * Enumerates each value of this vertex buffer as numbers.
  6331. * @param count the number of values to enumerate
  6332. * @param callback the callback function called for each value
  6333. */
  6334. forEach(count: number, callback: (value: number, index: number) => void): void;
  6335. /**
  6336. * Positions
  6337. */
  6338. static readonly PositionKind: string;
  6339. /**
  6340. * Normals
  6341. */
  6342. static readonly NormalKind: string;
  6343. /**
  6344. * Tangents
  6345. */
  6346. static readonly TangentKind: string;
  6347. /**
  6348. * Texture coordinates
  6349. */
  6350. static readonly UVKind: string;
  6351. /**
  6352. * Texture coordinates 2
  6353. */
  6354. static readonly UV2Kind: string;
  6355. /**
  6356. * Texture coordinates 3
  6357. */
  6358. static readonly UV3Kind: string;
  6359. /**
  6360. * Texture coordinates 4
  6361. */
  6362. static readonly UV4Kind: string;
  6363. /**
  6364. * Texture coordinates 5
  6365. */
  6366. static readonly UV5Kind: string;
  6367. /**
  6368. * Texture coordinates 6
  6369. */
  6370. static readonly UV6Kind: string;
  6371. /**
  6372. * Colors
  6373. */
  6374. static readonly ColorKind: string;
  6375. /**
  6376. * Matrix indices (for bones)
  6377. */
  6378. static readonly MatricesIndicesKind: string;
  6379. /**
  6380. * Matrix weights (for bones)
  6381. */
  6382. static readonly MatricesWeightsKind: string;
  6383. /**
  6384. * Additional matrix indices (for bones)
  6385. */
  6386. static readonly MatricesIndicesExtraKind: string;
  6387. /**
  6388. * Additional matrix weights (for bones)
  6389. */
  6390. static readonly MatricesWeightsExtraKind: string;
  6391. /**
  6392. * Deduces the stride given a kind.
  6393. * @param kind The kind string to deduce
  6394. * @returns The deduced stride
  6395. */
  6396. static DeduceStride(kind: string): number;
  6397. /**
  6398. * Gets the byte length of the given type.
  6399. * @param type the type
  6400. * @returns the number of bytes
  6401. */
  6402. static GetTypeByteLength(type: number): number;
  6403. /**
  6404. * Enumerates each value of the given parameters as numbers.
  6405. * @param data the data to enumerate
  6406. * @param byteOffset the byte offset of the data
  6407. * @param byteStride the byte stride of the data
  6408. * @param componentCount the number of components per element
  6409. * @param componentType the type of the component
  6410. * @param count the number of values to enumerate
  6411. * @param normalized whether the data is normalized
  6412. * @param callback the callback function called for each value
  6413. */
  6414. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6415. private static _GetFloatValue;
  6416. }
  6417. }
  6418. declare module BABYLON {
  6419. /**
  6420. * @hidden
  6421. */
  6422. export class IntersectionInfo {
  6423. bu: Nullable<number>;
  6424. bv: Nullable<number>;
  6425. distance: number;
  6426. faceId: number;
  6427. subMeshId: number;
  6428. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6429. }
  6430. }
  6431. declare module BABYLON {
  6432. /**
  6433. * Represens a plane by the equation ax + by + cz + d = 0
  6434. */
  6435. export class Plane {
  6436. private static _TmpMatrix;
  6437. /**
  6438. * Normal of the plane (a,b,c)
  6439. */
  6440. normal: Vector3;
  6441. /**
  6442. * d component of the plane
  6443. */
  6444. d: number;
  6445. /**
  6446. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6447. * @param a a component of the plane
  6448. * @param b b component of the plane
  6449. * @param c c component of the plane
  6450. * @param d d component of the plane
  6451. */
  6452. constructor(a: number, b: number, c: number, d: number);
  6453. /**
  6454. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6455. */
  6456. asArray(): number[];
  6457. /**
  6458. * @returns a new plane copied from the current Plane.
  6459. */
  6460. clone(): Plane;
  6461. /**
  6462. * @returns the string "Plane".
  6463. */
  6464. getClassName(): string;
  6465. /**
  6466. * @returns the Plane hash code.
  6467. */
  6468. getHashCode(): number;
  6469. /**
  6470. * Normalize the current Plane in place.
  6471. * @returns the updated Plane.
  6472. */
  6473. normalize(): Plane;
  6474. /**
  6475. * Applies a transformation the plane and returns the result
  6476. * @param transformation the transformation matrix to be applied to the plane
  6477. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6478. */
  6479. transform(transformation: DeepImmutable<Matrix>): Plane;
  6480. /**
  6481. * Calcualtte the dot product between the point and the plane normal
  6482. * @param point point to calculate the dot product with
  6483. * @returns the dot product (float) of the point coordinates and the plane normal.
  6484. */
  6485. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6486. /**
  6487. * Updates the current Plane from the plane defined by the three given points.
  6488. * @param point1 one of the points used to contruct the plane
  6489. * @param point2 one of the points used to contruct the plane
  6490. * @param point3 one of the points used to contruct the plane
  6491. * @returns the updated Plane.
  6492. */
  6493. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6494. /**
  6495. * Checks if the plane is facing a given direction
  6496. * @param direction the direction to check if the plane is facing
  6497. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6498. * @returns True is the vector "direction" is the same side than the plane normal.
  6499. */
  6500. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6501. /**
  6502. * Calculates the distance to a point
  6503. * @param point point to calculate distance to
  6504. * @returns the signed distance (float) from the given point to the Plane.
  6505. */
  6506. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6507. /**
  6508. * Creates a plane from an array
  6509. * @param array the array to create a plane from
  6510. * @returns a new Plane from the given array.
  6511. */
  6512. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6513. /**
  6514. * Creates a plane from three points
  6515. * @param point1 point used to create the plane
  6516. * @param point2 point used to create the plane
  6517. * @param point3 point used to create the plane
  6518. * @returns a new Plane defined by the three given points.
  6519. */
  6520. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6521. /**
  6522. * Creates a plane from an origin point and a normal
  6523. * @param origin origin of the plane to be constructed
  6524. * @param normal normal of the plane to be constructed
  6525. * @returns a new Plane the normal vector to this plane at the given origin point.
  6526. * Note : the vector "normal" is updated because normalized.
  6527. */
  6528. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6529. /**
  6530. * Calculates the distance from a plane and a point
  6531. * @param origin origin of the plane to be constructed
  6532. * @param normal normal of the plane to be constructed
  6533. * @param point point to calculate distance to
  6534. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6535. */
  6536. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6537. }
  6538. }
  6539. declare module BABYLON {
  6540. /**
  6541. * Class used to store bounding sphere information
  6542. */
  6543. export class BoundingSphere {
  6544. /**
  6545. * Gets the center of the bounding sphere in local space
  6546. */
  6547. readonly center: Vector3;
  6548. /**
  6549. * Radius of the bounding sphere in local space
  6550. */
  6551. radius: number;
  6552. /**
  6553. * Gets the center of the bounding sphere in world space
  6554. */
  6555. readonly centerWorld: Vector3;
  6556. /**
  6557. * Radius of the bounding sphere in world space
  6558. */
  6559. radiusWorld: number;
  6560. /**
  6561. * Gets the minimum vector in local space
  6562. */
  6563. readonly minimum: Vector3;
  6564. /**
  6565. * Gets the maximum vector in local space
  6566. */
  6567. readonly maximum: Vector3;
  6568. private _worldMatrix;
  6569. private static readonly TmpVector3;
  6570. /**
  6571. * Creates a new bounding sphere
  6572. * @param min defines the minimum vector (in local space)
  6573. * @param max defines the maximum vector (in local space)
  6574. * @param worldMatrix defines the new world matrix
  6575. */
  6576. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6577. /**
  6578. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6579. * @param min defines the new minimum vector (in local space)
  6580. * @param max defines the new maximum vector (in local space)
  6581. * @param worldMatrix defines the new world matrix
  6582. */
  6583. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6584. /**
  6585. * Scale the current bounding sphere by applying a scale factor
  6586. * @param factor defines the scale factor to apply
  6587. * @returns the current bounding box
  6588. */
  6589. scale(factor: number): BoundingSphere;
  6590. /**
  6591. * Gets the world matrix of the bounding box
  6592. * @returns a matrix
  6593. */
  6594. getWorldMatrix(): DeepImmutable<Matrix>;
  6595. /** @hidden */ private _update(worldMatrix: DeepImmutable<Matrix>): void;
  6596. /**
  6597. * Tests if the bounding sphere is intersecting the frustum planes
  6598. * @param frustumPlanes defines the frustum planes to test
  6599. * @returns true if there is an intersection
  6600. */
  6601. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6602. /**
  6603. * Tests if the bounding sphere center is in between the frustum planes.
  6604. * Used for optimistic fast inclusion.
  6605. * @param frustumPlanes defines the frustum planes to test
  6606. * @returns true if the sphere center is in between the frustum planes
  6607. */
  6608. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6609. /**
  6610. * Tests if a point is inside the bounding sphere
  6611. * @param point defines the point to test
  6612. * @returns true if the point is inside the bounding sphere
  6613. */
  6614. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6615. /**
  6616. * Checks if two sphere intersct
  6617. * @param sphere0 sphere 0
  6618. * @param sphere1 sphere 1
  6619. * @returns true if the speres intersect
  6620. */
  6621. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6622. }
  6623. }
  6624. declare module BABYLON {
  6625. /**
  6626. * Class used to store bounding box information
  6627. */
  6628. export class BoundingBox implements ICullable {
  6629. /**
  6630. * Gets the 8 vectors representing the bounding box in local space
  6631. */
  6632. readonly vectors: Vector3[];
  6633. /**
  6634. * Gets the center of the bounding box in local space
  6635. */
  6636. readonly center: Vector3;
  6637. /**
  6638. * Gets the center of the bounding box in world space
  6639. */
  6640. readonly centerWorld: Vector3;
  6641. /**
  6642. * Gets the extend size in local space
  6643. */
  6644. readonly extendSize: Vector3;
  6645. /**
  6646. * Gets the extend size in world space
  6647. */
  6648. readonly extendSizeWorld: Vector3;
  6649. /**
  6650. * Gets the OBB (object bounding box) directions
  6651. */
  6652. readonly directions: Vector3[];
  6653. /**
  6654. * Gets the 8 vectors representing the bounding box in world space
  6655. */
  6656. readonly vectorsWorld: Vector3[];
  6657. /**
  6658. * Gets the minimum vector in world space
  6659. */
  6660. readonly minimumWorld: Vector3;
  6661. /**
  6662. * Gets the maximum vector in world space
  6663. */
  6664. readonly maximumWorld: Vector3;
  6665. /**
  6666. * Gets the minimum vector in local space
  6667. */
  6668. readonly minimum: Vector3;
  6669. /**
  6670. * Gets the maximum vector in local space
  6671. */
  6672. readonly maximum: Vector3;
  6673. private _worldMatrix;
  6674. private static readonly TmpVector3;
  6675. /**
  6676. * @hidden
  6677. */ private _tag: number;
  6678. /**
  6679. * Creates a new bounding box
  6680. * @param min defines the minimum vector (in local space)
  6681. * @param max defines the maximum vector (in local space)
  6682. * @param worldMatrix defines the new world matrix
  6683. */
  6684. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6685. /**
  6686. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6687. * @param min defines the new minimum vector (in local space)
  6688. * @param max defines the new maximum vector (in local space)
  6689. * @param worldMatrix defines the new world matrix
  6690. */
  6691. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6692. /**
  6693. * Scale the current bounding box by applying a scale factor
  6694. * @param factor defines the scale factor to apply
  6695. * @returns the current bounding box
  6696. */
  6697. scale(factor: number): BoundingBox;
  6698. /**
  6699. * Gets the world matrix of the bounding box
  6700. * @returns a matrix
  6701. */
  6702. getWorldMatrix(): DeepImmutable<Matrix>;
  6703. /** @hidden */ private _update(world: DeepImmutable<Matrix>): void;
  6704. /**
  6705. * Tests if the bounding box is intersecting the frustum planes
  6706. * @param frustumPlanes defines the frustum planes to test
  6707. * @returns true if there is an intersection
  6708. */
  6709. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6710. /**
  6711. * Tests if the bounding box is entirely inside the frustum planes
  6712. * @param frustumPlanes defines the frustum planes to test
  6713. * @returns true if there is an inclusion
  6714. */
  6715. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6716. /**
  6717. * Tests if a point is inside the bounding box
  6718. * @param point defines the point to test
  6719. * @returns true if the point is inside the bounding box
  6720. */
  6721. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6722. /**
  6723. * Tests if the bounding box intersects with a bounding sphere
  6724. * @param sphere defines the sphere to test
  6725. * @returns true if there is an intersection
  6726. */
  6727. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6728. /**
  6729. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6730. * @param min defines the min vector to use
  6731. * @param max defines the max vector to use
  6732. * @returns true if there is an intersection
  6733. */
  6734. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6735. /**
  6736. * Tests if two bounding boxes are intersections
  6737. * @param box0 defines the first box to test
  6738. * @param box1 defines the second box to test
  6739. * @returns true if there is an intersection
  6740. */
  6741. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6742. /**
  6743. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6744. * @param minPoint defines the minimum vector of the bounding box
  6745. * @param maxPoint defines the maximum vector of the bounding box
  6746. * @param sphereCenter defines the sphere center
  6747. * @param sphereRadius defines the sphere radius
  6748. * @returns true if there is an intersection
  6749. */
  6750. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6751. /**
  6752. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6753. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6754. * @param frustumPlanes defines the frustum planes to test
  6755. * @return true if there is an inclusion
  6756. */
  6757. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6758. /**
  6759. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6760. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6761. * @param frustumPlanes defines the frustum planes to test
  6762. * @return true if there is an intersection
  6763. */
  6764. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6765. }
  6766. }
  6767. declare module BABYLON {
  6768. /** @hidden */
  6769. export class Collider {
  6770. /** Define if a collision was found */
  6771. collisionFound: boolean;
  6772. /**
  6773. * Define last intersection point in local space
  6774. */
  6775. intersectionPoint: Vector3;
  6776. /**
  6777. * Define last collided mesh
  6778. */
  6779. collidedMesh: Nullable<AbstractMesh>;
  6780. private _collisionPoint;
  6781. private _planeIntersectionPoint;
  6782. private _tempVector;
  6783. private _tempVector2;
  6784. private _tempVector3;
  6785. private _tempVector4;
  6786. private _edge;
  6787. private _baseToVertex;
  6788. private _destinationPoint;
  6789. private _slidePlaneNormal;
  6790. private _displacementVector;
  6791. /** @hidden */ private _radius: Vector3;
  6792. /** @hidden */ private _retry: number;
  6793. private _velocity;
  6794. private _basePoint;
  6795. private _epsilon;
  6796. /** @hidden */ private _velocityWorldLength: number;
  6797. /** @hidden */ private _basePointWorld: Vector3;
  6798. private _velocityWorld;
  6799. private _normalizedVelocity;
  6800. /** @hidden */ private _initialVelocity: Vector3;
  6801. /** @hidden */ private _initialPosition: Vector3;
  6802. private _nearestDistance;
  6803. private _collisionMask;
  6804. collisionMask: number;
  6805. /**
  6806. * Gets the plane normal used to compute the sliding response (in local space)
  6807. */
  6808. readonly slidePlaneNormal: Vector3;
  6809. /** @hidden */ private _initialize(source: Vector3, dir: Vector3, e: number): void;
  6810. /** @hidden */ private _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6811. /** @hidden */ private _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6812. /** @hidden */ private _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6813. /** @hidden */ private _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6814. /** @hidden */ private _getResponse(pos: Vector3, vel: Vector3): void;
  6815. }
  6816. }
  6817. declare module BABYLON {
  6818. /**
  6819. * Interface for cullable objects
  6820. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6821. */
  6822. export interface ICullable {
  6823. /**
  6824. * Checks if the object or part of the object is in the frustum
  6825. * @param frustumPlanes Camera near/planes
  6826. * @returns true if the object is in frustum otherwise false
  6827. */
  6828. isInFrustum(frustumPlanes: Plane[]): boolean;
  6829. /**
  6830. * Checks if a cullable object (mesh...) is in the camera frustum
  6831. * Unlike isInFrustum this cheks the full bounding box
  6832. * @param frustumPlanes Camera near/planes
  6833. * @returns true if the object is in frustum otherwise false
  6834. */
  6835. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6836. }
  6837. /**
  6838. * Info for a bounding data of a mesh
  6839. */
  6840. export class BoundingInfo implements ICullable {
  6841. /**
  6842. * Bounding box for the mesh
  6843. */
  6844. readonly boundingBox: BoundingBox;
  6845. /**
  6846. * Bounding sphere for the mesh
  6847. */
  6848. readonly boundingSphere: BoundingSphere;
  6849. private _isLocked;
  6850. private static readonly TmpVector3;
  6851. /**
  6852. * Constructs bounding info
  6853. * @param minimum min vector of the bounding box/sphere
  6854. * @param maximum max vector of the bounding box/sphere
  6855. * @param worldMatrix defines the new world matrix
  6856. */
  6857. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6858. /**
  6859. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6860. * @param min defines the new minimum vector (in local space)
  6861. * @param max defines the new maximum vector (in local space)
  6862. * @param worldMatrix defines the new world matrix
  6863. */
  6864. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6865. /**
  6866. * min vector of the bounding box/sphere
  6867. */
  6868. readonly minimum: Vector3;
  6869. /**
  6870. * max vector of the bounding box/sphere
  6871. */
  6872. readonly maximum: Vector3;
  6873. /**
  6874. * If the info is locked and won't be updated to avoid perf overhead
  6875. */
  6876. isLocked: boolean;
  6877. /**
  6878. * Updates the bounding sphere and box
  6879. * @param world world matrix to be used to update
  6880. */
  6881. update(world: DeepImmutable<Matrix>): void;
  6882. /**
  6883. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6884. * @param center New center of the bounding info
  6885. * @param extend New extend of the bounding info
  6886. * @returns the current bounding info
  6887. */
  6888. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  6889. /**
  6890. * Scale the current bounding info by applying a scale factor
  6891. * @param factor defines the scale factor to apply
  6892. * @returns the current bounding info
  6893. */
  6894. scale(factor: number): BoundingInfo;
  6895. /**
  6896. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  6897. * @param frustumPlanes defines the frustum to test
  6898. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  6899. * @returns true if the bounding info is in the frustum planes
  6900. */
  6901. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  6902. /**
  6903. * Gets the world distance between the min and max points of the bounding box
  6904. */
  6905. readonly diagonalLength: number;
  6906. /**
  6907. * Checks if a cullable object (mesh...) is in the camera frustum
  6908. * Unlike isInFrustum this cheks the full bounding box
  6909. * @param frustumPlanes Camera near/planes
  6910. * @returns true if the object is in frustum otherwise false
  6911. */
  6912. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6913. /** @hidden */ private _checkCollision(collider: Collider): boolean;
  6914. /**
  6915. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  6916. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  6917. * @param point the point to check intersection with
  6918. * @returns if the point intersects
  6919. */
  6920. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6921. /**
  6922. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  6923. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  6924. * @param boundingInfo the bounding info to check intersection with
  6925. * @param precise if the intersection should be done using OBB
  6926. * @returns if the bounding info intersects
  6927. */
  6928. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  6929. }
  6930. }
  6931. declare module BABYLON {
  6932. /**
  6933. * Extracts minimum and maximum values from a list of indexed positions
  6934. * @param positions defines the positions to use
  6935. * @param indices defines the indices to the positions
  6936. * @param indexStart defines the start index
  6937. * @param indexCount defines the end index
  6938. * @param bias defines bias value to add to the result
  6939. * @return minimum and maximum values
  6940. */
  6941. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  6942. minimum: Vector3;
  6943. maximum: Vector3;
  6944. };
  6945. /**
  6946. * Extracts minimum and maximum values from a list of positions
  6947. * @param positions defines the positions to use
  6948. * @param start defines the start index in the positions array
  6949. * @param count defines the number of positions to handle
  6950. * @param bias defines bias value to add to the result
  6951. * @param stride defines the stride size to use (distance between two positions in the positions array)
  6952. * @return minimum and maximum values
  6953. */
  6954. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  6955. minimum: Vector3;
  6956. maximum: Vector3;
  6957. };
  6958. }
  6959. declare module BABYLON {
  6960. /** @hidden */
  6961. export class WebGLDataBuffer extends DataBuffer {
  6962. private _buffer;
  6963. constructor(resource: WebGLBuffer);
  6964. readonly underlyingResource: any;
  6965. }
  6966. }
  6967. declare module BABYLON {
  6968. /** @hidden */
  6969. export class WebGLPipelineContext implements IPipelineContext {
  6970. engine: ThinEngine;
  6971. program: Nullable<WebGLProgram>;
  6972. context?: WebGLRenderingContext;
  6973. vertexShader?: WebGLShader;
  6974. fragmentShader?: WebGLShader;
  6975. isParallelCompiled: boolean;
  6976. onCompiled?: () => void;
  6977. transformFeedback?: WebGLTransformFeedback | null;
  6978. readonly isAsync: boolean;
  6979. readonly isReady: boolean; private _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  6980. }
  6981. }
  6982. declare module BABYLON {
  6983. interface ThinEngine {
  6984. /**
  6985. * Create an uniform buffer
  6986. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6987. * @param elements defines the content of the uniform buffer
  6988. * @returns the webGL uniform buffer
  6989. */
  6990. createUniformBuffer(elements: FloatArray): DataBuffer;
  6991. /**
  6992. * Create a dynamic uniform buffer
  6993. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6994. * @param elements defines the content of the uniform buffer
  6995. * @returns the webGL uniform buffer
  6996. */
  6997. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  6998. /**
  6999. * Update an existing uniform buffer
  7000. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7001. * @param uniformBuffer defines the target uniform buffer
  7002. * @param elements defines the content to update
  7003. * @param offset defines the offset in the uniform buffer where update should start
  7004. * @param count defines the size of the data to update
  7005. */
  7006. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7007. /**
  7008. * Bind an uniform buffer to the current webGL context
  7009. * @param buffer defines the buffer to bind
  7010. */
  7011. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7012. /**
  7013. * Bind a buffer to the current webGL context at a given location
  7014. * @param buffer defines the buffer to bind
  7015. * @param location defines the index where to bind the buffer
  7016. */
  7017. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7018. /**
  7019. * Bind a specific block at a given index in a specific shader program
  7020. * @param pipelineContext defines the pipeline context to use
  7021. * @param blockName defines the block name
  7022. * @param index defines the index where to bind the block
  7023. */
  7024. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7025. }
  7026. }
  7027. declare module BABYLON {
  7028. /**
  7029. * Uniform buffer objects.
  7030. *
  7031. * Handles blocks of uniform on the GPU.
  7032. *
  7033. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7034. *
  7035. * For more information, please refer to :
  7036. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7037. */
  7038. export class UniformBuffer {
  7039. private _engine;
  7040. private _buffer;
  7041. private _data;
  7042. private _bufferData;
  7043. private _dynamic?;
  7044. private _uniformLocations;
  7045. private _uniformSizes;
  7046. private _uniformLocationPointer;
  7047. private _needSync;
  7048. private _noUBO;
  7049. private _currentEffect;
  7050. /** @hidden */ private _alreadyBound: boolean;
  7051. private static _MAX_UNIFORM_SIZE;
  7052. private static _tempBuffer;
  7053. /**
  7054. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7055. * This is dynamic to allow compat with webgl 1 and 2.
  7056. * You will need to pass the name of the uniform as well as the value.
  7057. */
  7058. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7059. /**
  7060. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7061. * This is dynamic to allow compat with webgl 1 and 2.
  7062. * You will need to pass the name of the uniform as well as the value.
  7063. */
  7064. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7065. /**
  7066. * Lambda to Update a single float in a uniform buffer.
  7067. * This is dynamic to allow compat with webgl 1 and 2.
  7068. * You will need to pass the name of the uniform as well as the value.
  7069. */
  7070. updateFloat: (name: string, x: number) => void;
  7071. /**
  7072. * Lambda to Update a vec2 of float in a uniform buffer.
  7073. * This is dynamic to allow compat with webgl 1 and 2.
  7074. * You will need to pass the name of the uniform as well as the value.
  7075. */
  7076. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7077. /**
  7078. * Lambda to Update a vec3 of float in a uniform buffer.
  7079. * This is dynamic to allow compat with webgl 1 and 2.
  7080. * You will need to pass the name of the uniform as well as the value.
  7081. */
  7082. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7083. /**
  7084. * Lambda to Update a vec4 of float in a uniform buffer.
  7085. * This is dynamic to allow compat with webgl 1 and 2.
  7086. * You will need to pass the name of the uniform as well as the value.
  7087. */
  7088. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7089. /**
  7090. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7091. * This is dynamic to allow compat with webgl 1 and 2.
  7092. * You will need to pass the name of the uniform as well as the value.
  7093. */
  7094. updateMatrix: (name: string, mat: Matrix) => void;
  7095. /**
  7096. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7097. * This is dynamic to allow compat with webgl 1 and 2.
  7098. * You will need to pass the name of the uniform as well as the value.
  7099. */
  7100. updateVector3: (name: string, vector: Vector3) => void;
  7101. /**
  7102. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7103. * This is dynamic to allow compat with webgl 1 and 2.
  7104. * You will need to pass the name of the uniform as well as the value.
  7105. */
  7106. updateVector4: (name: string, vector: Vector4) => void;
  7107. /**
  7108. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7109. * This is dynamic to allow compat with webgl 1 and 2.
  7110. * You will need to pass the name of the uniform as well as the value.
  7111. */
  7112. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7113. /**
  7114. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7115. * This is dynamic to allow compat with webgl 1 and 2.
  7116. * You will need to pass the name of the uniform as well as the value.
  7117. */
  7118. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7119. /**
  7120. * Instantiates a new Uniform buffer objects.
  7121. *
  7122. * Handles blocks of uniform on the GPU.
  7123. *
  7124. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7125. *
  7126. * For more information, please refer to :
  7127. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7128. * @param engine Define the engine the buffer is associated with
  7129. * @param data Define the data contained in the buffer
  7130. * @param dynamic Define if the buffer is updatable
  7131. */
  7132. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7133. /**
  7134. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7135. * or just falling back on setUniformXXX calls.
  7136. */
  7137. readonly useUbo: boolean;
  7138. /**
  7139. * Indicates if the WebGL underlying uniform buffer is in sync
  7140. * with the javascript cache data.
  7141. */
  7142. readonly isSync: boolean;
  7143. /**
  7144. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7145. * Also, a dynamic UniformBuffer will disable cache verification and always
  7146. * update the underlying WebGL uniform buffer to the GPU.
  7147. * @returns if Dynamic, otherwise false
  7148. */
  7149. isDynamic(): boolean;
  7150. /**
  7151. * The data cache on JS side.
  7152. * @returns the underlying data as a float array
  7153. */
  7154. getData(): Float32Array;
  7155. /**
  7156. * The underlying WebGL Uniform buffer.
  7157. * @returns the webgl buffer
  7158. */
  7159. getBuffer(): Nullable<DataBuffer>;
  7160. /**
  7161. * std140 layout specifies how to align data within an UBO structure.
  7162. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7163. * for specs.
  7164. */
  7165. private _fillAlignment;
  7166. /**
  7167. * Adds an uniform in the buffer.
  7168. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7169. * for the layout to be correct !
  7170. * @param name Name of the uniform, as used in the uniform block in the shader.
  7171. * @param size Data size, or data directly.
  7172. */
  7173. addUniform(name: string, size: number | number[]): void;
  7174. /**
  7175. * Adds a Matrix 4x4 to the uniform buffer.
  7176. * @param name Name of the uniform, as used in the uniform block in the shader.
  7177. * @param mat A 4x4 matrix.
  7178. */
  7179. addMatrix(name: string, mat: Matrix): void;
  7180. /**
  7181. * Adds a vec2 to the uniform buffer.
  7182. * @param name Name of the uniform, as used in the uniform block in the shader.
  7183. * @param x Define the x component value of the vec2
  7184. * @param y Define the y component value of the vec2
  7185. */
  7186. addFloat2(name: string, x: number, y: number): void;
  7187. /**
  7188. * Adds a vec3 to the uniform buffer.
  7189. * @param name Name of the uniform, as used in the uniform block in the shader.
  7190. * @param x Define the x component value of the vec3
  7191. * @param y Define the y component value of the vec3
  7192. * @param z Define the z component value of the vec3
  7193. */
  7194. addFloat3(name: string, x: number, y: number, z: number): void;
  7195. /**
  7196. * Adds a vec3 to the uniform buffer.
  7197. * @param name Name of the uniform, as used in the uniform block in the shader.
  7198. * @param color Define the vec3 from a Color
  7199. */
  7200. addColor3(name: string, color: Color3): void;
  7201. /**
  7202. * Adds a vec4 to the uniform buffer.
  7203. * @param name Name of the uniform, as used in the uniform block in the shader.
  7204. * @param color Define the rgb components from a Color
  7205. * @param alpha Define the a component of the vec4
  7206. */
  7207. addColor4(name: string, color: Color3, alpha: number): void;
  7208. /**
  7209. * Adds a vec3 to the uniform buffer.
  7210. * @param name Name of the uniform, as used in the uniform block in the shader.
  7211. * @param vector Define the vec3 components from a Vector
  7212. */
  7213. addVector3(name: string, vector: Vector3): void;
  7214. /**
  7215. * Adds a Matrix 3x3 to the uniform buffer.
  7216. * @param name Name of the uniform, as used in the uniform block in the shader.
  7217. */
  7218. addMatrix3x3(name: string): void;
  7219. /**
  7220. * Adds a Matrix 2x2 to the uniform buffer.
  7221. * @param name Name of the uniform, as used in the uniform block in the shader.
  7222. */
  7223. addMatrix2x2(name: string): void;
  7224. /**
  7225. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7226. */
  7227. create(): void;
  7228. /** @hidden */ private _rebuild(): void;
  7229. /**
  7230. * Updates the WebGL Uniform Buffer on the GPU.
  7231. * If the `dynamic` flag is set to true, no cache comparison is done.
  7232. * Otherwise, the buffer will be updated only if the cache differs.
  7233. */
  7234. update(): void;
  7235. /**
  7236. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7237. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7238. * @param data Define the flattened data
  7239. * @param size Define the size of the data.
  7240. */
  7241. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7242. private _valueCache;
  7243. private _cacheMatrix;
  7244. private _updateMatrix3x3ForUniform;
  7245. private _updateMatrix3x3ForEffect;
  7246. private _updateMatrix2x2ForEffect;
  7247. private _updateMatrix2x2ForUniform;
  7248. private _updateFloatForEffect;
  7249. private _updateFloatForUniform;
  7250. private _updateFloat2ForEffect;
  7251. private _updateFloat2ForUniform;
  7252. private _updateFloat3ForEffect;
  7253. private _updateFloat3ForUniform;
  7254. private _updateFloat4ForEffect;
  7255. private _updateFloat4ForUniform;
  7256. private _updateMatrixForEffect;
  7257. private _updateMatrixForUniform;
  7258. private _updateVector3ForEffect;
  7259. private _updateVector3ForUniform;
  7260. private _updateVector4ForEffect;
  7261. private _updateVector4ForUniform;
  7262. private _updateColor3ForEffect;
  7263. private _updateColor3ForUniform;
  7264. private _updateColor4ForEffect;
  7265. private _updateColor4ForUniform;
  7266. /**
  7267. * Sets a sampler uniform on the effect.
  7268. * @param name Define the name of the sampler.
  7269. * @param texture Define the texture to set in the sampler
  7270. */
  7271. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7272. /**
  7273. * Directly updates the value of the uniform in the cache AND on the GPU.
  7274. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7275. * @param data Define the flattened data
  7276. */
  7277. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7278. /**
  7279. * Binds this uniform buffer to an effect.
  7280. * @param effect Define the effect to bind the buffer to
  7281. * @param name Name of the uniform block in the shader.
  7282. */
  7283. bindToEffect(effect: Effect, name: string): void;
  7284. /**
  7285. * Disposes the uniform buffer.
  7286. */
  7287. dispose(): void;
  7288. }
  7289. }
  7290. declare module BABYLON {
  7291. /**
  7292. * Enum that determines the text-wrapping mode to use.
  7293. */
  7294. export enum InspectableType {
  7295. /**
  7296. * Checkbox for booleans
  7297. */
  7298. Checkbox = 0,
  7299. /**
  7300. * Sliders for numbers
  7301. */
  7302. Slider = 1,
  7303. /**
  7304. * Vector3
  7305. */
  7306. Vector3 = 2,
  7307. /**
  7308. * Quaternions
  7309. */
  7310. Quaternion = 3,
  7311. /**
  7312. * Color3
  7313. */
  7314. Color3 = 4,
  7315. /**
  7316. * String
  7317. */
  7318. String = 5
  7319. }
  7320. /**
  7321. * Interface used to define custom inspectable properties.
  7322. * This interface is used by the inspector to display custom property grids
  7323. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7324. */
  7325. export interface IInspectable {
  7326. /**
  7327. * Gets the label to display
  7328. */
  7329. label: string;
  7330. /**
  7331. * Gets the name of the property to edit
  7332. */
  7333. propertyName: string;
  7334. /**
  7335. * Gets the type of the editor to use
  7336. */
  7337. type: InspectableType;
  7338. /**
  7339. * Gets the minimum value of the property when using in "slider" mode
  7340. */
  7341. min?: number;
  7342. /**
  7343. * Gets the maximum value of the property when using in "slider" mode
  7344. */
  7345. max?: number;
  7346. /**
  7347. * Gets the setp to use when using in "slider" mode
  7348. */
  7349. step?: number;
  7350. }
  7351. }
  7352. declare module BABYLON {
  7353. /**
  7354. * Class used to provide helper for timing
  7355. */
  7356. export class TimingTools {
  7357. /**
  7358. * Polyfill for setImmediate
  7359. * @param action defines the action to execute after the current execution block
  7360. */
  7361. static SetImmediate(action: () => void): void;
  7362. }
  7363. }
  7364. declare module BABYLON {
  7365. /**
  7366. * Class used to enable instatition of objects by class name
  7367. */
  7368. export class InstantiationTools {
  7369. /**
  7370. * Use this object to register external classes like custom textures or material
  7371. * to allow the laoders to instantiate them
  7372. */
  7373. static RegisteredExternalClasses: {
  7374. [key: string]: Object;
  7375. };
  7376. /**
  7377. * Tries to instantiate a new object from a given class name
  7378. * @param className defines the class name to instantiate
  7379. * @returns the new object or null if the system was not able to do the instantiation
  7380. */
  7381. static Instantiate(className: string): any;
  7382. }
  7383. }
  7384. declare module BABYLON {
  7385. /**
  7386. * Define options used to create a depth texture
  7387. */
  7388. export class DepthTextureCreationOptions {
  7389. /** Specifies whether or not a stencil should be allocated in the texture */
  7390. generateStencil?: boolean;
  7391. /** Specifies whether or not bilinear filtering is enable on the texture */
  7392. bilinearFiltering?: boolean;
  7393. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7394. comparisonFunction?: number;
  7395. /** Specifies if the created texture is a cube texture */
  7396. isCube?: boolean;
  7397. }
  7398. }
  7399. declare module BABYLON {
  7400. interface ThinEngine {
  7401. /**
  7402. * Creates a depth stencil cube texture.
  7403. * This is only available in WebGL 2.
  7404. * @param size The size of face edge in the cube texture.
  7405. * @param options The options defining the cube texture.
  7406. * @returns The cube texture
  7407. */ private _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7408. /**
  7409. * Creates a cube texture
  7410. * @param rootUrl defines the url where the files to load is located
  7411. * @param scene defines the current scene
  7412. * @param files defines the list of files to load (1 per face)
  7413. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7414. * @param onLoad defines an optional callback raised when the texture is loaded
  7415. * @param onError defines an optional callback raised if there is an issue to load the texture
  7416. * @param format defines the format of the data
  7417. * @param forcedExtension defines the extension to use to pick the right loader
  7418. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7419. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7420. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7421. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7422. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7423. * @returns the cube texture as an InternalTexture
  7424. */
  7425. 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;
  7426. /**
  7427. * Creates a cube texture
  7428. * @param rootUrl defines the url where the files to load is located
  7429. * @param scene defines the current scene
  7430. * @param files defines the list of files to load (1 per face)
  7431. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7432. * @param onLoad defines an optional callback raised when the texture is loaded
  7433. * @param onError defines an optional callback raised if there is an issue to load the texture
  7434. * @param format defines the format of the data
  7435. * @param forcedExtension defines the extension to use to pick the right loader
  7436. * @returns the cube texture as an InternalTexture
  7437. */
  7438. 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;
  7439. /**
  7440. * Creates a cube texture
  7441. * @param rootUrl defines the url where the files to load is located
  7442. * @param scene defines the current scene
  7443. * @param files defines the list of files to load (1 per face)
  7444. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7445. * @param onLoad defines an optional callback raised when the texture is loaded
  7446. * @param onError defines an optional callback raised if there is an issue to load the texture
  7447. * @param format defines the format of the data
  7448. * @param forcedExtension defines the extension to use to pick the right loader
  7449. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7450. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7451. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7452. * @returns the cube texture as an InternalTexture
  7453. */
  7454. 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;
  7455. /** @hidden */ private _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7456. /** @hidden */ private _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7457. /** @hidden */ private _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7458. /** @hidden */ private _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7459. }
  7460. }
  7461. declare module BABYLON {
  7462. /**
  7463. * Class for creating a cube texture
  7464. */
  7465. export class CubeTexture extends BaseTexture {
  7466. private _delayedOnLoad;
  7467. /**
  7468. * The url of the texture
  7469. */
  7470. url: string;
  7471. /**
  7472. * Gets or sets the center of the bounding box associated with the cube texture.
  7473. * It must define where the camera used to render the texture was set
  7474. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7475. */
  7476. boundingBoxPosition: Vector3;
  7477. private _boundingBoxSize;
  7478. /**
  7479. * Gets or sets the size of the bounding box associated with the cube texture
  7480. * When defined, the cubemap will switch to local mode
  7481. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7482. * @example https://www.babylonjs-playground.com/#RNASML
  7483. */
  7484. /**
  7485. * Returns the bounding box size
  7486. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7487. */
  7488. boundingBoxSize: Vector3;
  7489. protected _rotationY: number;
  7490. /**
  7491. * Sets texture matrix rotation angle around Y axis in radians.
  7492. */
  7493. /**
  7494. * Gets texture matrix rotation angle around Y axis radians.
  7495. */
  7496. rotationY: number;
  7497. /**
  7498. * Are mip maps generated for this texture or not.
  7499. */
  7500. readonly noMipmap: boolean;
  7501. private _noMipmap;
  7502. private _files;
  7503. protected _forcedExtension: Nullable<string>;
  7504. private _extensions;
  7505. private _textureMatrix;
  7506. private _format;
  7507. private _createPolynomials;
  7508. /** @hidden */ private _prefiltered: boolean;
  7509. /**
  7510. * Creates a cube texture from an array of image urls
  7511. * @param files defines an array of image urls
  7512. * @param scene defines the hosting scene
  7513. * @param noMipmap specifies if mip maps are not used
  7514. * @returns a cube texture
  7515. */
  7516. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7517. /**
  7518. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7519. * @param url defines the url of the prefiltered texture
  7520. * @param scene defines the scene the texture is attached to
  7521. * @param forcedExtension defines the extension of the file if different from the url
  7522. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7523. * @return the prefiltered texture
  7524. */
  7525. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7526. /**
  7527. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7528. * as prefiltered data.
  7529. * @param rootUrl defines the url of the texture or the root name of the six images
  7530. * @param scene defines the scene the texture is attached to
  7531. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7532. * @param noMipmap defines if mipmaps should be created or not
  7533. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7534. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7535. * @param onError defines a callback triggered in case of error during load
  7536. * @param format defines the internal format to use for the texture once loaded
  7537. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7538. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7539. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7540. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7541. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7542. * @return the cube texture
  7543. */
  7544. 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);
  7545. /**
  7546. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7547. */
  7548. readonly isPrefiltered: boolean;
  7549. /**
  7550. * Get the current class name of the texture useful for serialization or dynamic coding.
  7551. * @returns "CubeTexture"
  7552. */
  7553. getClassName(): string;
  7554. /**
  7555. * Update the url (and optional buffer) of this texture if url was null during construction.
  7556. * @param url the url of the texture
  7557. * @param forcedExtension defines the extension to use
  7558. * @param onLoad callback called when the texture is loaded (defaults to null)
  7559. */
  7560. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7561. /**
  7562. * Delays loading of the cube texture
  7563. * @param forcedExtension defines the extension to use
  7564. */
  7565. delayLoad(forcedExtension?: string): void;
  7566. /**
  7567. * Returns the reflection texture matrix
  7568. * @returns the reflection texture matrix
  7569. */
  7570. getReflectionTextureMatrix(): Matrix;
  7571. /**
  7572. * Sets the reflection texture matrix
  7573. * @param value Reflection texture matrix
  7574. */
  7575. setReflectionTextureMatrix(value: Matrix): void;
  7576. /**
  7577. * Parses text to create a cube texture
  7578. * @param parsedTexture define the serialized text to read from
  7579. * @param scene defines the hosting scene
  7580. * @param rootUrl defines the root url of the cube texture
  7581. * @returns a cube texture
  7582. */
  7583. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7584. /**
  7585. * Makes a clone, or deep copy, of the cube texture
  7586. * @returns a new cube texture
  7587. */
  7588. clone(): CubeTexture;
  7589. }
  7590. }
  7591. declare module BABYLON {
  7592. /**
  7593. * Manages the defines for the Material
  7594. */
  7595. export class MaterialDefines {
  7596. /** @hidden */
  7597. protected _keys: string[];
  7598. private _isDirty;
  7599. /** @hidden */ private _renderId: number;
  7600. /** @hidden */ private _areLightsDirty: boolean;
  7601. /** @hidden */ private _areLightsDisposed: boolean;
  7602. /** @hidden */ private _areAttributesDirty: boolean;
  7603. /** @hidden */ private _areTexturesDirty: boolean;
  7604. /** @hidden */ private _areFresnelDirty: boolean;
  7605. /** @hidden */ private _areMiscDirty: boolean;
  7606. /** @hidden */ private _areImageProcessingDirty: boolean;
  7607. /** @hidden */ private _normals: boolean;
  7608. /** @hidden */ private _uvs: boolean;
  7609. /** @hidden */ private _needNormals: boolean;
  7610. /** @hidden */ private _needUVs: boolean;
  7611. [id: string]: any;
  7612. /**
  7613. * Specifies if the material needs to be re-calculated
  7614. */
  7615. readonly isDirty: boolean;
  7616. /**
  7617. * Marks the material to indicate that it has been re-calculated
  7618. */
  7619. markAsProcessed(): void;
  7620. /**
  7621. * Marks the material to indicate that it needs to be re-calculated
  7622. */
  7623. markAsUnprocessed(): void;
  7624. /**
  7625. * Marks the material to indicate all of its defines need to be re-calculated
  7626. */
  7627. markAllAsDirty(): void;
  7628. /**
  7629. * Marks the material to indicate that image processing needs to be re-calculated
  7630. */
  7631. markAsImageProcessingDirty(): void;
  7632. /**
  7633. * Marks the material to indicate the lights need to be re-calculated
  7634. * @param disposed Defines whether the light is dirty due to dispose or not
  7635. */
  7636. markAsLightDirty(disposed?: boolean): void;
  7637. /**
  7638. * Marks the attribute state as changed
  7639. */
  7640. markAsAttributesDirty(): void;
  7641. /**
  7642. * Marks the texture state as changed
  7643. */
  7644. markAsTexturesDirty(): void;
  7645. /**
  7646. * Marks the fresnel state as changed
  7647. */
  7648. markAsFresnelDirty(): void;
  7649. /**
  7650. * Marks the misc state as changed
  7651. */
  7652. markAsMiscDirty(): void;
  7653. /**
  7654. * Rebuilds the material defines
  7655. */
  7656. rebuild(): void;
  7657. /**
  7658. * Specifies if two material defines are equal
  7659. * @param other - A material define instance to compare to
  7660. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7661. */
  7662. isEqual(other: MaterialDefines): boolean;
  7663. /**
  7664. * Clones this instance's defines to another instance
  7665. * @param other - material defines to clone values to
  7666. */
  7667. cloneTo(other: MaterialDefines): void;
  7668. /**
  7669. * Resets the material define values
  7670. */
  7671. reset(): void;
  7672. /**
  7673. * Converts the material define values to a string
  7674. * @returns - String of material define information
  7675. */
  7676. toString(): string;
  7677. }
  7678. }
  7679. declare module BABYLON {
  7680. /**
  7681. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7682. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7683. * 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;
  7684. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7685. */
  7686. export class ColorCurves {
  7687. private _dirty;
  7688. private _tempColor;
  7689. private _globalCurve;
  7690. private _highlightsCurve;
  7691. private _midtonesCurve;
  7692. private _shadowsCurve;
  7693. private _positiveCurve;
  7694. private _negativeCurve;
  7695. private _globalHue;
  7696. private _globalDensity;
  7697. private _globalSaturation;
  7698. private _globalExposure;
  7699. /**
  7700. * Gets the global Hue value.
  7701. * 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).
  7702. */
  7703. /**
  7704. * Sets the global Hue value.
  7705. * 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).
  7706. */
  7707. globalHue: number;
  7708. /**
  7709. * Gets the global Density value.
  7710. * 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.
  7711. * Values less than zero provide a filter of opposite hue.
  7712. */
  7713. /**
  7714. * Sets the global Density value.
  7715. * 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.
  7716. * Values less than zero provide a filter of opposite hue.
  7717. */
  7718. globalDensity: number;
  7719. /**
  7720. * Gets the global Saturation value.
  7721. * 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.
  7722. */
  7723. /**
  7724. * Sets the global Saturation value.
  7725. * 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.
  7726. */
  7727. globalSaturation: number;
  7728. /**
  7729. * Gets the global Exposure value.
  7730. * 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.
  7731. */
  7732. /**
  7733. * Sets the global Exposure value.
  7734. * 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.
  7735. */
  7736. globalExposure: number;
  7737. private _highlightsHue;
  7738. private _highlightsDensity;
  7739. private _highlightsSaturation;
  7740. private _highlightsExposure;
  7741. /**
  7742. * Gets the highlights Hue value.
  7743. * 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).
  7744. */
  7745. /**
  7746. * Sets the highlights Hue value.
  7747. * 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).
  7748. */
  7749. highlightsHue: number;
  7750. /**
  7751. * Gets the highlights Density value.
  7752. * 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.
  7753. * Values less than zero provide a filter of opposite hue.
  7754. */
  7755. /**
  7756. * Sets the highlights Density value.
  7757. * 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.
  7758. * Values less than zero provide a filter of opposite hue.
  7759. */
  7760. highlightsDensity: number;
  7761. /**
  7762. * Gets the highlights Saturation value.
  7763. * 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.
  7764. */
  7765. /**
  7766. * Sets the highlights Saturation value.
  7767. * 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.
  7768. */
  7769. highlightsSaturation: number;
  7770. /**
  7771. * Gets the highlights Exposure value.
  7772. * 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.
  7773. */
  7774. /**
  7775. * Sets the highlights Exposure value.
  7776. * 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.
  7777. */
  7778. highlightsExposure: number;
  7779. private _midtonesHue;
  7780. private _midtonesDensity;
  7781. private _midtonesSaturation;
  7782. private _midtonesExposure;
  7783. /**
  7784. * Gets the midtones Hue value.
  7785. * 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).
  7786. */
  7787. /**
  7788. * Sets the midtones Hue value.
  7789. * 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).
  7790. */
  7791. midtonesHue: number;
  7792. /**
  7793. * Gets the midtones Density value.
  7794. * 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.
  7795. * Values less than zero provide a filter of opposite hue.
  7796. */
  7797. /**
  7798. * Sets the midtones Density value.
  7799. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7800. * Values less than zero provide a filter of opposite hue.
  7801. */
  7802. midtonesDensity: number;
  7803. /**
  7804. * Gets the midtones Saturation value.
  7805. * 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.
  7806. */
  7807. /**
  7808. * Sets the midtones Saturation value.
  7809. * 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.
  7810. */
  7811. midtonesSaturation: number;
  7812. /**
  7813. * Gets the midtones Exposure value.
  7814. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7815. */
  7816. /**
  7817. * Sets the midtones Exposure value.
  7818. * 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.
  7819. */
  7820. midtonesExposure: number;
  7821. private _shadowsHue;
  7822. private _shadowsDensity;
  7823. private _shadowsSaturation;
  7824. private _shadowsExposure;
  7825. /**
  7826. * Gets the shadows Hue value.
  7827. * 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).
  7828. */
  7829. /**
  7830. * Sets the shadows Hue value.
  7831. * 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).
  7832. */
  7833. shadowsHue: number;
  7834. /**
  7835. * Gets the shadows Density value.
  7836. * 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.
  7837. * Values less than zero provide a filter of opposite hue.
  7838. */
  7839. /**
  7840. * Sets the shadows Density value.
  7841. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7842. * Values less than zero provide a filter of opposite hue.
  7843. */
  7844. shadowsDensity: number;
  7845. /**
  7846. * Gets the shadows Saturation value.
  7847. * 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.
  7848. */
  7849. /**
  7850. * Sets the shadows Saturation value.
  7851. * 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.
  7852. */
  7853. shadowsSaturation: number;
  7854. /**
  7855. * Gets the shadows Exposure value.
  7856. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7857. */
  7858. /**
  7859. * Sets the shadows Exposure value.
  7860. * 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.
  7861. */
  7862. shadowsExposure: number;
  7863. /**
  7864. * Returns the class name
  7865. * @returns The class name
  7866. */
  7867. getClassName(): string;
  7868. /**
  7869. * Binds the color curves to the shader.
  7870. * @param colorCurves The color curve to bind
  7871. * @param effect The effect to bind to
  7872. * @param positiveUniform The positive uniform shader parameter
  7873. * @param neutralUniform The neutral uniform shader parameter
  7874. * @param negativeUniform The negative uniform shader parameter
  7875. */
  7876. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7877. /**
  7878. * Prepare the list of uniforms associated with the ColorCurves effects.
  7879. * @param uniformsList The list of uniforms used in the effect
  7880. */
  7881. static PrepareUniforms(uniformsList: string[]): void;
  7882. /**
  7883. * Returns color grading data based on a hue, density, saturation and exposure value.
  7884. * @param filterHue The hue of the color filter.
  7885. * @param filterDensity The density of the color filter.
  7886. * @param saturation The saturation.
  7887. * @param exposure The exposure.
  7888. * @param result The result data container.
  7889. */
  7890. private getColorGradingDataToRef;
  7891. /**
  7892. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7893. * @param value The input slider value in range [-100,100].
  7894. * @returns Adjusted value.
  7895. */
  7896. private static applyColorGradingSliderNonlinear;
  7897. /**
  7898. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7899. * @param hue The hue (H) input.
  7900. * @param saturation The saturation (S) input.
  7901. * @param brightness The brightness (B) input.
  7902. * @result An RGBA color represented as Vector4.
  7903. */
  7904. private static fromHSBToRef;
  7905. /**
  7906. * Returns a value clamped between min and max
  7907. * @param value The value to clamp
  7908. * @param min The minimum of value
  7909. * @param max The maximum of value
  7910. * @returns The clamped value.
  7911. */
  7912. private static clamp;
  7913. /**
  7914. * Clones the current color curve instance.
  7915. * @return The cloned curves
  7916. */
  7917. clone(): ColorCurves;
  7918. /**
  7919. * Serializes the current color curve instance to a json representation.
  7920. * @return a JSON representation
  7921. */
  7922. serialize(): any;
  7923. /**
  7924. * Parses the color curve from a json representation.
  7925. * @param source the JSON source to parse
  7926. * @return The parsed curves
  7927. */
  7928. static Parse(source: any): ColorCurves;
  7929. }
  7930. }
  7931. declare module BABYLON {
  7932. /**
  7933. * Interface to follow in your material defines to integrate easily the
  7934. * Image proccessing functions.
  7935. * @hidden
  7936. */
  7937. export interface IImageProcessingConfigurationDefines {
  7938. IMAGEPROCESSING: boolean;
  7939. VIGNETTE: boolean;
  7940. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7941. VIGNETTEBLENDMODEOPAQUE: boolean;
  7942. TONEMAPPING: boolean;
  7943. TONEMAPPING_ACES: boolean;
  7944. CONTRAST: boolean;
  7945. EXPOSURE: boolean;
  7946. COLORCURVES: boolean;
  7947. COLORGRADING: boolean;
  7948. COLORGRADING3D: boolean;
  7949. SAMPLER3DGREENDEPTH: boolean;
  7950. SAMPLER3DBGRMAP: boolean;
  7951. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7952. }
  7953. /**
  7954. * @hidden
  7955. */
  7956. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  7957. IMAGEPROCESSING: boolean;
  7958. VIGNETTE: boolean;
  7959. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7960. VIGNETTEBLENDMODEOPAQUE: boolean;
  7961. TONEMAPPING: boolean;
  7962. TONEMAPPING_ACES: boolean;
  7963. CONTRAST: boolean;
  7964. COLORCURVES: boolean;
  7965. COLORGRADING: boolean;
  7966. COLORGRADING3D: boolean;
  7967. SAMPLER3DGREENDEPTH: boolean;
  7968. SAMPLER3DBGRMAP: boolean;
  7969. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7970. EXPOSURE: boolean;
  7971. constructor();
  7972. }
  7973. /**
  7974. * This groups together the common properties used for image processing either in direct forward pass
  7975. * or through post processing effect depending on the use of the image processing pipeline in your scene
  7976. * or not.
  7977. */
  7978. export class ImageProcessingConfiguration {
  7979. /**
  7980. * Default tone mapping applied in BabylonJS.
  7981. */
  7982. static readonly TONEMAPPING_STANDARD: number;
  7983. /**
  7984. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  7985. * to other engines rendering to increase portability.
  7986. */
  7987. static readonly TONEMAPPING_ACES: number;
  7988. /**
  7989. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  7990. */
  7991. colorCurves: Nullable<ColorCurves>;
  7992. private _colorCurvesEnabled;
  7993. /**
  7994. * Gets wether the color curves effect is enabled.
  7995. */
  7996. /**
  7997. * Sets wether the color curves effect is enabled.
  7998. */
  7999. colorCurvesEnabled: boolean;
  8000. private _colorGradingTexture;
  8001. /**
  8002. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8003. */
  8004. /**
  8005. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8006. */
  8007. colorGradingTexture: Nullable<BaseTexture>;
  8008. private _colorGradingEnabled;
  8009. /**
  8010. * Gets wether the color grading effect is enabled.
  8011. */
  8012. /**
  8013. * Sets wether the color grading effect is enabled.
  8014. */
  8015. colorGradingEnabled: boolean;
  8016. private _colorGradingWithGreenDepth;
  8017. /**
  8018. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8019. */
  8020. /**
  8021. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8022. */
  8023. colorGradingWithGreenDepth: boolean;
  8024. private _colorGradingBGR;
  8025. /**
  8026. * Gets wether the color grading texture contains BGR values.
  8027. */
  8028. /**
  8029. * Sets wether the color grading texture contains BGR values.
  8030. */
  8031. colorGradingBGR: boolean;
  8032. /** @hidden */ private _exposure: number;
  8033. /**
  8034. * Gets the Exposure used in the effect.
  8035. */
  8036. /**
  8037. * Sets the Exposure used in the effect.
  8038. */
  8039. exposure: number;
  8040. private _toneMappingEnabled;
  8041. /**
  8042. * Gets wether the tone mapping effect is enabled.
  8043. */
  8044. /**
  8045. * Sets wether the tone mapping effect is enabled.
  8046. */
  8047. toneMappingEnabled: boolean;
  8048. private _toneMappingType;
  8049. /**
  8050. * Gets the type of tone mapping effect.
  8051. */
  8052. /**
  8053. * Sets the type of tone mapping effect used in BabylonJS.
  8054. */
  8055. toneMappingType: number;
  8056. protected _contrast: number;
  8057. /**
  8058. * Gets the contrast used in the effect.
  8059. */
  8060. /**
  8061. * Sets the contrast used in the effect.
  8062. */
  8063. contrast: number;
  8064. /**
  8065. * Vignette stretch size.
  8066. */
  8067. vignetteStretch: number;
  8068. /**
  8069. * Vignette centre X Offset.
  8070. */
  8071. vignetteCentreX: number;
  8072. /**
  8073. * Vignette centre Y Offset.
  8074. */
  8075. vignetteCentreY: number;
  8076. /**
  8077. * Vignette weight or intensity of the vignette effect.
  8078. */
  8079. vignetteWeight: number;
  8080. /**
  8081. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8082. * if vignetteEnabled is set to true.
  8083. */
  8084. vignetteColor: Color4;
  8085. /**
  8086. * Camera field of view used by the Vignette effect.
  8087. */
  8088. vignetteCameraFov: number;
  8089. private _vignetteBlendMode;
  8090. /**
  8091. * Gets the vignette blend mode allowing different kind of effect.
  8092. */
  8093. /**
  8094. * Sets the vignette blend mode allowing different kind of effect.
  8095. */
  8096. vignetteBlendMode: number;
  8097. private _vignetteEnabled;
  8098. /**
  8099. * Gets wether the vignette effect is enabled.
  8100. */
  8101. /**
  8102. * Sets wether the vignette effect is enabled.
  8103. */
  8104. vignetteEnabled: boolean;
  8105. private _applyByPostProcess;
  8106. /**
  8107. * Gets wether the image processing is applied through a post process or not.
  8108. */
  8109. /**
  8110. * Sets wether the image processing is applied through a post process or not.
  8111. */
  8112. applyByPostProcess: boolean;
  8113. private _isEnabled;
  8114. /**
  8115. * Gets wether the image processing is enabled or not.
  8116. */
  8117. /**
  8118. * Sets wether the image processing is enabled or not.
  8119. */
  8120. isEnabled: boolean;
  8121. /**
  8122. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8123. */
  8124. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8125. /**
  8126. * Method called each time the image processing information changes requires to recompile the effect.
  8127. */
  8128. protected _updateParameters(): void;
  8129. /**
  8130. * Gets the current class name.
  8131. * @return "ImageProcessingConfiguration"
  8132. */
  8133. getClassName(): string;
  8134. /**
  8135. * Prepare the list of uniforms associated with the Image Processing effects.
  8136. * @param uniforms The list of uniforms used in the effect
  8137. * @param defines the list of defines currently in use
  8138. */
  8139. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8140. /**
  8141. * Prepare the list of samplers associated with the Image Processing effects.
  8142. * @param samplersList The list of uniforms used in the effect
  8143. * @param defines the list of defines currently in use
  8144. */
  8145. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8146. /**
  8147. * Prepare the list of defines associated to the shader.
  8148. * @param defines the list of defines to complete
  8149. * @param forPostProcess Define if we are currently in post process mode or not
  8150. */
  8151. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8152. /**
  8153. * Returns true if all the image processing information are ready.
  8154. * @returns True if ready, otherwise, false
  8155. */
  8156. isReady(): boolean;
  8157. /**
  8158. * Binds the image processing to the shader.
  8159. * @param effect The effect to bind to
  8160. * @param aspectRatio Define the current aspect ratio of the effect
  8161. */
  8162. bind(effect: Effect, aspectRatio?: number): void;
  8163. /**
  8164. * Clones the current image processing instance.
  8165. * @return The cloned image processing
  8166. */
  8167. clone(): ImageProcessingConfiguration;
  8168. /**
  8169. * Serializes the current image processing instance to a json representation.
  8170. * @return a JSON representation
  8171. */
  8172. serialize(): any;
  8173. /**
  8174. * Parses the image processing from a json representation.
  8175. * @param source the JSON source to parse
  8176. * @return The parsed image processing
  8177. */
  8178. static Parse(source: any): ImageProcessingConfiguration;
  8179. private static _VIGNETTEMODE_MULTIPLY;
  8180. private static _VIGNETTEMODE_OPAQUE;
  8181. /**
  8182. * Used to apply the vignette as a mix with the pixel color.
  8183. */
  8184. static readonly VIGNETTEMODE_MULTIPLY: number;
  8185. /**
  8186. * Used to apply the vignette as a replacement of the pixel color.
  8187. */
  8188. static readonly VIGNETTEMODE_OPAQUE: number;
  8189. }
  8190. }
  8191. declare module BABYLON {
  8192. /** @hidden */
  8193. export var postprocessVertexShader: {
  8194. name: string;
  8195. shader: string;
  8196. };
  8197. }
  8198. declare module BABYLON {
  8199. interface ThinEngine {
  8200. /**
  8201. * Creates a new render target texture
  8202. * @param size defines the size of the texture
  8203. * @param options defines the options used to create the texture
  8204. * @returns a new render target texture stored in an InternalTexture
  8205. */
  8206. createRenderTargetTexture(size: number | {
  8207. width: number;
  8208. height: number;
  8209. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8210. }
  8211. }
  8212. declare module BABYLON {
  8213. /** Defines supported spaces */
  8214. export enum Space {
  8215. /** Local (object) space */
  8216. LOCAL = 0,
  8217. /** World space */
  8218. WORLD = 1,
  8219. /** Bone space */
  8220. BONE = 2
  8221. }
  8222. /** Defines the 3 main axes */
  8223. export class Axis {
  8224. /** X axis */
  8225. static X: Vector3;
  8226. /** Y axis */
  8227. static Y: Vector3;
  8228. /** Z axis */
  8229. static Z: Vector3;
  8230. }
  8231. }
  8232. declare module BABYLON {
  8233. /**
  8234. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8235. * This is the base of the follow, arc rotate cameras and Free camera
  8236. * @see http://doc.babylonjs.com/features/cameras
  8237. */
  8238. export class TargetCamera extends Camera {
  8239. private static _RigCamTransformMatrix;
  8240. private static _TargetTransformMatrix;
  8241. private static _TargetFocalPoint;
  8242. /**
  8243. * Define the current direction the camera is moving to
  8244. */
  8245. cameraDirection: Vector3;
  8246. /**
  8247. * Define the current rotation the camera is rotating to
  8248. */
  8249. cameraRotation: Vector2;
  8250. /**
  8251. * When set, the up vector of the camera will be updated by the rotation of the camera
  8252. */
  8253. updateUpVectorFromRotation: boolean;
  8254. private _tmpQuaternion;
  8255. /**
  8256. * Define the current rotation of the camera
  8257. */
  8258. rotation: Vector3;
  8259. /**
  8260. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8261. */
  8262. rotationQuaternion: Quaternion;
  8263. /**
  8264. * Define the current speed of the camera
  8265. */
  8266. speed: number;
  8267. /**
  8268. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8269. * around all axis.
  8270. */
  8271. noRotationConstraint: boolean;
  8272. /**
  8273. * Define the current target of the camera as an object or a position.
  8274. */
  8275. lockedTarget: any;
  8276. /** @hidden */ private _currentTarget: Vector3;
  8277. /** @hidden */ private _initialFocalDistance: number;
  8278. /** @hidden */ private _viewMatrix: Matrix;
  8279. /** @hidden */ private _camMatrix: Matrix;
  8280. /** @hidden */ private _cameraTransformMatrix: Matrix;
  8281. /** @hidden */ private _cameraRotationMatrix: Matrix;
  8282. /** @hidden */ private _referencePoint: Vector3;
  8283. /** @hidden */ private _transformedReferencePoint: Vector3;
  8284. protected _globalCurrentTarget: Vector3;
  8285. protected _globalCurrentUpVector: Vector3;
  8286. /** @hidden */ private _reset: () => void;
  8287. private _defaultUp;
  8288. /**
  8289. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8290. * This is the base of the follow, arc rotate cameras and Free camera
  8291. * @see http://doc.babylonjs.com/features/cameras
  8292. * @param name Defines the name of the camera in the scene
  8293. * @param position Defines the start position of the camera in the scene
  8294. * @param scene Defines the scene the camera belongs to
  8295. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8296. */
  8297. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8298. /**
  8299. * Gets the position in front of the camera at a given distance.
  8300. * @param distance The distance from the camera we want the position to be
  8301. * @returns the position
  8302. */
  8303. getFrontPosition(distance: number): Vector3;
  8304. /** @hidden */ private _getLockedTargetPosition(): Nullable<Vector3>;
  8305. private _storedPosition;
  8306. private _storedRotation;
  8307. private _storedRotationQuaternion;
  8308. /**
  8309. * Store current camera state of the camera (fov, position, rotation, etc..)
  8310. * @returns the camera
  8311. */
  8312. storeState(): Camera;
  8313. /**
  8314. * Restored camera state. You must call storeState() first
  8315. * @returns whether it was successful or not
  8316. * @hidden
  8317. */ private _restoreStateValues(): boolean;
  8318. /** @hidden */ private _initCache(): void;
  8319. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  8320. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  8321. /** @hidden */ private _computeLocalCameraSpeed(): number;
  8322. /**
  8323. * Defines the target the camera should look at.
  8324. * @param target Defines the new target as a Vector or a mesh
  8325. */
  8326. setTarget(target: Vector3): void;
  8327. /**
  8328. * Return the current target position of the camera. This value is expressed in local space.
  8329. * @returns the target position
  8330. */
  8331. getTarget(): Vector3;
  8332. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  8333. /** @hidden */ private _updatePosition(): void;
  8334. /** @hidden */ private _checkInputs(): void;
  8335. protected _updateCameraRotationMatrix(): void;
  8336. /**
  8337. * 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)
  8338. * @returns the current camera
  8339. */
  8340. private _rotateUpVectorWithCameraRotationMatrix;
  8341. private _cachedRotationZ;
  8342. private _cachedQuaternionRotationZ;
  8343. /** @hidden */ private _getViewMatrix(): Matrix;
  8344. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8345. /**
  8346. * @hidden
  8347. */
  8348. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8349. /**
  8350. * @hidden
  8351. */ private _updateRigCameras(): void;
  8352. private _getRigCamPositionAndTarget;
  8353. /**
  8354. * Gets the current object class name.
  8355. * @return the class name
  8356. */
  8357. getClassName(): string;
  8358. }
  8359. }
  8360. declare module BABYLON {
  8361. /**
  8362. * Gather the list of keyboard event types as constants.
  8363. */
  8364. export class KeyboardEventTypes {
  8365. /**
  8366. * The keydown event is fired when a key becomes active (pressed).
  8367. */
  8368. static readonly KEYDOWN: number;
  8369. /**
  8370. * The keyup event is fired when a key has been released.
  8371. */
  8372. static readonly KEYUP: number;
  8373. }
  8374. /**
  8375. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8376. */
  8377. export class KeyboardInfo {
  8378. /**
  8379. * Defines the type of event (KeyboardEventTypes)
  8380. */
  8381. type: number;
  8382. /**
  8383. * Defines the related dom event
  8384. */
  8385. event: KeyboardEvent;
  8386. /**
  8387. * Instantiates a new keyboard info.
  8388. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8389. * @param type Defines the type of event (KeyboardEventTypes)
  8390. * @param event Defines the related dom event
  8391. */
  8392. constructor(
  8393. /**
  8394. * Defines the type of event (KeyboardEventTypes)
  8395. */
  8396. type: number,
  8397. /**
  8398. * Defines the related dom event
  8399. */
  8400. event: KeyboardEvent);
  8401. }
  8402. /**
  8403. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8404. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8405. */
  8406. export class KeyboardInfoPre extends KeyboardInfo {
  8407. /**
  8408. * Defines the type of event (KeyboardEventTypes)
  8409. */
  8410. type: number;
  8411. /**
  8412. * Defines the related dom event
  8413. */
  8414. event: KeyboardEvent;
  8415. /**
  8416. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8417. */
  8418. skipOnPointerObservable: boolean;
  8419. /**
  8420. * Instantiates a new keyboard pre info.
  8421. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8422. * @param type Defines the type of event (KeyboardEventTypes)
  8423. * @param event Defines the related dom event
  8424. */
  8425. constructor(
  8426. /**
  8427. * Defines the type of event (KeyboardEventTypes)
  8428. */
  8429. type: number,
  8430. /**
  8431. * Defines the related dom event
  8432. */
  8433. event: KeyboardEvent);
  8434. }
  8435. }
  8436. declare module BABYLON {
  8437. /**
  8438. * Manage the keyboard inputs to control the movement of a free camera.
  8439. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8440. */
  8441. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8442. /**
  8443. * Defines the camera the input is attached to.
  8444. */
  8445. camera: FreeCamera;
  8446. /**
  8447. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8448. */
  8449. keysUp: number[];
  8450. /**
  8451. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8452. */
  8453. keysDown: number[];
  8454. /**
  8455. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8456. */
  8457. keysLeft: number[];
  8458. /**
  8459. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8460. */
  8461. keysRight: number[];
  8462. private _keys;
  8463. private _onCanvasBlurObserver;
  8464. private _onKeyboardObserver;
  8465. private _engine;
  8466. private _scene;
  8467. /**
  8468. * Attach the input controls to a specific dom element to get the input from.
  8469. * @param element Defines the element the controls should be listened from
  8470. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8471. */
  8472. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8473. /**
  8474. * Detach the current controls from the specified dom element.
  8475. * @param element Defines the element to stop listening the inputs from
  8476. */
  8477. detachControl(element: Nullable<HTMLElement>): void;
  8478. /**
  8479. * Update the current camera state depending on the inputs that have been used this frame.
  8480. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8481. */
  8482. checkInputs(): void;
  8483. /**
  8484. * Gets the class name of the current intput.
  8485. * @returns the class name
  8486. */
  8487. getClassName(): string;
  8488. /** @hidden */ private _onLostFocus(): void;
  8489. /**
  8490. * Get the friendly name associated with the input class.
  8491. * @returns the input friendly name
  8492. */
  8493. getSimpleName(): string;
  8494. }
  8495. }
  8496. declare module BABYLON {
  8497. /**
  8498. * Interface describing all the common properties and methods a shadow light needs to implement.
  8499. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8500. * as well as binding the different shadow properties to the effects.
  8501. */
  8502. export interface IShadowLight extends Light {
  8503. /**
  8504. * The light id in the scene (used in scene.findLighById for instance)
  8505. */
  8506. id: string;
  8507. /**
  8508. * The position the shdow will be casted from.
  8509. */
  8510. position: Vector3;
  8511. /**
  8512. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8513. */
  8514. direction: Vector3;
  8515. /**
  8516. * The transformed position. Position of the light in world space taking parenting in account.
  8517. */
  8518. transformedPosition: Vector3;
  8519. /**
  8520. * The transformed direction. Direction of the light in world space taking parenting in account.
  8521. */
  8522. transformedDirection: Vector3;
  8523. /**
  8524. * The friendly name of the light in the scene.
  8525. */
  8526. name: string;
  8527. /**
  8528. * Defines the shadow projection clipping minimum z value.
  8529. */
  8530. shadowMinZ: number;
  8531. /**
  8532. * Defines the shadow projection clipping maximum z value.
  8533. */
  8534. shadowMaxZ: number;
  8535. /**
  8536. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8537. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8538. */
  8539. computeTransformedInformation(): boolean;
  8540. /**
  8541. * Gets the scene the light belongs to.
  8542. * @returns The scene
  8543. */
  8544. getScene(): Scene;
  8545. /**
  8546. * Callback defining a custom Projection Matrix Builder.
  8547. * This can be used to override the default projection matrix computation.
  8548. */
  8549. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8550. /**
  8551. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8552. * @param matrix The materix to updated with the projection information
  8553. * @param viewMatrix The transform matrix of the light
  8554. * @param renderList The list of mesh to render in the map
  8555. * @returns The current light
  8556. */
  8557. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8558. /**
  8559. * Gets the current depth scale used in ESM.
  8560. * @returns The scale
  8561. */
  8562. getDepthScale(): number;
  8563. /**
  8564. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8565. * @returns true if a cube texture needs to be use
  8566. */
  8567. needCube(): boolean;
  8568. /**
  8569. * Detects if the projection matrix requires to be recomputed this frame.
  8570. * @returns true if it requires to be recomputed otherwise, false.
  8571. */
  8572. needProjectionMatrixCompute(): boolean;
  8573. /**
  8574. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8575. */
  8576. forceProjectionMatrixCompute(): void;
  8577. /**
  8578. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8579. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8580. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8581. */
  8582. getShadowDirection(faceIndex?: number): Vector3;
  8583. /**
  8584. * Gets the minZ used for shadow according to both the scene and the light.
  8585. * @param activeCamera The camera we are returning the min for
  8586. * @returns the depth min z
  8587. */
  8588. getDepthMinZ(activeCamera: Camera): number;
  8589. /**
  8590. * Gets the maxZ used for shadow according to both the scene and the light.
  8591. * @param activeCamera The camera we are returning the max for
  8592. * @returns the depth max z
  8593. */
  8594. getDepthMaxZ(activeCamera: Camera): number;
  8595. }
  8596. /**
  8597. * Base implementation IShadowLight
  8598. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8599. */
  8600. export abstract class ShadowLight extends Light implements IShadowLight {
  8601. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8602. protected _position: Vector3;
  8603. protected _setPosition(value: Vector3): void;
  8604. /**
  8605. * Sets the position the shadow will be casted from. Also use as the light position for both
  8606. * point and spot lights.
  8607. */
  8608. /**
  8609. * Sets the position the shadow will be casted from. Also use as the light position for both
  8610. * point and spot lights.
  8611. */
  8612. position: Vector3;
  8613. protected _direction: Vector3;
  8614. protected _setDirection(value: Vector3): void;
  8615. /**
  8616. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8617. * Also use as the light direction on spot and directional lights.
  8618. */
  8619. /**
  8620. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8621. * Also use as the light direction on spot and directional lights.
  8622. */
  8623. direction: Vector3;
  8624. private _shadowMinZ;
  8625. /**
  8626. * Gets the shadow projection clipping minimum z value.
  8627. */
  8628. /**
  8629. * Sets the shadow projection clipping minimum z value.
  8630. */
  8631. shadowMinZ: number;
  8632. private _shadowMaxZ;
  8633. /**
  8634. * Sets the shadow projection clipping maximum z value.
  8635. */
  8636. /**
  8637. * Gets the shadow projection clipping maximum z value.
  8638. */
  8639. shadowMaxZ: number;
  8640. /**
  8641. * Callback defining a custom Projection Matrix Builder.
  8642. * This can be used to override the default projection matrix computation.
  8643. */
  8644. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8645. /**
  8646. * The transformed position. Position of the light in world space taking parenting in account.
  8647. */
  8648. transformedPosition: Vector3;
  8649. /**
  8650. * The transformed direction. Direction of the light in world space taking parenting in account.
  8651. */
  8652. transformedDirection: Vector3;
  8653. private _needProjectionMatrixCompute;
  8654. /**
  8655. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8656. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8657. */
  8658. computeTransformedInformation(): boolean;
  8659. /**
  8660. * Return the depth scale used for the shadow map.
  8661. * @returns the depth scale.
  8662. */
  8663. getDepthScale(): number;
  8664. /**
  8665. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8666. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8667. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8668. */
  8669. getShadowDirection(faceIndex?: number): Vector3;
  8670. /**
  8671. * Returns the ShadowLight absolute position in the World.
  8672. * @returns the position vector in world space
  8673. */
  8674. getAbsolutePosition(): Vector3;
  8675. /**
  8676. * Sets the ShadowLight direction toward the passed target.
  8677. * @param target The point to target in local space
  8678. * @returns the updated ShadowLight direction
  8679. */
  8680. setDirectionToTarget(target: Vector3): Vector3;
  8681. /**
  8682. * Returns the light rotation in euler definition.
  8683. * @returns the x y z rotation in local space.
  8684. */
  8685. getRotation(): Vector3;
  8686. /**
  8687. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8688. * @returns true if a cube texture needs to be use
  8689. */
  8690. needCube(): boolean;
  8691. /**
  8692. * Detects if the projection matrix requires to be recomputed this frame.
  8693. * @returns true if it requires to be recomputed otherwise, false.
  8694. */
  8695. needProjectionMatrixCompute(): boolean;
  8696. /**
  8697. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8698. */
  8699. forceProjectionMatrixCompute(): void;
  8700. /** @hidden */ private _initCache(): void;
  8701. /** @hidden */ private _isSynchronized(): boolean;
  8702. /**
  8703. * Computes the world matrix of the node
  8704. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8705. * @returns the world matrix
  8706. */
  8707. computeWorldMatrix(force?: boolean): Matrix;
  8708. /**
  8709. * Gets the minZ used for shadow according to both the scene and the light.
  8710. * @param activeCamera The camera we are returning the min for
  8711. * @returns the depth min z
  8712. */
  8713. getDepthMinZ(activeCamera: Camera): number;
  8714. /**
  8715. * Gets the maxZ used for shadow according to both the scene and the light.
  8716. * @param activeCamera The camera we are returning the max for
  8717. * @returns the depth max z
  8718. */
  8719. getDepthMaxZ(activeCamera: Camera): number;
  8720. /**
  8721. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8722. * @param matrix The materix to updated with the projection information
  8723. * @param viewMatrix The transform matrix of the light
  8724. * @param renderList The list of mesh to render in the map
  8725. * @returns The current light
  8726. */
  8727. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8728. }
  8729. }
  8730. declare module BABYLON {
  8731. /**
  8732. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8733. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8734. */
  8735. export class EffectFallbacks implements IEffectFallbacks {
  8736. private _defines;
  8737. private _currentRank;
  8738. private _maxRank;
  8739. private _mesh;
  8740. /**
  8741. * Removes the fallback from the bound mesh.
  8742. */
  8743. unBindMesh(): void;
  8744. /**
  8745. * Adds a fallback on the specified property.
  8746. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8747. * @param define The name of the define in the shader
  8748. */
  8749. addFallback(rank: number, define: string): void;
  8750. /**
  8751. * Sets the mesh to use CPU skinning when needing to fallback.
  8752. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8753. * @param mesh The mesh to use the fallbacks.
  8754. */
  8755. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8756. /**
  8757. * Checks to see if more fallbacks are still availible.
  8758. */
  8759. readonly hasMoreFallbacks: boolean;
  8760. /**
  8761. * Removes the defines that should be removed when falling back.
  8762. * @param currentDefines defines the current define statements for the shader.
  8763. * @param effect defines the current effect we try to compile
  8764. * @returns The resulting defines with defines of the current rank removed.
  8765. */
  8766. reduce(currentDefines: string, effect: Effect): string;
  8767. }
  8768. }
  8769. declare module BABYLON {
  8770. /**
  8771. * "Static Class" containing the most commonly used helper while dealing with material for
  8772. * rendering purpose.
  8773. *
  8774. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8775. *
  8776. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8777. */
  8778. export class MaterialHelper {
  8779. /**
  8780. * Bind the current view position to an effect.
  8781. * @param effect The effect to be bound
  8782. * @param scene The scene the eyes position is used from
  8783. */
  8784. static BindEyePosition(effect: Effect, scene: Scene): void;
  8785. /**
  8786. * Helps preparing the defines values about the UVs in used in the effect.
  8787. * UVs are shared as much as we can accross channels in the shaders.
  8788. * @param texture The texture we are preparing the UVs for
  8789. * @param defines The defines to update
  8790. * @param key The channel key "diffuse", "specular"... used in the shader
  8791. */
  8792. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8793. /**
  8794. * Binds a texture matrix value to its corrsponding uniform
  8795. * @param texture The texture to bind the matrix for
  8796. * @param uniformBuffer The uniform buffer receivin the data
  8797. * @param key The channel key "diffuse", "specular"... used in the shader
  8798. */
  8799. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8800. /**
  8801. * Gets the current status of the fog (should it be enabled?)
  8802. * @param mesh defines the mesh to evaluate for fog support
  8803. * @param scene defines the hosting scene
  8804. * @returns true if fog must be enabled
  8805. */
  8806. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8807. /**
  8808. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8809. * @param mesh defines the current mesh
  8810. * @param scene defines the current scene
  8811. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8812. * @param pointsCloud defines if point cloud rendering has to be turned on
  8813. * @param fogEnabled defines if fog has to be turned on
  8814. * @param alphaTest defines if alpha testing has to be turned on
  8815. * @param defines defines the current list of defines
  8816. */
  8817. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8818. /**
  8819. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8820. * @param scene defines the current scene
  8821. * @param engine defines the current engine
  8822. * @param defines specifies the list of active defines
  8823. * @param useInstances defines if instances have to be turned on
  8824. * @param useClipPlane defines if clip plane have to be turned on
  8825. */
  8826. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8827. /**
  8828. * Prepares the defines for bones
  8829. * @param mesh The mesh containing the geometry data we will draw
  8830. * @param defines The defines to update
  8831. */
  8832. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8833. /**
  8834. * Prepares the defines for morph targets
  8835. * @param mesh The mesh containing the geometry data we will draw
  8836. * @param defines The defines to update
  8837. */
  8838. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8839. /**
  8840. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8841. * @param mesh The mesh containing the geometry data we will draw
  8842. * @param defines The defines to update
  8843. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8844. * @param useBones Precise whether bones should be used or not (override mesh info)
  8845. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8846. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8847. * @returns false if defines are considered not dirty and have not been checked
  8848. */
  8849. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8850. /**
  8851. * Prepares the defines related to multiview
  8852. * @param scene The scene we are intending to draw
  8853. * @param defines The defines to update
  8854. */
  8855. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8856. /**
  8857. * Prepares the defines related to the light information passed in parameter
  8858. * @param scene The scene we are intending to draw
  8859. * @param mesh The mesh the effect is compiling for
  8860. * @param light The light the effect is compiling for
  8861. * @param lightIndex The index of the light
  8862. * @param defines The defines to update
  8863. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8864. * @param state Defines the current state regarding what is needed (normals, etc...)
  8865. */
  8866. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8867. needNormals: boolean;
  8868. needRebuild: boolean;
  8869. shadowEnabled: boolean;
  8870. specularEnabled: boolean;
  8871. lightmapMode: boolean;
  8872. }): void;
  8873. /**
  8874. * Prepares the defines related to the light information passed in parameter
  8875. * @param scene The scene we are intending to draw
  8876. * @param mesh The mesh the effect is compiling for
  8877. * @param defines The defines to update
  8878. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8879. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8880. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8881. * @returns true if normals will be required for the rest of the effect
  8882. */
  8883. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8884. /**
  8885. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8886. * @param lightIndex defines the light index
  8887. * @param uniformsList The uniform list
  8888. * @param samplersList The sampler list
  8889. * @param projectedLightTexture defines if projected texture must be used
  8890. * @param uniformBuffersList defines an optional list of uniform buffers
  8891. */
  8892. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8893. /**
  8894. * Prepares the uniforms and samplers list to be used in the effect
  8895. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8896. * @param samplersList The sampler list
  8897. * @param defines The defines helping in the list generation
  8898. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8899. */
  8900. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8901. /**
  8902. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8903. * @param defines The defines to update while falling back
  8904. * @param fallbacks The authorized effect fallbacks
  8905. * @param maxSimultaneousLights The maximum number of lights allowed
  8906. * @param rank the current rank of the Effect
  8907. * @returns The newly affected rank
  8908. */
  8909. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  8910. private static _TmpMorphInfluencers;
  8911. /**
  8912. * Prepares the list of attributes required for morph targets according to the effect defines.
  8913. * @param attribs The current list of supported attribs
  8914. * @param mesh The mesh to prepare the morph targets attributes for
  8915. * @param influencers The number of influencers
  8916. */
  8917. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  8918. /**
  8919. * Prepares the list of attributes required for morph targets according to the effect defines.
  8920. * @param attribs The current list of supported attribs
  8921. * @param mesh The mesh to prepare the morph targets attributes for
  8922. * @param defines The current Defines of the effect
  8923. */
  8924. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  8925. /**
  8926. * Prepares the list of attributes required for bones according to the effect defines.
  8927. * @param attribs The current list of supported attribs
  8928. * @param mesh The mesh to prepare the bones attributes for
  8929. * @param defines The current Defines of the effect
  8930. * @param fallbacks The current efffect fallback strategy
  8931. */
  8932. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  8933. /**
  8934. * Check and prepare the list of attributes required for instances according to the effect defines.
  8935. * @param attribs The current list of supported attribs
  8936. * @param defines The current MaterialDefines of the effect
  8937. */
  8938. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  8939. /**
  8940. * Add the list of attributes required for instances to the attribs array.
  8941. * @param attribs The current list of supported attribs
  8942. */
  8943. static PushAttributesForInstances(attribs: string[]): void;
  8944. /**
  8945. * Binds the light information to the effect.
  8946. * @param light The light containing the generator
  8947. * @param effect The effect we are binding the data to
  8948. * @param lightIndex The light index in the effect used to render
  8949. */
  8950. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  8951. /**
  8952. * Binds the lights information from the scene to the effect for the given mesh.
  8953. * @param light Light to bind
  8954. * @param lightIndex Light index
  8955. * @param scene The scene where the light belongs to
  8956. * @param effect The effect we are binding the data to
  8957. * @param useSpecular Defines if specular is supported
  8958. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8959. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8960. */
  8961. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  8962. /**
  8963. * Binds the lights information from the scene to the effect for the given mesh.
  8964. * @param scene The scene the lights belongs to
  8965. * @param mesh The mesh we are binding the information to render
  8966. * @param effect The effect we are binding the data to
  8967. * @param defines The generated defines for the effect
  8968. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  8969. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8970. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8971. */
  8972. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  8973. private static _tempFogColor;
  8974. /**
  8975. * Binds the fog information from the scene to the effect for the given mesh.
  8976. * @param scene The scene the lights belongs to
  8977. * @param mesh The mesh we are binding the information to render
  8978. * @param effect The effect we are binding the data to
  8979. * @param linearSpace Defines if the fog effect is applied in linear space
  8980. */
  8981. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  8982. /**
  8983. * Binds the bones information from the mesh to the effect.
  8984. * @param mesh The mesh we are binding the information to render
  8985. * @param effect The effect we are binding the data to
  8986. */
  8987. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  8988. /**
  8989. * Binds the morph targets information from the mesh to the effect.
  8990. * @param abstractMesh The mesh we are binding the information to render
  8991. * @param effect The effect we are binding the data to
  8992. */
  8993. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  8994. /**
  8995. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  8996. * @param defines The generated defines used in the effect
  8997. * @param effect The effect we are binding the data to
  8998. * @param scene The scene we are willing to render with logarithmic scale for
  8999. */
  9000. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9001. /**
  9002. * Binds the clip plane information from the scene to the effect.
  9003. * @param scene The scene the clip plane information are extracted from
  9004. * @param effect The effect we are binding the data to
  9005. */
  9006. static BindClipPlane(effect: Effect, scene: Scene): void;
  9007. }
  9008. }
  9009. declare module BABYLON {
  9010. /** @hidden */
  9011. export var packingFunctions: {
  9012. name: string;
  9013. shader: string;
  9014. };
  9015. }
  9016. declare module BABYLON {
  9017. /** @hidden */
  9018. export var shadowMapPixelShader: {
  9019. name: string;
  9020. shader: string;
  9021. };
  9022. }
  9023. declare module BABYLON {
  9024. /** @hidden */
  9025. export var bonesDeclaration: {
  9026. name: string;
  9027. shader: string;
  9028. };
  9029. }
  9030. declare module BABYLON {
  9031. /** @hidden */
  9032. export var morphTargetsVertexGlobalDeclaration: {
  9033. name: string;
  9034. shader: string;
  9035. };
  9036. }
  9037. declare module BABYLON {
  9038. /** @hidden */
  9039. export var morphTargetsVertexDeclaration: {
  9040. name: string;
  9041. shader: string;
  9042. };
  9043. }
  9044. declare module BABYLON {
  9045. /** @hidden */
  9046. export var instancesDeclaration: {
  9047. name: string;
  9048. shader: string;
  9049. };
  9050. }
  9051. declare module BABYLON {
  9052. /** @hidden */
  9053. export var helperFunctions: {
  9054. name: string;
  9055. shader: string;
  9056. };
  9057. }
  9058. declare module BABYLON {
  9059. /** @hidden */
  9060. export var morphTargetsVertex: {
  9061. name: string;
  9062. shader: string;
  9063. };
  9064. }
  9065. declare module BABYLON {
  9066. /** @hidden */
  9067. export var instancesVertex: {
  9068. name: string;
  9069. shader: string;
  9070. };
  9071. }
  9072. declare module BABYLON {
  9073. /** @hidden */
  9074. export var bonesVertex: {
  9075. name: string;
  9076. shader: string;
  9077. };
  9078. }
  9079. declare module BABYLON {
  9080. /** @hidden */
  9081. export var shadowMapVertexShader: {
  9082. name: string;
  9083. shader: string;
  9084. };
  9085. }
  9086. declare module BABYLON {
  9087. /** @hidden */
  9088. export var depthBoxBlurPixelShader: {
  9089. name: string;
  9090. shader: string;
  9091. };
  9092. }
  9093. declare module BABYLON {
  9094. /**
  9095. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9096. */
  9097. export interface ICustomShaderOptions {
  9098. /**
  9099. * Gets or sets the custom shader name to use
  9100. */
  9101. shaderName: string;
  9102. /**
  9103. * The list of attribute names used in the shader
  9104. */
  9105. attributes?: string[];
  9106. /**
  9107. * The list of unifrom names used in the shader
  9108. */
  9109. uniforms?: string[];
  9110. /**
  9111. * The list of sampler names used in the shader
  9112. */
  9113. samplers?: string[];
  9114. /**
  9115. * The list of defines used in the shader
  9116. */
  9117. defines?: string[];
  9118. }
  9119. /**
  9120. * Interface to implement to create a shadow generator compatible with BJS.
  9121. */
  9122. export interface IShadowGenerator {
  9123. /**
  9124. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9125. * @returns The render target texture if present otherwise, null
  9126. */
  9127. getShadowMap(): Nullable<RenderTargetTexture>;
  9128. /**
  9129. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9130. * @returns The render target texture if the shadow map is present otherwise, null
  9131. */
  9132. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9133. /**
  9134. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9135. * @param subMesh The submesh we want to render in the shadow map
  9136. * @param useInstances Defines wether will draw in the map using instances
  9137. * @returns true if ready otherwise, false
  9138. */
  9139. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9140. /**
  9141. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9142. * @param defines Defines of the material we want to update
  9143. * @param lightIndex Index of the light in the enabled light list of the material
  9144. */
  9145. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9146. /**
  9147. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9148. * defined in the generator but impacting the effect).
  9149. * It implies the unifroms available on the materials are the standard BJS ones.
  9150. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9151. * @param effect The effect we are binfing the information for
  9152. */
  9153. bindShadowLight(lightIndex: string, effect: Effect): void;
  9154. /**
  9155. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9156. * (eq to shadow prjection matrix * light transform matrix)
  9157. * @returns The transform matrix used to create the shadow map
  9158. */
  9159. getTransformMatrix(): Matrix;
  9160. /**
  9161. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9162. * Cube and 2D textures for instance.
  9163. */
  9164. recreateShadowMap(): void;
  9165. /**
  9166. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9167. * @param onCompiled Callback triggered at the and of the effects compilation
  9168. * @param options Sets of optional options forcing the compilation with different modes
  9169. */
  9170. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9171. useInstances: boolean;
  9172. }>): void;
  9173. /**
  9174. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9175. * @param options Sets of optional options forcing the compilation with different modes
  9176. * @returns A promise that resolves when the compilation completes
  9177. */
  9178. forceCompilationAsync(options?: Partial<{
  9179. useInstances: boolean;
  9180. }>): Promise<void>;
  9181. /**
  9182. * Serializes the shadow generator setup to a json object.
  9183. * @returns The serialized JSON object
  9184. */
  9185. serialize(): any;
  9186. /**
  9187. * Disposes the Shadow map and related Textures and effects.
  9188. */
  9189. dispose(): void;
  9190. }
  9191. /**
  9192. * Default implementation IShadowGenerator.
  9193. * This is the main object responsible of generating shadows in the framework.
  9194. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9195. */
  9196. export class ShadowGenerator implements IShadowGenerator {
  9197. /**
  9198. * Shadow generator mode None: no filtering applied.
  9199. */
  9200. static readonly FILTER_NONE: number;
  9201. /**
  9202. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9203. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9204. */
  9205. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9206. /**
  9207. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9208. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9209. */
  9210. static readonly FILTER_POISSONSAMPLING: number;
  9211. /**
  9212. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9213. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9214. */
  9215. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9216. /**
  9217. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9218. * edge artifacts on steep falloff.
  9219. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9220. */
  9221. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9222. /**
  9223. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9224. * edge artifacts on steep falloff.
  9225. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9226. */
  9227. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9228. /**
  9229. * Shadow generator mode PCF: Percentage Closer Filtering
  9230. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9231. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9232. */
  9233. static readonly FILTER_PCF: number;
  9234. /**
  9235. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9236. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9237. * Contact Hardening
  9238. */
  9239. static readonly FILTER_PCSS: number;
  9240. /**
  9241. * Reserved for PCF and PCSS
  9242. * Highest Quality.
  9243. *
  9244. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9245. *
  9246. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9247. */
  9248. static readonly QUALITY_HIGH: number;
  9249. /**
  9250. * Reserved for PCF and PCSS
  9251. * Good tradeoff for quality/perf cross devices
  9252. *
  9253. * Execute PCF on a 3*3 kernel.
  9254. *
  9255. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9256. */
  9257. static readonly QUALITY_MEDIUM: number;
  9258. /**
  9259. * Reserved for PCF and PCSS
  9260. * The lowest quality but the fastest.
  9261. *
  9262. * Execute PCF on a 1*1 kernel.
  9263. *
  9264. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9265. */
  9266. static readonly QUALITY_LOW: number;
  9267. /** Gets or sets the custom shader name to use */
  9268. customShaderOptions: ICustomShaderOptions;
  9269. /**
  9270. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9271. */
  9272. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9273. /**
  9274. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9275. */
  9276. onAfterShadowMapRenderObservable: Observable<Effect>;
  9277. /**
  9278. * Observable triggered before a mesh is rendered in the shadow map.
  9279. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9280. */
  9281. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9282. /**
  9283. * Observable triggered after a mesh is rendered in the shadow map.
  9284. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9285. */
  9286. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9287. private _bias;
  9288. /**
  9289. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9290. */
  9291. /**
  9292. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9293. */
  9294. bias: number;
  9295. private _normalBias;
  9296. /**
  9297. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9298. */
  9299. /**
  9300. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9301. */
  9302. normalBias: number;
  9303. private _blurBoxOffset;
  9304. /**
  9305. * Gets the blur box offset: offset applied during the blur pass.
  9306. * Only useful if useKernelBlur = false
  9307. */
  9308. /**
  9309. * Sets the blur box offset: offset applied during the blur pass.
  9310. * Only useful if useKernelBlur = false
  9311. */
  9312. blurBoxOffset: number;
  9313. private _blurScale;
  9314. /**
  9315. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9316. * 2 means half of the size.
  9317. */
  9318. /**
  9319. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9320. * 2 means half of the size.
  9321. */
  9322. blurScale: number;
  9323. private _blurKernel;
  9324. /**
  9325. * Gets the blur kernel: kernel size of the blur pass.
  9326. * Only useful if useKernelBlur = true
  9327. */
  9328. /**
  9329. * Sets the blur kernel: kernel size of the blur pass.
  9330. * Only useful if useKernelBlur = true
  9331. */
  9332. blurKernel: number;
  9333. private _useKernelBlur;
  9334. /**
  9335. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9336. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9337. */
  9338. /**
  9339. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9340. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9341. */
  9342. useKernelBlur: boolean;
  9343. private _depthScale;
  9344. /**
  9345. * Gets the depth scale used in ESM mode.
  9346. */
  9347. /**
  9348. * Sets the depth scale used in ESM mode.
  9349. * This can override the scale stored on the light.
  9350. */
  9351. depthScale: number;
  9352. private _filter;
  9353. /**
  9354. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9355. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9356. */
  9357. /**
  9358. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9359. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9360. */
  9361. filter: number;
  9362. /**
  9363. * Gets if the current filter is set to Poisson Sampling.
  9364. */
  9365. /**
  9366. * Sets the current filter to Poisson Sampling.
  9367. */
  9368. usePoissonSampling: boolean;
  9369. /**
  9370. * Gets if the current filter is set to ESM.
  9371. */
  9372. /**
  9373. * Sets the current filter is to ESM.
  9374. */
  9375. useExponentialShadowMap: boolean;
  9376. /**
  9377. * Gets if the current filter is set to filtered ESM.
  9378. */
  9379. /**
  9380. * Gets if the current filter is set to filtered ESM.
  9381. */
  9382. useBlurExponentialShadowMap: boolean;
  9383. /**
  9384. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9385. * exponential to prevent steep falloff artifacts).
  9386. */
  9387. /**
  9388. * Sets the current filter to "close ESM" (using the inverse of the
  9389. * exponential to prevent steep falloff artifacts).
  9390. */
  9391. useCloseExponentialShadowMap: boolean;
  9392. /**
  9393. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9394. * exponential to prevent steep falloff artifacts).
  9395. */
  9396. /**
  9397. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9398. * exponential to prevent steep falloff artifacts).
  9399. */
  9400. useBlurCloseExponentialShadowMap: boolean;
  9401. /**
  9402. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9403. */
  9404. /**
  9405. * Sets the current filter to "PCF" (percentage closer filtering).
  9406. */
  9407. usePercentageCloserFiltering: boolean;
  9408. private _filteringQuality;
  9409. /**
  9410. * Gets the PCF or PCSS Quality.
  9411. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9412. */
  9413. /**
  9414. * Sets the PCF or PCSS Quality.
  9415. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9416. */
  9417. filteringQuality: number;
  9418. /**
  9419. * Gets if the current filter is set to "PCSS" (contact hardening).
  9420. */
  9421. /**
  9422. * Sets the current filter to "PCSS" (contact hardening).
  9423. */
  9424. useContactHardeningShadow: boolean;
  9425. private _contactHardeningLightSizeUVRatio;
  9426. /**
  9427. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9428. * Using a ratio helps keeping shape stability independently of the map size.
  9429. *
  9430. * It does not account for the light projection as it was having too much
  9431. * instability during the light setup or during light position changes.
  9432. *
  9433. * Only valid if useContactHardeningShadow is true.
  9434. */
  9435. /**
  9436. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9437. * Using a ratio helps keeping shape stability independently of the map size.
  9438. *
  9439. * It does not account for the light projection as it was having too much
  9440. * instability during the light setup or during light position changes.
  9441. *
  9442. * Only valid if useContactHardeningShadow is true.
  9443. */
  9444. contactHardeningLightSizeUVRatio: number;
  9445. private _darkness;
  9446. /** Gets or sets the actual darkness of a shadow */
  9447. darkness: number;
  9448. /**
  9449. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9450. * 0 means strongest and 1 would means no shadow.
  9451. * @returns the darkness.
  9452. */
  9453. getDarkness(): number;
  9454. /**
  9455. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9456. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9457. * @returns the shadow generator allowing fluent coding.
  9458. */
  9459. setDarkness(darkness: number): ShadowGenerator;
  9460. private _transparencyShadow;
  9461. /** Gets or sets the ability to have transparent shadow */
  9462. transparencyShadow: boolean;
  9463. /**
  9464. * Sets the ability to have transparent shadow (boolean).
  9465. * @param transparent True if transparent else False
  9466. * @returns the shadow generator allowing fluent coding
  9467. */
  9468. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9469. private _shadowMap;
  9470. private _shadowMap2;
  9471. /**
  9472. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9473. * @returns The render target texture if present otherwise, null
  9474. */
  9475. getShadowMap(): Nullable<RenderTargetTexture>;
  9476. /**
  9477. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9478. * @returns The render target texture if the shadow map is present otherwise, null
  9479. */
  9480. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9481. /**
  9482. * Gets the class name of that object
  9483. * @returns "ShadowGenerator"
  9484. */
  9485. getClassName(): string;
  9486. /**
  9487. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9488. * @param mesh Mesh to add
  9489. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9490. * @returns the Shadow Generator itself
  9491. */
  9492. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9493. /**
  9494. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9495. * @param mesh Mesh to remove
  9496. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9497. * @returns the Shadow Generator itself
  9498. */
  9499. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9500. /**
  9501. * Controls the extent to which the shadows fade out at the edge of the frustum
  9502. * Used only by directionals and spots
  9503. */
  9504. frustumEdgeFalloff: number;
  9505. private _light;
  9506. /**
  9507. * Returns the associated light object.
  9508. * @returns the light generating the shadow
  9509. */
  9510. getLight(): IShadowLight;
  9511. /**
  9512. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9513. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9514. * It might on the other hand introduce peter panning.
  9515. */
  9516. forceBackFacesOnly: boolean;
  9517. private _scene;
  9518. private _lightDirection;
  9519. private _effect;
  9520. private _viewMatrix;
  9521. private _projectionMatrix;
  9522. private _transformMatrix;
  9523. private _cachedPosition;
  9524. private _cachedDirection;
  9525. private _cachedDefines;
  9526. private _currentRenderID;
  9527. private _boxBlurPostprocess;
  9528. private _kernelBlurXPostprocess;
  9529. private _kernelBlurYPostprocess;
  9530. private _blurPostProcesses;
  9531. private _mapSize;
  9532. private _currentFaceIndex;
  9533. private _currentFaceIndexCache;
  9534. private _textureType;
  9535. private _defaultTextureMatrix;
  9536. private _storedUniqueId;
  9537. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  9538. /**
  9539. * Creates a ShadowGenerator object.
  9540. * A ShadowGenerator is the required tool to use the shadows.
  9541. * Each light casting shadows needs to use its own ShadowGenerator.
  9542. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9543. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9544. * @param light The light object generating the shadows.
  9545. * @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.
  9546. */
  9547. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9548. private _initializeGenerator;
  9549. private _initializeShadowMap;
  9550. private _initializeBlurRTTAndPostProcesses;
  9551. private _renderForShadowMap;
  9552. private _renderSubMeshForShadowMap;
  9553. private _applyFilterValues;
  9554. /**
  9555. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9556. * @param onCompiled Callback triggered at the and of the effects compilation
  9557. * @param options Sets of optional options forcing the compilation with different modes
  9558. */
  9559. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9560. useInstances: boolean;
  9561. }>): void;
  9562. /**
  9563. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9564. * @param options Sets of optional options forcing the compilation with different modes
  9565. * @returns A promise that resolves when the compilation completes
  9566. */
  9567. forceCompilationAsync(options?: Partial<{
  9568. useInstances: boolean;
  9569. }>): Promise<void>;
  9570. /**
  9571. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9572. * @param subMesh The submesh we want to render in the shadow map
  9573. * @param useInstances Defines wether will draw in the map using instances
  9574. * @returns true if ready otherwise, false
  9575. */
  9576. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9577. /**
  9578. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9579. * @param defines Defines of the material we want to update
  9580. * @param lightIndex Index of the light in the enabled light list of the material
  9581. */
  9582. prepareDefines(defines: any, lightIndex: number): void;
  9583. /**
  9584. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9585. * defined in the generator but impacting the effect).
  9586. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9587. * @param effect The effect we are binfing the information for
  9588. */
  9589. bindShadowLight(lightIndex: string, effect: Effect): void;
  9590. /**
  9591. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9592. * (eq to shadow prjection matrix * light transform matrix)
  9593. * @returns The transform matrix used to create the shadow map
  9594. */
  9595. getTransformMatrix(): Matrix;
  9596. /**
  9597. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9598. * Cube and 2D textures for instance.
  9599. */
  9600. recreateShadowMap(): void;
  9601. private _disposeBlurPostProcesses;
  9602. private _disposeRTTandPostProcesses;
  9603. /**
  9604. * Disposes the ShadowGenerator.
  9605. * Returns nothing.
  9606. */
  9607. dispose(): void;
  9608. /**
  9609. * Serializes the shadow generator setup to a json object.
  9610. * @returns The serialized JSON object
  9611. */
  9612. serialize(): any;
  9613. /**
  9614. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9615. * @param parsedShadowGenerator The JSON object to parse
  9616. * @param scene The scene to create the shadow map for
  9617. * @returns The parsed shadow generator
  9618. */
  9619. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9620. }
  9621. }
  9622. declare module BABYLON {
  9623. /**
  9624. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9625. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9626. * 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.
  9627. */
  9628. export abstract class Light extends Node {
  9629. /**
  9630. * Falloff Default: light is falling off following the material specification:
  9631. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9632. */
  9633. static readonly FALLOFF_DEFAULT: number;
  9634. /**
  9635. * Falloff Physical: light is falling off following the inverse squared distance law.
  9636. */
  9637. static readonly FALLOFF_PHYSICAL: number;
  9638. /**
  9639. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9640. * to enhance interoperability with other engines.
  9641. */
  9642. static readonly FALLOFF_GLTF: number;
  9643. /**
  9644. * Falloff Standard: light is falling off like in the standard material
  9645. * to enhance interoperability with other materials.
  9646. */
  9647. static readonly FALLOFF_STANDARD: number;
  9648. /**
  9649. * If every light affecting the material is in this lightmapMode,
  9650. * material.lightmapTexture adds or multiplies
  9651. * (depends on material.useLightmapAsShadowmap)
  9652. * after every other light calculations.
  9653. */
  9654. static readonly LIGHTMAP_DEFAULT: number;
  9655. /**
  9656. * material.lightmapTexture as only diffuse lighting from this light
  9657. * adds only specular lighting from this light
  9658. * adds dynamic shadows
  9659. */
  9660. static readonly LIGHTMAP_SPECULAR: number;
  9661. /**
  9662. * material.lightmapTexture as only lighting
  9663. * no light calculation from this light
  9664. * only adds dynamic shadows from this light
  9665. */
  9666. static readonly LIGHTMAP_SHADOWSONLY: number;
  9667. /**
  9668. * Each light type uses the default quantity according to its type:
  9669. * point/spot lights use luminous intensity
  9670. * directional lights use illuminance
  9671. */
  9672. static readonly INTENSITYMODE_AUTOMATIC: number;
  9673. /**
  9674. * lumen (lm)
  9675. */
  9676. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9677. /**
  9678. * candela (lm/sr)
  9679. */
  9680. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9681. /**
  9682. * lux (lm/m^2)
  9683. */
  9684. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9685. /**
  9686. * nit (cd/m^2)
  9687. */
  9688. static readonly INTENSITYMODE_LUMINANCE: number;
  9689. /**
  9690. * Light type const id of the point light.
  9691. */
  9692. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9693. /**
  9694. * Light type const id of the directional light.
  9695. */
  9696. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9697. /**
  9698. * Light type const id of the spot light.
  9699. */
  9700. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9701. /**
  9702. * Light type const id of the hemispheric light.
  9703. */
  9704. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9705. /**
  9706. * Diffuse gives the basic color to an object.
  9707. */
  9708. diffuse: Color3;
  9709. /**
  9710. * Specular produces a highlight color on an object.
  9711. * Note: This is note affecting PBR materials.
  9712. */
  9713. specular: Color3;
  9714. /**
  9715. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9716. * falling off base on range or angle.
  9717. * This can be set to any values in Light.FALLOFF_x.
  9718. *
  9719. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9720. * other types of materials.
  9721. */
  9722. falloffType: number;
  9723. /**
  9724. * Strength of the light.
  9725. * Note: By default it is define in the framework own unit.
  9726. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9727. */
  9728. intensity: number;
  9729. private _range;
  9730. protected _inverseSquaredRange: number;
  9731. /**
  9732. * Defines how far from the source the light is impacting in scene units.
  9733. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9734. */
  9735. /**
  9736. * Defines how far from the source the light is impacting in scene units.
  9737. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9738. */
  9739. range: number;
  9740. /**
  9741. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9742. * of light.
  9743. */
  9744. private _photometricScale;
  9745. private _intensityMode;
  9746. /**
  9747. * Gets the photometric scale used to interpret the intensity.
  9748. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9749. */
  9750. /**
  9751. * Sets the photometric scale used to interpret the intensity.
  9752. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9753. */
  9754. intensityMode: number;
  9755. private _radius;
  9756. /**
  9757. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9758. */
  9759. /**
  9760. * sets the light radius used by PBR Materials to simulate soft area lights.
  9761. */
  9762. radius: number;
  9763. private _renderPriority;
  9764. /**
  9765. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9766. * exceeding the number allowed of the materials.
  9767. */
  9768. renderPriority: number;
  9769. private _shadowEnabled;
  9770. /**
  9771. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9772. * the current shadow generator.
  9773. */
  9774. /**
  9775. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9776. * the current shadow generator.
  9777. */
  9778. shadowEnabled: boolean;
  9779. private _includedOnlyMeshes;
  9780. /**
  9781. * Gets the only meshes impacted by this light.
  9782. */
  9783. /**
  9784. * Sets the only meshes impacted by this light.
  9785. */
  9786. includedOnlyMeshes: AbstractMesh[];
  9787. private _excludedMeshes;
  9788. /**
  9789. * Gets the meshes not impacted by this light.
  9790. */
  9791. /**
  9792. * Sets the meshes not impacted by this light.
  9793. */
  9794. excludedMeshes: AbstractMesh[];
  9795. private _excludeWithLayerMask;
  9796. /**
  9797. * Gets the layer id use to find what meshes are not impacted by the light.
  9798. * Inactive if 0
  9799. */
  9800. /**
  9801. * Sets the layer id use to find what meshes are not impacted by the light.
  9802. * Inactive if 0
  9803. */
  9804. excludeWithLayerMask: number;
  9805. private _includeOnlyWithLayerMask;
  9806. /**
  9807. * Gets the layer id use to find what meshes are impacted by the light.
  9808. * Inactive if 0
  9809. */
  9810. /**
  9811. * Sets the layer id use to find what meshes are impacted by the light.
  9812. * Inactive if 0
  9813. */
  9814. includeOnlyWithLayerMask: number;
  9815. private _lightmapMode;
  9816. /**
  9817. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9818. */
  9819. /**
  9820. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9821. */
  9822. lightmapMode: number;
  9823. /**
  9824. * Shadow generator associted to the light.
  9825. * @hidden Internal use only.
  9826. */ private _shadowGenerator: Nullable<IShadowGenerator>;
  9827. /**
  9828. * @hidden Internal use only.
  9829. */ private _excludedMeshesIds: string[];
  9830. /**
  9831. * @hidden Internal use only.
  9832. */ private _includedOnlyMeshesIds: string[];
  9833. /**
  9834. * The current light unifom buffer.
  9835. * @hidden Internal use only.
  9836. */ private _uniformBuffer: UniformBuffer;
  9837. /** @hidden */ private _renderId: number;
  9838. /**
  9839. * Creates a Light object in the scene.
  9840. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9841. * @param name The firendly name of the light
  9842. * @param scene The scene the light belongs too
  9843. */
  9844. constructor(name: string, scene: Scene);
  9845. protected abstract _buildUniformLayout(): void;
  9846. /**
  9847. * Sets the passed Effect "effect" with the Light information.
  9848. * @param effect The effect to update
  9849. * @param lightIndex The index of the light in the effect to update
  9850. * @returns The light
  9851. */
  9852. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9853. /**
  9854. * Sets the passed Effect "effect" with the Light information.
  9855. * @param effect The effect to update
  9856. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9857. * @returns The light
  9858. */
  9859. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9860. /**
  9861. * Returns the string "Light".
  9862. * @returns the class name
  9863. */
  9864. getClassName(): string;
  9865. /** @hidden */ protected readonly _isLight: boolean;
  9866. /**
  9867. * Converts the light information to a readable string for debug purpose.
  9868. * @param fullDetails Supports for multiple levels of logging within scene loading
  9869. * @returns the human readable light info
  9870. */
  9871. toString(fullDetails?: boolean): string;
  9872. /** @hidden */
  9873. protected _syncParentEnabledState(): void;
  9874. /**
  9875. * Set the enabled state of this node.
  9876. * @param value - the new enabled state
  9877. */
  9878. setEnabled(value: boolean): void;
  9879. /**
  9880. * Returns the Light associated shadow generator if any.
  9881. * @return the associated shadow generator.
  9882. */
  9883. getShadowGenerator(): Nullable<IShadowGenerator>;
  9884. /**
  9885. * Returns a Vector3, the absolute light position in the World.
  9886. * @returns the world space position of the light
  9887. */
  9888. getAbsolutePosition(): Vector3;
  9889. /**
  9890. * Specifies if the light will affect the passed mesh.
  9891. * @param mesh The mesh to test against the light
  9892. * @return true the mesh is affected otherwise, false.
  9893. */
  9894. canAffectMesh(mesh: AbstractMesh): boolean;
  9895. /**
  9896. * Sort function to order lights for rendering.
  9897. * @param a First Light object to compare to second.
  9898. * @param b Second Light object to compare first.
  9899. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9900. */
  9901. static CompareLightsPriority(a: Light, b: Light): number;
  9902. /**
  9903. * Releases resources associated with this node.
  9904. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9905. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9906. */
  9907. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9908. /**
  9909. * Returns the light type ID (integer).
  9910. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9911. */
  9912. getTypeID(): number;
  9913. /**
  9914. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9915. * @returns the scaled intensity in intensity mode unit
  9916. */
  9917. getScaledIntensity(): number;
  9918. /**
  9919. * Returns a new Light object, named "name", from the current one.
  9920. * @param name The name of the cloned light
  9921. * @returns the new created light
  9922. */
  9923. clone(name: string): Nullable<Light>;
  9924. /**
  9925. * Serializes the current light into a Serialization object.
  9926. * @returns the serialized object.
  9927. */
  9928. serialize(): any;
  9929. /**
  9930. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9931. * This new light is named "name" and added to the passed scene.
  9932. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9933. * @param name The friendly name of the light
  9934. * @param scene The scene the new light will belong to
  9935. * @returns the constructor function
  9936. */
  9937. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9938. /**
  9939. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9940. * @param parsedLight The JSON representation of the light
  9941. * @param scene The scene to create the parsed light in
  9942. * @returns the created light after parsing
  9943. */
  9944. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9945. private _hookArrayForExcluded;
  9946. private _hookArrayForIncludedOnly;
  9947. private _resyncMeshes;
  9948. /**
  9949. * Forces the meshes to update their light related information in their rendering used effects
  9950. * @hidden Internal Use Only
  9951. */ private _markMeshesAsLightDirty(): void;
  9952. /**
  9953. * Recomputes the cached photometric scale if needed.
  9954. */
  9955. private _computePhotometricScale;
  9956. /**
  9957. * Returns the Photometric Scale according to the light type and intensity mode.
  9958. */
  9959. private _getPhotometricScale;
  9960. /**
  9961. * Reorder the light in the scene according to their defined priority.
  9962. * @hidden Internal Use Only
  9963. */ private _reorderLightsInScene(): void;
  9964. /**
  9965. * Prepares the list of defines specific to the light type.
  9966. * @param defines the list of defines
  9967. * @param lightIndex defines the index of the light for the effect
  9968. */
  9969. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9970. }
  9971. }
  9972. declare module BABYLON {
  9973. /**
  9974. * Interface used to define Action
  9975. */
  9976. export interface IAction {
  9977. /**
  9978. * Trigger for the action
  9979. */
  9980. trigger: number;
  9981. /** Options of the trigger */
  9982. triggerOptions: any;
  9983. /**
  9984. * Gets the trigger parameters
  9985. * @returns the trigger parameters
  9986. */
  9987. getTriggerParameter(): any;
  9988. /**
  9989. * Internal only - executes current action event
  9990. * @hidden
  9991. */ private _executeCurrent(evt?: ActionEvent): void;
  9992. /**
  9993. * Serialize placeholder for child classes
  9994. * @param parent of child
  9995. * @returns the serialized object
  9996. */
  9997. serialize(parent: any): any;
  9998. /**
  9999. * Internal only
  10000. * @hidden
  10001. */ private _prepare(): void;
  10002. /**
  10003. * Internal only - manager for action
  10004. * @hidden
  10005. */ private _actionManager: AbstractActionManager;
  10006. /**
  10007. * Adds action to chain of actions, may be a DoNothingAction
  10008. * @param action defines the next action to execute
  10009. * @returns The action passed in
  10010. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10011. */
  10012. then(action: IAction): IAction;
  10013. }
  10014. /**
  10015. * The action to be carried out following a trigger
  10016. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10017. */
  10018. export class Action implements IAction {
  10019. /** the trigger, with or without parameters, for the action */
  10020. triggerOptions: any;
  10021. /**
  10022. * Trigger for the action
  10023. */
  10024. trigger: number;
  10025. /**
  10026. * Internal only - manager for action
  10027. * @hidden
  10028. */ private _actionManager: ActionManager;
  10029. private _nextActiveAction;
  10030. private _child;
  10031. private _condition?;
  10032. private _triggerParameter;
  10033. /**
  10034. * An event triggered prior to action being executed.
  10035. */
  10036. onBeforeExecuteObservable: Observable<Action>;
  10037. /**
  10038. * Creates a new Action
  10039. * @param triggerOptions the trigger, with or without parameters, for the action
  10040. * @param condition an optional determinant of action
  10041. */
  10042. constructor(
  10043. /** the trigger, with or without parameters, for the action */
  10044. triggerOptions: any, condition?: Condition);
  10045. /**
  10046. * Internal only
  10047. * @hidden
  10048. */ private _prepare(): void;
  10049. /**
  10050. * Gets the trigger parameters
  10051. * @returns the trigger parameters
  10052. */
  10053. getTriggerParameter(): any;
  10054. /**
  10055. * Internal only - executes current action event
  10056. * @hidden
  10057. */ private _executeCurrent(evt?: ActionEvent): void;
  10058. /**
  10059. * Execute placeholder for child classes
  10060. * @param evt optional action event
  10061. */
  10062. execute(evt?: ActionEvent): void;
  10063. /**
  10064. * Skips to next active action
  10065. */
  10066. skipToNextActiveAction(): void;
  10067. /**
  10068. * Adds action to chain of actions, may be a DoNothingAction
  10069. * @param action defines the next action to execute
  10070. * @returns The action passed in
  10071. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10072. */
  10073. then(action: Action): Action;
  10074. /**
  10075. * Internal only
  10076. * @hidden
  10077. */ private _getProperty(propertyPath: string): string;
  10078. /**
  10079. * Internal only
  10080. * @hidden
  10081. */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10082. /**
  10083. * Serialize placeholder for child classes
  10084. * @param parent of child
  10085. * @returns the serialized object
  10086. */
  10087. serialize(parent: any): any;
  10088. /**
  10089. * Internal only called by serialize
  10090. * @hidden
  10091. */
  10092. protected _serialize(serializedAction: any, parent?: any): any;
  10093. /**
  10094. * Internal only
  10095. * @hidden
  10096. */ private static _SerializeValueAsString: (value: any) => string;
  10097. /**
  10098. * Internal only
  10099. * @hidden
  10100. */ private static _GetTargetProperty: (target: Node | Scene) => {
  10101. name: string;
  10102. targetType: string;
  10103. value: string;
  10104. };
  10105. }
  10106. }
  10107. declare module BABYLON {
  10108. /**
  10109. * A Condition applied to an Action
  10110. */
  10111. export class Condition {
  10112. /**
  10113. * Internal only - manager for action
  10114. * @hidden
  10115. */ private _actionManager: ActionManager;
  10116. /**
  10117. * Internal only
  10118. * @hidden
  10119. */ private _evaluationId: number;
  10120. /**
  10121. * Internal only
  10122. * @hidden
  10123. */ private _currentResult: boolean;
  10124. /**
  10125. * Creates a new Condition
  10126. * @param actionManager the manager of the action the condition is applied to
  10127. */
  10128. constructor(actionManager: ActionManager);
  10129. /**
  10130. * Check if the current condition is valid
  10131. * @returns a boolean
  10132. */
  10133. isValid(): boolean;
  10134. /**
  10135. * Internal only
  10136. * @hidden
  10137. */ private _getProperty(propertyPath: string): string;
  10138. /**
  10139. * Internal only
  10140. * @hidden
  10141. */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10142. /**
  10143. * Serialize placeholder for child classes
  10144. * @returns the serialized object
  10145. */
  10146. serialize(): any;
  10147. /**
  10148. * Internal only
  10149. * @hidden
  10150. */
  10151. protected _serialize(serializedCondition: any): any;
  10152. }
  10153. /**
  10154. * Defines specific conditional operators as extensions of Condition
  10155. */
  10156. export class ValueCondition extends Condition {
  10157. /** path to specify the property of the target the conditional operator uses */
  10158. propertyPath: string;
  10159. /** the value compared by the conditional operator against the current value of the property */
  10160. value: any;
  10161. /** the conditional operator, default ValueCondition.IsEqual */
  10162. operator: number;
  10163. /**
  10164. * Internal only
  10165. * @hidden
  10166. */
  10167. private static _IsEqual;
  10168. /**
  10169. * Internal only
  10170. * @hidden
  10171. */
  10172. private static _IsDifferent;
  10173. /**
  10174. * Internal only
  10175. * @hidden
  10176. */
  10177. private static _IsGreater;
  10178. /**
  10179. * Internal only
  10180. * @hidden
  10181. */
  10182. private static _IsLesser;
  10183. /**
  10184. * returns the number for IsEqual
  10185. */
  10186. static readonly IsEqual: number;
  10187. /**
  10188. * Returns the number for IsDifferent
  10189. */
  10190. static readonly IsDifferent: number;
  10191. /**
  10192. * Returns the number for IsGreater
  10193. */
  10194. static readonly IsGreater: number;
  10195. /**
  10196. * Returns the number for IsLesser
  10197. */
  10198. static readonly IsLesser: number;
  10199. /**
  10200. * Internal only The action manager for the condition
  10201. * @hidden
  10202. */ private _actionManager: ActionManager;
  10203. /**
  10204. * Internal only
  10205. * @hidden
  10206. */
  10207. private _target;
  10208. /**
  10209. * Internal only
  10210. * @hidden
  10211. */
  10212. private _effectiveTarget;
  10213. /**
  10214. * Internal only
  10215. * @hidden
  10216. */
  10217. private _property;
  10218. /**
  10219. * Creates a new ValueCondition
  10220. * @param actionManager manager for the action the condition applies to
  10221. * @param target for the action
  10222. * @param propertyPath path to specify the property of the target the conditional operator uses
  10223. * @param value the value compared by the conditional operator against the current value of the property
  10224. * @param operator the conditional operator, default ValueCondition.IsEqual
  10225. */
  10226. constructor(actionManager: ActionManager, target: any,
  10227. /** path to specify the property of the target the conditional operator uses */
  10228. propertyPath: string,
  10229. /** the value compared by the conditional operator against the current value of the property */
  10230. value: any,
  10231. /** the conditional operator, default ValueCondition.IsEqual */
  10232. operator?: number);
  10233. /**
  10234. * Compares the given value with the property value for the specified conditional operator
  10235. * @returns the result of the comparison
  10236. */
  10237. isValid(): boolean;
  10238. /**
  10239. * Serialize the ValueCondition into a JSON compatible object
  10240. * @returns serialization object
  10241. */
  10242. serialize(): any;
  10243. /**
  10244. * Gets the name of the conditional operator for the ValueCondition
  10245. * @param operator the conditional operator
  10246. * @returns the name
  10247. */
  10248. static GetOperatorName(operator: number): string;
  10249. }
  10250. /**
  10251. * Defines a predicate condition as an extension of Condition
  10252. */
  10253. export class PredicateCondition extends Condition {
  10254. /** defines the predicate function used to validate the condition */
  10255. predicate: () => boolean;
  10256. /**
  10257. * Internal only - manager for action
  10258. * @hidden
  10259. */ private _actionManager: ActionManager;
  10260. /**
  10261. * Creates a new PredicateCondition
  10262. * @param actionManager manager for the action the condition applies to
  10263. * @param predicate defines the predicate function used to validate the condition
  10264. */
  10265. constructor(actionManager: ActionManager,
  10266. /** defines the predicate function used to validate the condition */
  10267. predicate: () => boolean);
  10268. /**
  10269. * @returns the validity of the predicate condition
  10270. */
  10271. isValid(): boolean;
  10272. }
  10273. /**
  10274. * Defines a state condition as an extension of Condition
  10275. */
  10276. export class StateCondition extends Condition {
  10277. /** Value to compare with target state */
  10278. value: string;
  10279. /**
  10280. * Internal only - manager for action
  10281. * @hidden
  10282. */ private _actionManager: ActionManager;
  10283. /**
  10284. * Internal only
  10285. * @hidden
  10286. */
  10287. private _target;
  10288. /**
  10289. * Creates a new StateCondition
  10290. * @param actionManager manager for the action the condition applies to
  10291. * @param target of the condition
  10292. * @param value to compare with target state
  10293. */
  10294. constructor(actionManager: ActionManager, target: any,
  10295. /** Value to compare with target state */
  10296. value: string);
  10297. /**
  10298. * Gets a boolean indicating if the current condition is met
  10299. * @returns the validity of the state
  10300. */
  10301. isValid(): boolean;
  10302. /**
  10303. * Serialize the StateCondition into a JSON compatible object
  10304. * @returns serialization object
  10305. */
  10306. serialize(): any;
  10307. }
  10308. }
  10309. declare module BABYLON {
  10310. /**
  10311. * This defines an action responsible to toggle a boolean once triggered.
  10312. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10313. */
  10314. export class SwitchBooleanAction extends Action {
  10315. /**
  10316. * The path to the boolean property in the target object
  10317. */
  10318. propertyPath: string;
  10319. private _target;
  10320. private _effectiveTarget;
  10321. private _property;
  10322. /**
  10323. * Instantiate the action
  10324. * @param triggerOptions defines the trigger options
  10325. * @param target defines the object containing the boolean
  10326. * @param propertyPath defines the path to the boolean property in the target object
  10327. * @param condition defines the trigger related conditions
  10328. */
  10329. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10330. /** @hidden */ private _prepare(): void;
  10331. /**
  10332. * Execute the action toggle the boolean value.
  10333. */
  10334. execute(): void;
  10335. /**
  10336. * Serializes the actions and its related information.
  10337. * @param parent defines the object to serialize in
  10338. * @returns the serialized object
  10339. */
  10340. serialize(parent: any): any;
  10341. }
  10342. /**
  10343. * This defines an action responsible to set a the state field of the target
  10344. * to a desired value once triggered.
  10345. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10346. */
  10347. export class SetStateAction extends Action {
  10348. /**
  10349. * The value to store in the state field.
  10350. */
  10351. value: string;
  10352. private _target;
  10353. /**
  10354. * Instantiate the action
  10355. * @param triggerOptions defines the trigger options
  10356. * @param target defines the object containing the state property
  10357. * @param value defines the value to store in the state field
  10358. * @param condition defines the trigger related conditions
  10359. */
  10360. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10361. /**
  10362. * Execute the action and store the value on the target state property.
  10363. */
  10364. execute(): void;
  10365. /**
  10366. * Serializes the actions and its related information.
  10367. * @param parent defines the object to serialize in
  10368. * @returns the serialized object
  10369. */
  10370. serialize(parent: any): any;
  10371. }
  10372. /**
  10373. * This defines an action responsible to set a property of the target
  10374. * to a desired value once triggered.
  10375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10376. */
  10377. export class SetValueAction extends Action {
  10378. /**
  10379. * The path of the property to set in the target.
  10380. */
  10381. propertyPath: string;
  10382. /**
  10383. * The value to set in the property
  10384. */
  10385. value: any;
  10386. private _target;
  10387. private _effectiveTarget;
  10388. private _property;
  10389. /**
  10390. * Instantiate the action
  10391. * @param triggerOptions defines the trigger options
  10392. * @param target defines the object containing the property
  10393. * @param propertyPath defines the path of the property to set in the target
  10394. * @param value defines the value to set in the property
  10395. * @param condition defines the trigger related conditions
  10396. */
  10397. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10398. /** @hidden */ private _prepare(): void;
  10399. /**
  10400. * Execute the action and set the targetted property to the desired value.
  10401. */
  10402. execute(): void;
  10403. /**
  10404. * Serializes the actions and its related information.
  10405. * @param parent defines the object to serialize in
  10406. * @returns the serialized object
  10407. */
  10408. serialize(parent: any): any;
  10409. }
  10410. /**
  10411. * This defines an action responsible to increment the target value
  10412. * to a desired value once triggered.
  10413. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10414. */
  10415. export class IncrementValueAction extends Action {
  10416. /**
  10417. * The path of the property to increment in the target.
  10418. */
  10419. propertyPath: string;
  10420. /**
  10421. * The value we should increment the property by.
  10422. */
  10423. value: any;
  10424. private _target;
  10425. private _effectiveTarget;
  10426. private _property;
  10427. /**
  10428. * Instantiate the action
  10429. * @param triggerOptions defines the trigger options
  10430. * @param target defines the object containing the property
  10431. * @param propertyPath defines the path of the property to increment in the target
  10432. * @param value defines the value value we should increment the property by
  10433. * @param condition defines the trigger related conditions
  10434. */
  10435. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10436. /** @hidden */ private _prepare(): void;
  10437. /**
  10438. * Execute the action and increment the target of the value amount.
  10439. */
  10440. execute(): void;
  10441. /**
  10442. * Serializes the actions and its related information.
  10443. * @param parent defines the object to serialize in
  10444. * @returns the serialized object
  10445. */
  10446. serialize(parent: any): any;
  10447. }
  10448. /**
  10449. * This defines an action responsible to start an animation once triggered.
  10450. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10451. */
  10452. export class PlayAnimationAction extends Action {
  10453. /**
  10454. * Where the animation should start (animation frame)
  10455. */
  10456. from: number;
  10457. /**
  10458. * Where the animation should stop (animation frame)
  10459. */
  10460. to: number;
  10461. /**
  10462. * Define if the animation should loop or stop after the first play.
  10463. */
  10464. loop?: boolean;
  10465. private _target;
  10466. /**
  10467. * Instantiate the action
  10468. * @param triggerOptions defines the trigger options
  10469. * @param target defines the target animation or animation name
  10470. * @param from defines from where the animation should start (animation frame)
  10471. * @param end defines where the animation should stop (animation frame)
  10472. * @param loop defines if the animation should loop or stop after the first play
  10473. * @param condition defines the trigger related conditions
  10474. */
  10475. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10476. /** @hidden */ private _prepare(): void;
  10477. /**
  10478. * Execute the action and play the animation.
  10479. */
  10480. execute(): void;
  10481. /**
  10482. * Serializes the actions and its related information.
  10483. * @param parent defines the object to serialize in
  10484. * @returns the serialized object
  10485. */
  10486. serialize(parent: any): any;
  10487. }
  10488. /**
  10489. * This defines an action responsible to stop an animation once triggered.
  10490. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10491. */
  10492. export class StopAnimationAction extends Action {
  10493. private _target;
  10494. /**
  10495. * Instantiate the action
  10496. * @param triggerOptions defines the trigger options
  10497. * @param target defines the target animation or animation name
  10498. * @param condition defines the trigger related conditions
  10499. */
  10500. constructor(triggerOptions: any, target: any, condition?: Condition);
  10501. /** @hidden */ private _prepare(): void;
  10502. /**
  10503. * Execute the action and stop the animation.
  10504. */
  10505. execute(): void;
  10506. /**
  10507. * Serializes the actions and its related information.
  10508. * @param parent defines the object to serialize in
  10509. * @returns the serialized object
  10510. */
  10511. serialize(parent: any): any;
  10512. }
  10513. /**
  10514. * This defines an action responsible that does nothing once triggered.
  10515. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10516. */
  10517. export class DoNothingAction extends Action {
  10518. /**
  10519. * Instantiate the action
  10520. * @param triggerOptions defines the trigger options
  10521. * @param condition defines the trigger related conditions
  10522. */
  10523. constructor(triggerOptions?: any, condition?: Condition);
  10524. /**
  10525. * Execute the action and do nothing.
  10526. */
  10527. execute(): void;
  10528. /**
  10529. * Serializes the actions and its related information.
  10530. * @param parent defines the object to serialize in
  10531. * @returns the serialized object
  10532. */
  10533. serialize(parent: any): any;
  10534. }
  10535. /**
  10536. * This defines an action responsible to trigger several actions once triggered.
  10537. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10538. */
  10539. export class CombineAction extends Action {
  10540. /**
  10541. * The list of aggregated animations to run.
  10542. */
  10543. children: Action[];
  10544. /**
  10545. * Instantiate the action
  10546. * @param triggerOptions defines the trigger options
  10547. * @param children defines the list of aggregated animations to run
  10548. * @param condition defines the trigger related conditions
  10549. */
  10550. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10551. /** @hidden */ private _prepare(): void;
  10552. /**
  10553. * Execute the action and executes all the aggregated actions.
  10554. */
  10555. execute(evt: ActionEvent): void;
  10556. /**
  10557. * Serializes the actions and its related information.
  10558. * @param parent defines the object to serialize in
  10559. * @returns the serialized object
  10560. */
  10561. serialize(parent: any): any;
  10562. }
  10563. /**
  10564. * This defines an action responsible to run code (external event) once triggered.
  10565. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10566. */
  10567. export class ExecuteCodeAction extends Action {
  10568. /**
  10569. * The callback function to run.
  10570. */
  10571. func: (evt: ActionEvent) => void;
  10572. /**
  10573. * Instantiate the action
  10574. * @param triggerOptions defines the trigger options
  10575. * @param func defines the callback function to run
  10576. * @param condition defines the trigger related conditions
  10577. */
  10578. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10579. /**
  10580. * Execute the action and run the attached code.
  10581. */
  10582. execute(evt: ActionEvent): void;
  10583. }
  10584. /**
  10585. * This defines an action responsible to set the parent property of the target once triggered.
  10586. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10587. */
  10588. export class SetParentAction extends Action {
  10589. private _parent;
  10590. private _target;
  10591. /**
  10592. * Instantiate the action
  10593. * @param triggerOptions defines the trigger options
  10594. * @param target defines the target containing the parent property
  10595. * @param parent defines from where the animation should start (animation frame)
  10596. * @param condition defines the trigger related conditions
  10597. */
  10598. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10599. /** @hidden */ private _prepare(): void;
  10600. /**
  10601. * Execute the action and set the parent property.
  10602. */
  10603. execute(): void;
  10604. /**
  10605. * Serializes the actions and its related information.
  10606. * @param parent defines the object to serialize in
  10607. * @returns the serialized object
  10608. */
  10609. serialize(parent: any): any;
  10610. }
  10611. }
  10612. declare module BABYLON {
  10613. /**
  10614. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10615. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10616. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10617. */
  10618. export class ActionManager extends AbstractActionManager {
  10619. /**
  10620. * Nothing
  10621. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10622. */
  10623. static readonly NothingTrigger: number;
  10624. /**
  10625. * On pick
  10626. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10627. */
  10628. static readonly OnPickTrigger: number;
  10629. /**
  10630. * On left pick
  10631. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10632. */
  10633. static readonly OnLeftPickTrigger: number;
  10634. /**
  10635. * On right pick
  10636. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10637. */
  10638. static readonly OnRightPickTrigger: number;
  10639. /**
  10640. * On center pick
  10641. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10642. */
  10643. static readonly OnCenterPickTrigger: number;
  10644. /**
  10645. * On pick down
  10646. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10647. */
  10648. static readonly OnPickDownTrigger: number;
  10649. /**
  10650. * On double pick
  10651. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10652. */
  10653. static readonly OnDoublePickTrigger: number;
  10654. /**
  10655. * On pick up
  10656. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10657. */
  10658. static readonly OnPickUpTrigger: number;
  10659. /**
  10660. * On pick out.
  10661. * This trigger will only be raised if you also declared a OnPickDown
  10662. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10663. */
  10664. static readonly OnPickOutTrigger: number;
  10665. /**
  10666. * On long press
  10667. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10668. */
  10669. static readonly OnLongPressTrigger: number;
  10670. /**
  10671. * On pointer over
  10672. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10673. */
  10674. static readonly OnPointerOverTrigger: number;
  10675. /**
  10676. * On pointer out
  10677. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10678. */
  10679. static readonly OnPointerOutTrigger: number;
  10680. /**
  10681. * On every frame
  10682. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10683. */
  10684. static readonly OnEveryFrameTrigger: number;
  10685. /**
  10686. * On intersection enter
  10687. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10688. */
  10689. static readonly OnIntersectionEnterTrigger: number;
  10690. /**
  10691. * On intersection exit
  10692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10693. */
  10694. static readonly OnIntersectionExitTrigger: number;
  10695. /**
  10696. * On key down
  10697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10698. */
  10699. static readonly OnKeyDownTrigger: number;
  10700. /**
  10701. * On key up
  10702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10703. */
  10704. static readonly OnKeyUpTrigger: number;
  10705. private _scene;
  10706. /**
  10707. * Creates a new action manager
  10708. * @param scene defines the hosting scene
  10709. */
  10710. constructor(scene: Scene);
  10711. /**
  10712. * Releases all associated resources
  10713. */
  10714. dispose(): void;
  10715. /**
  10716. * Gets hosting scene
  10717. * @returns the hosting scene
  10718. */
  10719. getScene(): Scene;
  10720. /**
  10721. * Does this action manager handles actions of any of the given triggers
  10722. * @param triggers defines the triggers to be tested
  10723. * @return a boolean indicating whether one (or more) of the triggers is handled
  10724. */
  10725. hasSpecificTriggers(triggers: number[]): boolean;
  10726. /**
  10727. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10728. * speed.
  10729. * @param triggerA defines the trigger to be tested
  10730. * @param triggerB defines the trigger to be tested
  10731. * @return a boolean indicating whether one (or more) of the triggers is handled
  10732. */
  10733. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10734. /**
  10735. * Does this action manager handles actions of a given trigger
  10736. * @param trigger defines the trigger to be tested
  10737. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10738. * @return whether the trigger is handled
  10739. */
  10740. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10741. /**
  10742. * Does this action manager has pointer triggers
  10743. */
  10744. readonly hasPointerTriggers: boolean;
  10745. /**
  10746. * Does this action manager has pick triggers
  10747. */
  10748. readonly hasPickTriggers: boolean;
  10749. /**
  10750. * Registers an action to this action manager
  10751. * @param action defines the action to be registered
  10752. * @return the action amended (prepared) after registration
  10753. */
  10754. registerAction(action: IAction): Nullable<IAction>;
  10755. /**
  10756. * Unregisters an action to this action manager
  10757. * @param action defines the action to be unregistered
  10758. * @return a boolean indicating whether the action has been unregistered
  10759. */
  10760. unregisterAction(action: IAction): Boolean;
  10761. /**
  10762. * Process a specific trigger
  10763. * @param trigger defines the trigger to process
  10764. * @param evt defines the event details to be processed
  10765. */
  10766. processTrigger(trigger: number, evt?: IActionEvent): void;
  10767. /** @hidden */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10768. /** @hidden */ private _getProperty(propertyPath: string): string;
  10769. /**
  10770. * Serialize this manager to a JSON object
  10771. * @param name defines the property name to store this manager
  10772. * @returns a JSON representation of this manager
  10773. */
  10774. serialize(name: string): any;
  10775. /**
  10776. * Creates a new ActionManager from a JSON data
  10777. * @param parsedActions defines the JSON data to read from
  10778. * @param object defines the hosting mesh
  10779. * @param scene defines the hosting scene
  10780. */
  10781. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10782. /**
  10783. * Get a trigger name by index
  10784. * @param trigger defines the trigger index
  10785. * @returns a trigger name
  10786. */
  10787. static GetTriggerName(trigger: number): string;
  10788. }
  10789. }
  10790. declare module BABYLON {
  10791. /**
  10792. * Class representing a ray with position and direction
  10793. */
  10794. export class Ray {
  10795. /** origin point */
  10796. origin: Vector3;
  10797. /** direction */
  10798. direction: Vector3;
  10799. /** length of the ray */
  10800. length: number;
  10801. private static readonly TmpVector3;
  10802. private _tmpRay;
  10803. /**
  10804. * Creates a new ray
  10805. * @param origin origin point
  10806. * @param direction direction
  10807. * @param length length of the ray
  10808. */
  10809. constructor(
  10810. /** origin point */
  10811. origin: Vector3,
  10812. /** direction */
  10813. direction: Vector3,
  10814. /** length of the ray */
  10815. length?: number);
  10816. /**
  10817. * Checks if the ray intersects a box
  10818. * @param minimum bound of the box
  10819. * @param maximum bound of the box
  10820. * @param intersectionTreshold extra extend to be added to the box in all direction
  10821. * @returns if the box was hit
  10822. */
  10823. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10824. /**
  10825. * Checks if the ray intersects a box
  10826. * @param box the bounding box to check
  10827. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10828. * @returns if the box was hit
  10829. */
  10830. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10831. /**
  10832. * If the ray hits a sphere
  10833. * @param sphere the bounding sphere to check
  10834. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10835. * @returns true if it hits the sphere
  10836. */
  10837. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10838. /**
  10839. * If the ray hits a triange
  10840. * @param vertex0 triangle vertex
  10841. * @param vertex1 triangle vertex
  10842. * @param vertex2 triangle vertex
  10843. * @returns intersection information if hit
  10844. */
  10845. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10846. /**
  10847. * Checks if ray intersects a plane
  10848. * @param plane the plane to check
  10849. * @returns the distance away it was hit
  10850. */
  10851. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10852. /**
  10853. * Calculate the intercept of a ray on a given axis
  10854. * @param axis to check 'x' | 'y' | 'z'
  10855. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10856. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10857. */
  10858. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10859. /**
  10860. * Checks if ray intersects a mesh
  10861. * @param mesh the mesh to check
  10862. * @param fastCheck if only the bounding box should checked
  10863. * @returns picking info of the intersecton
  10864. */
  10865. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10866. /**
  10867. * Checks if ray intersects a mesh
  10868. * @param meshes the meshes to check
  10869. * @param fastCheck if only the bounding box should checked
  10870. * @param results array to store result in
  10871. * @returns Array of picking infos
  10872. */
  10873. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10874. private _comparePickingInfo;
  10875. private static smallnum;
  10876. private static rayl;
  10877. /**
  10878. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10879. * @param sega the first point of the segment to test the intersection against
  10880. * @param segb the second point of the segment to test the intersection against
  10881. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10882. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10883. */
  10884. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10885. /**
  10886. * Update the ray from viewport position
  10887. * @param x position
  10888. * @param y y position
  10889. * @param viewportWidth viewport width
  10890. * @param viewportHeight viewport height
  10891. * @param world world matrix
  10892. * @param view view matrix
  10893. * @param projection projection matrix
  10894. * @returns this ray updated
  10895. */
  10896. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10897. /**
  10898. * Creates a ray with origin and direction of 0,0,0
  10899. * @returns the new ray
  10900. */
  10901. static Zero(): Ray;
  10902. /**
  10903. * Creates a new ray from screen space and viewport
  10904. * @param x position
  10905. * @param y y position
  10906. * @param viewportWidth viewport width
  10907. * @param viewportHeight viewport height
  10908. * @param world world matrix
  10909. * @param view view matrix
  10910. * @param projection projection matrix
  10911. * @returns new ray
  10912. */
  10913. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10914. /**
  10915. * 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
  10916. * transformed to the given world matrix.
  10917. * @param origin The origin point
  10918. * @param end The end point
  10919. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10920. * @returns the new ray
  10921. */
  10922. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10923. /**
  10924. * Transforms a ray by a matrix
  10925. * @param ray ray to transform
  10926. * @param matrix matrix to apply
  10927. * @returns the resulting new ray
  10928. */
  10929. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10930. /**
  10931. * Transforms a ray by a matrix
  10932. * @param ray ray to transform
  10933. * @param matrix matrix to apply
  10934. * @param result ray to store result in
  10935. */
  10936. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10937. /**
  10938. * Unproject a ray from screen space to object space
  10939. * @param sourceX defines the screen space x coordinate to use
  10940. * @param sourceY defines the screen space y coordinate to use
  10941. * @param viewportWidth defines the current width of the viewport
  10942. * @param viewportHeight defines the current height of the viewport
  10943. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10944. * @param view defines the view matrix to use
  10945. * @param projection defines the projection matrix to use
  10946. */
  10947. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10948. }
  10949. /**
  10950. * Type used to define predicate used to select faces when a mesh intersection is detected
  10951. */
  10952. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10953. interface Scene {
  10954. /** @hidden */ private _tempPickingRay: Nullable<Ray>;
  10955. /** @hidden */ private _cachedRayForTransform: Ray;
  10956. /** @hidden */ private _pickWithRayInverseMatrix: Matrix;
  10957. /** @hidden */ private _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10958. /** @hidden */ private _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10959. }
  10960. }
  10961. declare module BABYLON {
  10962. /**
  10963. * Groups all the scene component constants in one place to ease maintenance.
  10964. * @hidden
  10965. */
  10966. export class SceneComponentConstants {
  10967. static readonly NAME_EFFECTLAYER: string;
  10968. static readonly NAME_LAYER: string;
  10969. static readonly NAME_LENSFLARESYSTEM: string;
  10970. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10971. static readonly NAME_PARTICLESYSTEM: string;
  10972. static readonly NAME_GAMEPAD: string;
  10973. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10974. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10975. static readonly NAME_DEPTHRENDERER: string;
  10976. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10977. static readonly NAME_SPRITE: string;
  10978. static readonly NAME_OUTLINERENDERER: string;
  10979. static readonly NAME_PROCEDURALTEXTURE: string;
  10980. static readonly NAME_SHADOWGENERATOR: string;
  10981. static readonly NAME_OCTREE: string;
  10982. static readonly NAME_PHYSICSENGINE: string;
  10983. static readonly NAME_AUDIO: string;
  10984. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10985. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10986. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10987. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10988. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10989. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10990. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10991. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10992. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10993. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10994. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10995. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10996. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10997. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10998. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10999. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11000. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11001. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11002. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11003. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11004. static readonly STEP_AFTERRENDER_AUDIO: number;
  11005. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11006. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11007. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11008. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11009. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11010. static readonly STEP_POINTERMOVE_SPRITE: number;
  11011. static readonly STEP_POINTERDOWN_SPRITE: number;
  11012. static readonly STEP_POINTERUP_SPRITE: number;
  11013. }
  11014. /**
  11015. * This represents a scene component.
  11016. *
  11017. * This is used to decouple the dependency the scene is having on the different workloads like
  11018. * layers, post processes...
  11019. */
  11020. export interface ISceneComponent {
  11021. /**
  11022. * The name of the component. Each component must have a unique name.
  11023. */
  11024. name: string;
  11025. /**
  11026. * The scene the component belongs to.
  11027. */
  11028. scene: Scene;
  11029. /**
  11030. * Register the component to one instance of a scene.
  11031. */
  11032. register(): void;
  11033. /**
  11034. * Rebuilds the elements related to this component in case of
  11035. * context lost for instance.
  11036. */
  11037. rebuild(): void;
  11038. /**
  11039. * Disposes the component and the associated ressources.
  11040. */
  11041. dispose(): void;
  11042. }
  11043. /**
  11044. * This represents a SERIALIZABLE scene component.
  11045. *
  11046. * This extends Scene Component to add Serialization methods on top.
  11047. */
  11048. export interface ISceneSerializableComponent extends ISceneComponent {
  11049. /**
  11050. * Adds all the elements from the container to the scene
  11051. * @param container the container holding the elements
  11052. */
  11053. addFromContainer(container: AbstractScene): void;
  11054. /**
  11055. * Removes all the elements in the container from the scene
  11056. * @param container contains the elements to remove
  11057. * @param dispose if the removed element should be disposed (default: false)
  11058. */
  11059. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11060. /**
  11061. * Serializes the component data to the specified json object
  11062. * @param serializationObject The object to serialize to
  11063. */
  11064. serialize(serializationObject: any): void;
  11065. }
  11066. /**
  11067. * Strong typing of a Mesh related stage step action
  11068. */
  11069. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11070. /**
  11071. * Strong typing of a Evaluate Sub Mesh related stage step action
  11072. */
  11073. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11074. /**
  11075. * Strong typing of a Active Mesh related stage step action
  11076. */
  11077. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11078. /**
  11079. * Strong typing of a Camera related stage step action
  11080. */
  11081. export type CameraStageAction = (camera: Camera) => void;
  11082. /**
  11083. * Strong typing of a Camera Frame buffer related stage step action
  11084. */
  11085. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11086. /**
  11087. * Strong typing of a Render Target related stage step action
  11088. */
  11089. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11090. /**
  11091. * Strong typing of a RenderingGroup related stage step action
  11092. */
  11093. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11094. /**
  11095. * Strong typing of a Mesh Render related stage step action
  11096. */
  11097. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11098. /**
  11099. * Strong typing of a simple stage step action
  11100. */
  11101. export type SimpleStageAction = () => void;
  11102. /**
  11103. * Strong typing of a render target action.
  11104. */
  11105. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11106. /**
  11107. * Strong typing of a pointer move action.
  11108. */
  11109. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11110. /**
  11111. * Strong typing of a pointer up/down action.
  11112. */
  11113. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11114. /**
  11115. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11116. * @hidden
  11117. */
  11118. export class Stage<T extends Function> extends Array<{
  11119. index: number;
  11120. component: ISceneComponent;
  11121. action: T;
  11122. }> {
  11123. /**
  11124. * Hide ctor from the rest of the world.
  11125. * @param items The items to add.
  11126. */
  11127. private constructor();
  11128. /**
  11129. * Creates a new Stage.
  11130. * @returns A new instance of a Stage
  11131. */
  11132. static Create<T extends Function>(): Stage<T>;
  11133. /**
  11134. * Registers a step in an ordered way in the targeted stage.
  11135. * @param index Defines the position to register the step in
  11136. * @param component Defines the component attached to the step
  11137. * @param action Defines the action to launch during the step
  11138. */
  11139. registerStep(index: number, component: ISceneComponent, action: T): void;
  11140. /**
  11141. * Clears all the steps from the stage.
  11142. */
  11143. clear(): void;
  11144. }
  11145. }
  11146. declare module BABYLON {
  11147. interface Scene {
  11148. /** @hidden */ private _pointerOverSprite: Nullable<Sprite>;
  11149. /** @hidden */ private _pickedDownSprite: Nullable<Sprite>;
  11150. /** @hidden */ private _tempSpritePickingRay: Nullable<Ray>;
  11151. /**
  11152. * All of the sprite managers added to this scene
  11153. * @see http://doc.babylonjs.com/babylon101/sprites
  11154. */
  11155. spriteManagers: Array<ISpriteManager>;
  11156. /**
  11157. * An event triggered when sprites rendering is about to start
  11158. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11159. */
  11160. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11161. /**
  11162. * An event triggered when sprites rendering is done
  11163. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11164. */
  11165. onAfterSpritesRenderingObservable: Observable<Scene>;
  11166. /** @hidden */ private _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11167. /** Launch a ray to try to pick a sprite in the scene
  11168. * @param x position on screen
  11169. * @param y position on screen
  11170. * @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
  11171. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11172. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11173. * @returns a PickingInfo
  11174. */
  11175. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11176. /** Use the given ray to pick a sprite in the scene
  11177. * @param ray The ray (in world space) to use to pick meshes
  11178. * @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
  11179. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11180. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11181. * @returns a PickingInfo
  11182. */
  11183. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11184. /** @hidden */ private _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11185. /** Launch a ray to try to pick sprites in the scene
  11186. * @param x position on screen
  11187. * @param y position on screen
  11188. * @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
  11189. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11190. * @returns a PickingInfo array
  11191. */
  11192. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11193. /** Use the given ray to pick sprites in the scene
  11194. * @param ray The ray (in world space) to use to pick meshes
  11195. * @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
  11196. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11197. * @returns a PickingInfo array
  11198. */
  11199. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11200. /**
  11201. * Force the sprite under the pointer
  11202. * @param sprite defines the sprite to use
  11203. */
  11204. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11205. /**
  11206. * Gets the sprite under the pointer
  11207. * @returns a Sprite or null if no sprite is under the pointer
  11208. */
  11209. getPointerOverSprite(): Nullable<Sprite>;
  11210. }
  11211. /**
  11212. * Defines the sprite scene component responsible to manage sprites
  11213. * in a given scene.
  11214. */
  11215. export class SpriteSceneComponent implements ISceneComponent {
  11216. /**
  11217. * The component name helpfull to identify the component in the list of scene components.
  11218. */
  11219. readonly name: string;
  11220. /**
  11221. * The scene the component belongs to.
  11222. */
  11223. scene: Scene;
  11224. /** @hidden */
  11225. private _spritePredicate;
  11226. /**
  11227. * Creates a new instance of the component for the given scene
  11228. * @param scene Defines the scene to register the component in
  11229. */
  11230. constructor(scene: Scene);
  11231. /**
  11232. * Registers the component in a given scene
  11233. */
  11234. register(): void;
  11235. /**
  11236. * Rebuilds the elements related to this component in case of
  11237. * context lost for instance.
  11238. */
  11239. rebuild(): void;
  11240. /**
  11241. * Disposes the component and the associated ressources.
  11242. */
  11243. dispose(): void;
  11244. private _pickSpriteButKeepRay;
  11245. private _pointerMove;
  11246. private _pointerDown;
  11247. private _pointerUp;
  11248. }
  11249. }
  11250. declare module BABYLON {
  11251. /** @hidden */
  11252. export var fogFragmentDeclaration: {
  11253. name: string;
  11254. shader: string;
  11255. };
  11256. }
  11257. declare module BABYLON {
  11258. /** @hidden */
  11259. export var fogFragment: {
  11260. name: string;
  11261. shader: string;
  11262. };
  11263. }
  11264. declare module BABYLON {
  11265. /** @hidden */
  11266. export var spritesPixelShader: {
  11267. name: string;
  11268. shader: string;
  11269. };
  11270. }
  11271. declare module BABYLON {
  11272. /** @hidden */
  11273. export var fogVertexDeclaration: {
  11274. name: string;
  11275. shader: string;
  11276. };
  11277. }
  11278. declare module BABYLON {
  11279. /** @hidden */
  11280. export var spritesVertexShader: {
  11281. name: string;
  11282. shader: string;
  11283. };
  11284. }
  11285. declare module BABYLON {
  11286. /**
  11287. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11288. */
  11289. export interface ISpriteManager extends IDisposable {
  11290. /**
  11291. * Restricts the camera to viewing objects with the same layerMask.
  11292. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11293. */
  11294. layerMask: number;
  11295. /**
  11296. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11297. */
  11298. isPickable: boolean;
  11299. /**
  11300. * Specifies the rendering group id for this mesh (0 by default)
  11301. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11302. */
  11303. renderingGroupId: number;
  11304. /**
  11305. * Defines the list of sprites managed by the manager.
  11306. */
  11307. sprites: Array<Sprite>;
  11308. /**
  11309. * Tests the intersection of a sprite with a specific ray.
  11310. * @param ray The ray we are sending to test the collision
  11311. * @param camera The camera space we are sending rays in
  11312. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11313. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11314. * @returns picking info or null.
  11315. */
  11316. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11317. /**
  11318. * Intersects the sprites with a ray
  11319. * @param ray defines the ray to intersect with
  11320. * @param camera defines the current active camera
  11321. * @param predicate defines a predicate used to select candidate sprites
  11322. * @returns null if no hit or a PickingInfo array
  11323. */
  11324. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11325. /**
  11326. * Renders the list of sprites on screen.
  11327. */
  11328. render(): void;
  11329. }
  11330. /**
  11331. * Class used to manage multiple sprites on the same spritesheet
  11332. * @see http://doc.babylonjs.com/babylon101/sprites
  11333. */
  11334. export class SpriteManager implements ISpriteManager {
  11335. /** defines the manager's name */
  11336. name: string;
  11337. /** Gets the list of sprites */
  11338. sprites: Sprite[];
  11339. /** Gets or sets the rendering group id (0 by default) */
  11340. renderingGroupId: number;
  11341. /** Gets or sets camera layer mask */
  11342. layerMask: number;
  11343. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11344. fogEnabled: boolean;
  11345. /** Gets or sets a boolean indicating if the sprites are pickable */
  11346. isPickable: boolean;
  11347. /** Defines the default width of a cell in the spritesheet */
  11348. cellWidth: number;
  11349. /** Defines the default height of a cell in the spritesheet */
  11350. cellHeight: number;
  11351. /** Associative array from JSON sprite data file */
  11352. private _cellData;
  11353. /** Array of sprite names from JSON sprite data file */
  11354. private _spriteMap;
  11355. /** True when packed cell data from JSON file is ready*/
  11356. private _packedAndReady;
  11357. /**
  11358. * An event triggered when the manager is disposed.
  11359. */
  11360. onDisposeObservable: Observable<SpriteManager>;
  11361. private _onDisposeObserver;
  11362. /**
  11363. * Callback called when the manager is disposed
  11364. */
  11365. onDispose: () => void;
  11366. private _capacity;
  11367. private _fromPacked;
  11368. private _spriteTexture;
  11369. private _epsilon;
  11370. private _scene;
  11371. private _vertexData;
  11372. private _buffer;
  11373. private _vertexBuffers;
  11374. private _indexBuffer;
  11375. private _effectBase;
  11376. private _effectFog;
  11377. /**
  11378. * Gets or sets the spritesheet texture
  11379. */
  11380. texture: Texture;
  11381. /**
  11382. * Creates a new sprite manager
  11383. * @param name defines the manager's name
  11384. * @param imgUrl defines the sprite sheet url
  11385. * @param capacity defines the maximum allowed number of sprites
  11386. * @param cellSize defines the size of a sprite cell
  11387. * @param scene defines the hosting scene
  11388. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11389. * @param samplingMode defines the smapling mode to use with spritesheet
  11390. * @param fromPacked set to false; do not alter
  11391. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11392. */
  11393. constructor(
  11394. /** defines the manager's name */
  11395. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11396. private _makePacked;
  11397. private _appendSpriteVertex;
  11398. /**
  11399. * Intersects the sprites with a ray
  11400. * @param ray defines the ray to intersect with
  11401. * @param camera defines the current active camera
  11402. * @param predicate defines a predicate used to select candidate sprites
  11403. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11404. * @returns null if no hit or a PickingInfo
  11405. */
  11406. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11407. /**
  11408. * Intersects the sprites with a ray
  11409. * @param ray defines the ray to intersect with
  11410. * @param camera defines the current active camera
  11411. * @param predicate defines a predicate used to select candidate sprites
  11412. * @returns null if no hit or a PickingInfo array
  11413. */
  11414. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11415. /**
  11416. * Render all child sprites
  11417. */
  11418. render(): void;
  11419. /**
  11420. * Release associated resources
  11421. */
  11422. dispose(): void;
  11423. }
  11424. }
  11425. declare module BABYLON {
  11426. /**
  11427. * Class used to represent a sprite
  11428. * @see http://doc.babylonjs.com/babylon101/sprites
  11429. */
  11430. export class Sprite {
  11431. /** defines the name */
  11432. name: string;
  11433. /** Gets or sets the current world position */
  11434. position: Vector3;
  11435. /** Gets or sets the main color */
  11436. color: Color4;
  11437. /** Gets or sets the width */
  11438. width: number;
  11439. /** Gets or sets the height */
  11440. height: number;
  11441. /** Gets or sets rotation angle */
  11442. angle: number;
  11443. /** Gets or sets the cell index in the sprite sheet */
  11444. cellIndex: number;
  11445. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11446. cellRef: string;
  11447. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11448. invertU: number;
  11449. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11450. invertV: number;
  11451. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11452. disposeWhenFinishedAnimating: boolean;
  11453. /** Gets the list of attached animations */
  11454. animations: Animation[];
  11455. /** Gets or sets a boolean indicating if the sprite can be picked */
  11456. isPickable: boolean;
  11457. /**
  11458. * Gets or sets the associated action manager
  11459. */
  11460. actionManager: Nullable<ActionManager>;
  11461. private _animationStarted;
  11462. private _loopAnimation;
  11463. private _fromIndex;
  11464. private _toIndex;
  11465. private _delay;
  11466. private _direction;
  11467. private _manager;
  11468. private _time;
  11469. private _onAnimationEnd;
  11470. /**
  11471. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11472. */
  11473. isVisible: boolean;
  11474. /**
  11475. * Gets or sets the sprite size
  11476. */
  11477. size: number;
  11478. /**
  11479. * Creates a new Sprite
  11480. * @param name defines the name
  11481. * @param manager defines the manager
  11482. */
  11483. constructor(
  11484. /** defines the name */
  11485. name: string, manager: ISpriteManager);
  11486. /**
  11487. * Starts an animation
  11488. * @param from defines the initial key
  11489. * @param to defines the end key
  11490. * @param loop defines if the animation must loop
  11491. * @param delay defines the start delay (in ms)
  11492. * @param onAnimationEnd defines a callback to call when animation ends
  11493. */
  11494. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11495. /** Stops current animation (if any) */
  11496. stopAnimation(): void;
  11497. /** @hidden */ private _animate(deltaTime: number): void;
  11498. /** Release associated resources */
  11499. dispose(): void;
  11500. }
  11501. }
  11502. declare module BABYLON {
  11503. /**
  11504. * Information about the result of picking within a scene
  11505. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11506. */
  11507. export class PickingInfo {
  11508. /** @hidden */ private _pickingUnavailable: boolean;
  11509. /**
  11510. * If the pick collided with an object
  11511. */
  11512. hit: boolean;
  11513. /**
  11514. * Distance away where the pick collided
  11515. */
  11516. distance: number;
  11517. /**
  11518. * The location of pick collision
  11519. */
  11520. pickedPoint: Nullable<Vector3>;
  11521. /**
  11522. * The mesh corresponding the the pick collision
  11523. */
  11524. pickedMesh: Nullable<AbstractMesh>;
  11525. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11526. bu: number;
  11527. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11528. bv: number;
  11529. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11530. faceId: number;
  11531. /** Id of the the submesh that was picked */
  11532. subMeshId: number;
  11533. /** If a sprite was picked, this will be the sprite the pick collided with */
  11534. pickedSprite: Nullable<Sprite>;
  11535. /**
  11536. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11537. */
  11538. originMesh: Nullable<AbstractMesh>;
  11539. /**
  11540. * The ray that was used to perform the picking.
  11541. */
  11542. ray: Nullable<Ray>;
  11543. /**
  11544. * Gets the normal correspodning to the face the pick collided with
  11545. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11546. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11547. * @returns The normal correspodning to the face the pick collided with
  11548. */
  11549. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11550. /**
  11551. * Gets the texture coordinates of where the pick occured
  11552. * @returns the vector containing the coordnates of the texture
  11553. */
  11554. getTextureCoordinates(): Nullable<Vector2>;
  11555. }
  11556. }
  11557. declare module BABYLON {
  11558. /**
  11559. * Gather the list of pointer event types as constants.
  11560. */
  11561. export class PointerEventTypes {
  11562. /**
  11563. * 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.
  11564. */
  11565. static readonly POINTERDOWN: number;
  11566. /**
  11567. * The pointerup event is fired when a pointer is no longer active.
  11568. */
  11569. static readonly POINTERUP: number;
  11570. /**
  11571. * The pointermove event is fired when a pointer changes coordinates.
  11572. */
  11573. static readonly POINTERMOVE: number;
  11574. /**
  11575. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11576. */
  11577. static readonly POINTERWHEEL: number;
  11578. /**
  11579. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11580. */
  11581. static readonly POINTERPICK: number;
  11582. /**
  11583. * The pointertap event is fired when a the object has been touched and released without drag.
  11584. */
  11585. static readonly POINTERTAP: number;
  11586. /**
  11587. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11588. */
  11589. static readonly POINTERDOUBLETAP: number;
  11590. }
  11591. /**
  11592. * Base class of pointer info types.
  11593. */
  11594. export class PointerInfoBase {
  11595. /**
  11596. * Defines the type of event (PointerEventTypes)
  11597. */
  11598. type: number;
  11599. /**
  11600. * Defines the related dom event
  11601. */
  11602. event: PointerEvent | MouseWheelEvent;
  11603. /**
  11604. * Instantiates the base class of pointers info.
  11605. * @param type Defines the type of event (PointerEventTypes)
  11606. * @param event Defines the related dom event
  11607. */
  11608. constructor(
  11609. /**
  11610. * Defines the type of event (PointerEventTypes)
  11611. */
  11612. type: number,
  11613. /**
  11614. * Defines the related dom event
  11615. */
  11616. event: PointerEvent | MouseWheelEvent);
  11617. }
  11618. /**
  11619. * This class is used to store pointer related info for the onPrePointerObservable event.
  11620. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11621. */
  11622. export class PointerInfoPre extends PointerInfoBase {
  11623. /**
  11624. * Ray from a pointer if availible (eg. 6dof controller)
  11625. */
  11626. ray: Nullable<Ray>;
  11627. /**
  11628. * Defines the local position of the pointer on the canvas.
  11629. */
  11630. localPosition: Vector2;
  11631. /**
  11632. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11633. */
  11634. skipOnPointerObservable: boolean;
  11635. /**
  11636. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11637. * @param type Defines the type of event (PointerEventTypes)
  11638. * @param event Defines the related dom event
  11639. * @param localX Defines the local x coordinates of the pointer when the event occured
  11640. * @param localY Defines the local y coordinates of the pointer when the event occured
  11641. */
  11642. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11643. }
  11644. /**
  11645. * This type contains all the data related to a pointer event in Babylon.js.
  11646. * 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.
  11647. */
  11648. export class PointerInfo extends PointerInfoBase {
  11649. /**
  11650. * Defines the picking info associated to the info (if any)\
  11651. */
  11652. pickInfo: Nullable<PickingInfo>;
  11653. /**
  11654. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11655. * @param type Defines the type of event (PointerEventTypes)
  11656. * @param event Defines the related dom event
  11657. * @param pickInfo Defines the picking info associated to the info (if any)\
  11658. */
  11659. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11660. /**
  11661. * Defines the picking info associated to the info (if any)\
  11662. */
  11663. pickInfo: Nullable<PickingInfo>);
  11664. }
  11665. /**
  11666. * Data relating to a touch event on the screen.
  11667. */
  11668. export interface PointerTouch {
  11669. /**
  11670. * X coordinate of touch.
  11671. */
  11672. x: number;
  11673. /**
  11674. * Y coordinate of touch.
  11675. */
  11676. y: number;
  11677. /**
  11678. * Id of touch. Unique for each finger.
  11679. */
  11680. pointerId: number;
  11681. /**
  11682. * Event type passed from DOM.
  11683. */
  11684. type: any;
  11685. }
  11686. }
  11687. declare module BABYLON {
  11688. /**
  11689. * Manage the mouse inputs to control the movement of a free camera.
  11690. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11691. */
  11692. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11693. /**
  11694. * Define if touch is enabled in the mouse input
  11695. */
  11696. touchEnabled: boolean;
  11697. /**
  11698. * Defines the camera the input is attached to.
  11699. */
  11700. camera: FreeCamera;
  11701. /**
  11702. * Defines the buttons associated with the input to handle camera move.
  11703. */
  11704. buttons: number[];
  11705. /**
  11706. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11707. */
  11708. angularSensibility: number;
  11709. private _pointerInput;
  11710. private _onMouseMove;
  11711. private _observer;
  11712. private previousPosition;
  11713. /**
  11714. * Observable for when a pointer move event occurs containing the move offset
  11715. */
  11716. onPointerMovedObservable: Observable<{
  11717. offsetX: number;
  11718. offsetY: number;
  11719. }>;
  11720. /**
  11721. * @hidden
  11722. * If the camera should be rotated automatically based on pointer movement
  11723. */ private _allowCameraRotation: boolean;
  11724. /**
  11725. * Manage the mouse inputs to control the movement of a free camera.
  11726. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11727. * @param touchEnabled Defines if touch is enabled or not
  11728. */
  11729. constructor(
  11730. /**
  11731. * Define if touch is enabled in the mouse input
  11732. */
  11733. touchEnabled?: boolean);
  11734. /**
  11735. * Attach the input controls to a specific dom element to get the input from.
  11736. * @param element Defines the element the controls should be listened from
  11737. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11738. */
  11739. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11740. /**
  11741. * Called on JS contextmenu event.
  11742. * Override this method to provide functionality.
  11743. */
  11744. protected onContextMenu(evt: PointerEvent): void;
  11745. /**
  11746. * Detach the current controls from the specified dom element.
  11747. * @param element Defines the element to stop listening the inputs from
  11748. */
  11749. detachControl(element: Nullable<HTMLElement>): void;
  11750. /**
  11751. * Gets the class name of the current intput.
  11752. * @returns the class name
  11753. */
  11754. getClassName(): string;
  11755. /**
  11756. * Get the friendly name associated with the input class.
  11757. * @returns the input friendly name
  11758. */
  11759. getSimpleName(): string;
  11760. }
  11761. }
  11762. declare module BABYLON {
  11763. /**
  11764. * Manage the touch inputs to control the movement of a free camera.
  11765. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11766. */
  11767. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11768. /**
  11769. * Defines the camera the input is attached to.
  11770. */
  11771. camera: FreeCamera;
  11772. /**
  11773. * Defines the touch sensibility for rotation.
  11774. * The higher the faster.
  11775. */
  11776. touchAngularSensibility: number;
  11777. /**
  11778. * Defines the touch sensibility for move.
  11779. * The higher the faster.
  11780. */
  11781. touchMoveSensibility: number;
  11782. private _offsetX;
  11783. private _offsetY;
  11784. private _pointerPressed;
  11785. private _pointerInput;
  11786. private _observer;
  11787. private _onLostFocus;
  11788. /**
  11789. * Attach the input controls to a specific dom element to get the input from.
  11790. * @param element Defines the element the controls should be listened from
  11791. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11792. */
  11793. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11794. /**
  11795. * Detach the current controls from the specified dom element.
  11796. * @param element Defines the element to stop listening the inputs from
  11797. */
  11798. detachControl(element: Nullable<HTMLElement>): void;
  11799. /**
  11800. * Update the current camera state depending on the inputs that have been used this frame.
  11801. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11802. */
  11803. checkInputs(): void;
  11804. /**
  11805. * Gets the class name of the current intput.
  11806. * @returns the class name
  11807. */
  11808. getClassName(): string;
  11809. /**
  11810. * Get the friendly name associated with the input class.
  11811. * @returns the input friendly name
  11812. */
  11813. getSimpleName(): string;
  11814. }
  11815. }
  11816. declare module BABYLON {
  11817. /**
  11818. * Default Inputs manager for the FreeCamera.
  11819. * It groups all the default supported inputs for ease of use.
  11820. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11821. */
  11822. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11823. /**
  11824. * @hidden
  11825. */ private _mouseInput: Nullable<FreeCameraMouseInput>;
  11826. /**
  11827. * Instantiates a new FreeCameraInputsManager.
  11828. * @param camera Defines the camera the inputs belong to
  11829. */
  11830. constructor(camera: FreeCamera);
  11831. /**
  11832. * Add keyboard input support to the input manager.
  11833. * @returns the current input manager
  11834. */
  11835. addKeyboard(): FreeCameraInputsManager;
  11836. /**
  11837. * Add mouse input support to the input manager.
  11838. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11839. * @returns the current input manager
  11840. */
  11841. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11842. /**
  11843. * Removes the mouse input support from the manager
  11844. * @returns the current input manager
  11845. */
  11846. removeMouse(): FreeCameraInputsManager;
  11847. /**
  11848. * Add touch input support to the input manager.
  11849. * @returns the current input manager
  11850. */
  11851. addTouch(): FreeCameraInputsManager;
  11852. /**
  11853. * Remove all attached input methods from a camera
  11854. */
  11855. clear(): void;
  11856. }
  11857. }
  11858. declare module BABYLON {
  11859. /**
  11860. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11861. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  11862. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11863. */
  11864. export class FreeCamera extends TargetCamera {
  11865. /**
  11866. * Define the collision ellipsoid of the camera.
  11867. * This is helpful to simulate a camera body like the player body around the camera
  11868. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  11869. */
  11870. ellipsoid: Vector3;
  11871. /**
  11872. * Define an offset for the position of the ellipsoid around the camera.
  11873. * This can be helpful to determine the center of the body near the gravity center of the body
  11874. * instead of its head.
  11875. */
  11876. ellipsoidOffset: Vector3;
  11877. /**
  11878. * Enable or disable collisions of the camera with the rest of the scene objects.
  11879. */
  11880. checkCollisions: boolean;
  11881. /**
  11882. * Enable or disable gravity on the camera.
  11883. */
  11884. applyGravity: boolean;
  11885. /**
  11886. * Define the input manager associated to the camera.
  11887. */
  11888. inputs: FreeCameraInputsManager;
  11889. /**
  11890. * Gets the input sensibility for a mouse input. (default is 2000.0)
  11891. * Higher values reduce sensitivity.
  11892. */
  11893. /**
  11894. * Sets the input sensibility for a mouse input. (default is 2000.0)
  11895. * Higher values reduce sensitivity.
  11896. */
  11897. angularSensibility: number;
  11898. /**
  11899. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  11900. */
  11901. keysUp: number[];
  11902. /**
  11903. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  11904. */
  11905. keysDown: number[];
  11906. /**
  11907. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  11908. */
  11909. keysLeft: number[];
  11910. /**
  11911. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  11912. */
  11913. keysRight: number[];
  11914. /**
  11915. * Event raised when the camera collide with a mesh in the scene.
  11916. */
  11917. onCollide: (collidedMesh: AbstractMesh) => void;
  11918. private _collider;
  11919. private _needMoveForGravity;
  11920. private _oldPosition;
  11921. private _diffPosition;
  11922. private _newPosition;
  11923. /** @hidden */ private _localDirection: Vector3;
  11924. /** @hidden */ private _transformedDirection: Vector3;
  11925. /**
  11926. * Instantiates a Free Camera.
  11927. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11928. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  11929. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11930. * @param name Define the name of the camera in the scene
  11931. * @param position Define the start position of the camera in the scene
  11932. * @param scene Define the scene the camera belongs to
  11933. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  11934. */
  11935. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  11936. /**
  11937. * Attached controls to the current camera.
  11938. * @param element Defines the element the controls should be listened from
  11939. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11940. */
  11941. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11942. /**
  11943. * Detach the current controls from the camera.
  11944. * The camera will stop reacting to inputs.
  11945. * @param element Defines the element to stop listening the inputs from
  11946. */
  11947. detachControl(element: HTMLElement): void;
  11948. private _collisionMask;
  11949. /**
  11950. * Define a collision mask to limit the list of object the camera can collide with
  11951. */
  11952. collisionMask: number;
  11953. /** @hidden */ private _collideWithWorld(displacement: Vector3): void;
  11954. private _onCollisionPositionChange;
  11955. /** @hidden */ private _checkInputs(): void;
  11956. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  11957. /** @hidden */ private _updatePosition(): void;
  11958. /**
  11959. * Destroy the camera and release the current resources hold by it.
  11960. */
  11961. dispose(): void;
  11962. /**
  11963. * Gets the current object class name.
  11964. * @return the class name
  11965. */
  11966. getClassName(): string;
  11967. }
  11968. }
  11969. declare module BABYLON {
  11970. /**
  11971. * Represents a gamepad control stick position
  11972. */
  11973. export class StickValues {
  11974. /**
  11975. * The x component of the control stick
  11976. */
  11977. x: number;
  11978. /**
  11979. * The y component of the control stick
  11980. */
  11981. y: number;
  11982. /**
  11983. * Initializes the gamepad x and y control stick values
  11984. * @param x The x component of the gamepad control stick value
  11985. * @param y The y component of the gamepad control stick value
  11986. */
  11987. constructor(
  11988. /**
  11989. * The x component of the control stick
  11990. */
  11991. x: number,
  11992. /**
  11993. * The y component of the control stick
  11994. */
  11995. y: number);
  11996. }
  11997. /**
  11998. * An interface which manages callbacks for gamepad button changes
  11999. */
  12000. export interface GamepadButtonChanges {
  12001. /**
  12002. * Called when a gamepad has been changed
  12003. */
  12004. changed: boolean;
  12005. /**
  12006. * Called when a gamepad press event has been triggered
  12007. */
  12008. pressChanged: boolean;
  12009. /**
  12010. * Called when a touch event has been triggered
  12011. */
  12012. touchChanged: boolean;
  12013. /**
  12014. * Called when a value has changed
  12015. */
  12016. valueChanged: boolean;
  12017. }
  12018. /**
  12019. * Represents a gamepad
  12020. */
  12021. export class Gamepad {
  12022. /**
  12023. * The id of the gamepad
  12024. */
  12025. id: string;
  12026. /**
  12027. * The index of the gamepad
  12028. */
  12029. index: number;
  12030. /**
  12031. * The browser gamepad
  12032. */
  12033. browserGamepad: any;
  12034. /**
  12035. * Specifies what type of gamepad this represents
  12036. */
  12037. type: number;
  12038. private _leftStick;
  12039. private _rightStick;
  12040. /** @hidden */ private _isConnected: boolean;
  12041. private _leftStickAxisX;
  12042. private _leftStickAxisY;
  12043. private _rightStickAxisX;
  12044. private _rightStickAxisY;
  12045. /**
  12046. * Triggered when the left control stick has been changed
  12047. */
  12048. private _onleftstickchanged;
  12049. /**
  12050. * Triggered when the right control stick has been changed
  12051. */
  12052. private _onrightstickchanged;
  12053. /**
  12054. * Represents a gamepad controller
  12055. */
  12056. static GAMEPAD: number;
  12057. /**
  12058. * Represents a generic controller
  12059. */
  12060. static GENERIC: number;
  12061. /**
  12062. * Represents an XBox controller
  12063. */
  12064. static XBOX: number;
  12065. /**
  12066. * Represents a pose-enabled controller
  12067. */
  12068. static POSE_ENABLED: number;
  12069. /**
  12070. * Represents an Dual Shock controller
  12071. */
  12072. static DUALSHOCK: number;
  12073. /**
  12074. * Specifies whether the left control stick should be Y-inverted
  12075. */
  12076. protected _invertLeftStickY: boolean;
  12077. /**
  12078. * Specifies if the gamepad has been connected
  12079. */
  12080. readonly isConnected: boolean;
  12081. /**
  12082. * Initializes the gamepad
  12083. * @param id The id of the gamepad
  12084. * @param index The index of the gamepad
  12085. * @param browserGamepad The browser gamepad
  12086. * @param leftStickX The x component of the left joystick
  12087. * @param leftStickY The y component of the left joystick
  12088. * @param rightStickX The x component of the right joystick
  12089. * @param rightStickY The y component of the right joystick
  12090. */
  12091. constructor(
  12092. /**
  12093. * The id of the gamepad
  12094. */
  12095. id: string,
  12096. /**
  12097. * The index of the gamepad
  12098. */
  12099. index: number,
  12100. /**
  12101. * The browser gamepad
  12102. */
  12103. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12104. /**
  12105. * Callback triggered when the left joystick has changed
  12106. * @param callback
  12107. */
  12108. onleftstickchanged(callback: (values: StickValues) => void): void;
  12109. /**
  12110. * Callback triggered when the right joystick has changed
  12111. * @param callback
  12112. */
  12113. onrightstickchanged(callback: (values: StickValues) => void): void;
  12114. /**
  12115. * Gets the left joystick
  12116. */
  12117. /**
  12118. * Sets the left joystick values
  12119. */
  12120. leftStick: StickValues;
  12121. /**
  12122. * Gets the right joystick
  12123. */
  12124. /**
  12125. * Sets the right joystick value
  12126. */
  12127. rightStick: StickValues;
  12128. /**
  12129. * Updates the gamepad joystick positions
  12130. */
  12131. update(): void;
  12132. /**
  12133. * Disposes the gamepad
  12134. */
  12135. dispose(): void;
  12136. }
  12137. /**
  12138. * Represents a generic gamepad
  12139. */
  12140. export class GenericPad extends Gamepad {
  12141. private _buttons;
  12142. private _onbuttondown;
  12143. private _onbuttonup;
  12144. /**
  12145. * Observable triggered when a button has been pressed
  12146. */
  12147. onButtonDownObservable: Observable<number>;
  12148. /**
  12149. * Observable triggered when a button has been released
  12150. */
  12151. onButtonUpObservable: Observable<number>;
  12152. /**
  12153. * Callback triggered when a button has been pressed
  12154. * @param callback Called when a button has been pressed
  12155. */
  12156. onbuttondown(callback: (buttonPressed: number) => void): void;
  12157. /**
  12158. * Callback triggered when a button has been released
  12159. * @param callback Called when a button has been released
  12160. */
  12161. onbuttonup(callback: (buttonReleased: number) => void): void;
  12162. /**
  12163. * Initializes the generic gamepad
  12164. * @param id The id of the generic gamepad
  12165. * @param index The index of the generic gamepad
  12166. * @param browserGamepad The browser gamepad
  12167. */
  12168. constructor(id: string, index: number, browserGamepad: any);
  12169. private _setButtonValue;
  12170. /**
  12171. * Updates the generic gamepad
  12172. */
  12173. update(): void;
  12174. /**
  12175. * Disposes the generic gamepad
  12176. */
  12177. dispose(): void;
  12178. }
  12179. }
  12180. declare module BABYLON {
  12181. interface Engine {
  12182. /**
  12183. * Creates a raw texture
  12184. * @param data defines the data to store in the texture
  12185. * @param width defines the width of the texture
  12186. * @param height defines the height of the texture
  12187. * @param format defines the format of the data
  12188. * @param generateMipMaps defines if the engine should generate the mip levels
  12189. * @param invertY defines if data must be stored with Y axis inverted
  12190. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12191. * @param compression defines the compression used (null by default)
  12192. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12193. * @returns the raw texture inside an InternalTexture
  12194. */
  12195. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12196. /**
  12197. * Update a raw texture
  12198. * @param texture defines the texture to update
  12199. * @param data defines the data to store in the texture
  12200. * @param format defines the format of the data
  12201. * @param invertY defines if data must be stored with Y axis inverted
  12202. */
  12203. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12204. /**
  12205. * Update a raw texture
  12206. * @param texture defines the texture to update
  12207. * @param data defines the data to store in the texture
  12208. * @param format defines the format of the data
  12209. * @param invertY defines if data must be stored with Y axis inverted
  12210. * @param compression defines the compression used (null by default)
  12211. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12212. */
  12213. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12214. /**
  12215. * Creates a new raw cube texture
  12216. * @param data defines the array of data to use to create each face
  12217. * @param size defines the size of the textures
  12218. * @param format defines the format of the data
  12219. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12220. * @param generateMipMaps defines if the engine should generate the mip levels
  12221. * @param invertY defines if data must be stored with Y axis inverted
  12222. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12223. * @param compression defines the compression used (null by default)
  12224. * @returns the cube texture as an InternalTexture
  12225. */
  12226. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12227. /**
  12228. * Update a raw cube texture
  12229. * @param texture defines the texture to udpdate
  12230. * @param data defines the data to store
  12231. * @param format defines the data format
  12232. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12233. * @param invertY defines if data must be stored with Y axis inverted
  12234. */
  12235. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12236. /**
  12237. * Update a raw cube texture
  12238. * @param texture defines the texture to udpdate
  12239. * @param data defines the data to store
  12240. * @param format defines the data format
  12241. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12242. * @param invertY defines if data must be stored with Y axis inverted
  12243. * @param compression defines the compression used (null by default)
  12244. */
  12245. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12246. /**
  12247. * Update a raw cube texture
  12248. * @param texture defines the texture to udpdate
  12249. * @param data defines the data to store
  12250. * @param format defines the data format
  12251. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12252. * @param invertY defines if data must be stored with Y axis inverted
  12253. * @param compression defines the compression used (null by default)
  12254. * @param level defines which level of the texture to update
  12255. */
  12256. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12257. /**
  12258. * Creates a new raw cube texture from a specified url
  12259. * @param url defines the url where the data is located
  12260. * @param scene defines the current scene
  12261. * @param size defines the size of the textures
  12262. * @param format defines the format of the data
  12263. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12264. * @param noMipmap defines if the engine should avoid generating the mip levels
  12265. * @param callback defines a callback used to extract texture data from loaded data
  12266. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12267. * @param onLoad defines a callback called when texture is loaded
  12268. * @param onError defines a callback called if there is an error
  12269. * @returns the cube texture as an InternalTexture
  12270. */
  12271. 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;
  12272. /**
  12273. * Creates a new raw cube texture from a specified url
  12274. * @param url defines the url where the data is located
  12275. * @param scene defines the current scene
  12276. * @param size defines the size of the textures
  12277. * @param format defines the format of the data
  12278. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12279. * @param noMipmap defines if the engine should avoid generating the mip levels
  12280. * @param callback defines a callback used to extract texture data from loaded data
  12281. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12282. * @param onLoad defines a callback called when texture is loaded
  12283. * @param onError defines a callback called if there is an error
  12284. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12285. * @param invertY defines if data must be stored with Y axis inverted
  12286. * @returns the cube texture as an InternalTexture
  12287. */
  12288. 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;
  12289. /**
  12290. * Creates a new raw 3D texture
  12291. * @param data defines the data used to create the texture
  12292. * @param width defines the width of the texture
  12293. * @param height defines the height of the texture
  12294. * @param depth defines the depth of the texture
  12295. * @param format defines the format of the texture
  12296. * @param generateMipMaps defines if the engine must generate mip levels
  12297. * @param invertY defines if data must be stored with Y axis inverted
  12298. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12299. * @param compression defines the compressed used (can be null)
  12300. * @param textureType defines the compressed used (can be null)
  12301. * @returns a new raw 3D texture (stored in an InternalTexture)
  12302. */
  12303. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12304. /**
  12305. * Update a raw 3D texture
  12306. * @param texture defines the texture to update
  12307. * @param data defines the data to store
  12308. * @param format defines the data format
  12309. * @param invertY defines if data must be stored with Y axis inverted
  12310. */
  12311. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12312. /**
  12313. * Update a raw 3D texture
  12314. * @param texture defines the texture to update
  12315. * @param data defines the data to store
  12316. * @param format defines the data format
  12317. * @param invertY defines if data must be stored with Y axis inverted
  12318. * @param compression defines the used compression (can be null)
  12319. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12320. */
  12321. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12322. }
  12323. }
  12324. declare module BABYLON {
  12325. /**
  12326. * Raw texture can help creating a texture directly from an array of data.
  12327. * This can be super useful if you either get the data from an uncompressed source or
  12328. * if you wish to create your texture pixel by pixel.
  12329. */
  12330. export class RawTexture extends Texture {
  12331. /**
  12332. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12333. */
  12334. format: number;
  12335. private _engine;
  12336. /**
  12337. * Instantiates a new RawTexture.
  12338. * Raw texture can help creating a texture directly from an array of data.
  12339. * This can be super useful if you either get the data from an uncompressed source or
  12340. * if you wish to create your texture pixel by pixel.
  12341. * @param data define the array of data to use to create the texture
  12342. * @param width define the width of the texture
  12343. * @param height define the height of the texture
  12344. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12345. * @param scene define the scene the texture belongs to
  12346. * @param generateMipMaps define whether mip maps should be generated or not
  12347. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12348. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12349. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12350. */
  12351. constructor(data: ArrayBufferView, width: number, height: number,
  12352. /**
  12353. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12354. */
  12355. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12356. /**
  12357. * Updates the texture underlying data.
  12358. * @param data Define the new data of the texture
  12359. */
  12360. update(data: ArrayBufferView): void;
  12361. /**
  12362. * Creates a luminance texture from some data.
  12363. * @param data Define the texture data
  12364. * @param width Define the width of the texture
  12365. * @param height Define the height of the texture
  12366. * @param scene Define the scene the texture belongs to
  12367. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12368. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12369. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12370. * @returns the luminance texture
  12371. */
  12372. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12373. /**
  12374. * Creates a luminance alpha texture from some data.
  12375. * @param data Define the texture data
  12376. * @param width Define the width of the texture
  12377. * @param height Define the height of the texture
  12378. * @param scene Define the scene the texture belongs to
  12379. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12380. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12381. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12382. * @returns the luminance alpha texture
  12383. */
  12384. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12385. /**
  12386. * Creates an alpha texture from some data.
  12387. * @param data Define the texture data
  12388. * @param width Define the width of the texture
  12389. * @param height Define the height of the texture
  12390. * @param scene Define the scene the texture belongs to
  12391. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12392. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12393. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12394. * @returns the alpha texture
  12395. */
  12396. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12397. /**
  12398. * Creates a RGB texture from some data.
  12399. * @param data Define the texture data
  12400. * @param width Define the width of the texture
  12401. * @param height Define the height of the texture
  12402. * @param scene Define the scene the texture belongs to
  12403. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12404. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12405. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12406. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12407. * @returns the RGB alpha texture
  12408. */
  12409. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12410. /**
  12411. * Creates a RGBA texture from some data.
  12412. * @param data Define the texture data
  12413. * @param width Define the width of the texture
  12414. * @param height Define the height of the texture
  12415. * @param scene Define the scene the texture belongs to
  12416. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12417. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12418. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12419. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12420. * @returns the RGBA texture
  12421. */
  12422. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12423. /**
  12424. * Creates a R texture from some data.
  12425. * @param data Define the texture data
  12426. * @param width Define the width of the texture
  12427. * @param height Define the height of the texture
  12428. * @param scene Define the scene the texture belongs to
  12429. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12430. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12431. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12432. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12433. * @returns the R texture
  12434. */
  12435. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12436. }
  12437. }
  12438. declare module BABYLON {
  12439. /**
  12440. * Interface for the size containing width and height
  12441. */
  12442. export interface ISize {
  12443. /**
  12444. * Width
  12445. */
  12446. width: number;
  12447. /**
  12448. * Heighht
  12449. */
  12450. height: number;
  12451. }
  12452. /**
  12453. * Size containing widht and height
  12454. */
  12455. export class Size implements ISize {
  12456. /**
  12457. * Width
  12458. */
  12459. width: number;
  12460. /**
  12461. * Height
  12462. */
  12463. height: number;
  12464. /**
  12465. * Creates a Size object from the given width and height (floats).
  12466. * @param width width of the new size
  12467. * @param height height of the new size
  12468. */
  12469. constructor(width: number, height: number);
  12470. /**
  12471. * Returns a string with the Size width and height
  12472. * @returns a string with the Size width and height
  12473. */
  12474. toString(): string;
  12475. /**
  12476. * "Size"
  12477. * @returns the string "Size"
  12478. */
  12479. getClassName(): string;
  12480. /**
  12481. * Returns the Size hash code.
  12482. * @returns a hash code for a unique width and height
  12483. */
  12484. getHashCode(): number;
  12485. /**
  12486. * Updates the current size from the given one.
  12487. * @param src the given size
  12488. */
  12489. copyFrom(src: Size): void;
  12490. /**
  12491. * Updates in place the current Size from the given floats.
  12492. * @param width width of the new size
  12493. * @param height height of the new size
  12494. * @returns the updated Size.
  12495. */
  12496. copyFromFloats(width: number, height: number): Size;
  12497. /**
  12498. * Updates in place the current Size from the given floats.
  12499. * @param width width to set
  12500. * @param height height to set
  12501. * @returns the updated Size.
  12502. */
  12503. set(width: number, height: number): Size;
  12504. /**
  12505. * Multiplies the width and height by numbers
  12506. * @param w factor to multiple the width by
  12507. * @param h factor to multiple the height by
  12508. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12509. */
  12510. multiplyByFloats(w: number, h: number): Size;
  12511. /**
  12512. * Clones the size
  12513. * @returns a new Size copied from the given one.
  12514. */
  12515. clone(): Size;
  12516. /**
  12517. * True if the current Size and the given one width and height are strictly equal.
  12518. * @param other the other size to compare against
  12519. * @returns True if the current Size and the given one width and height are strictly equal.
  12520. */
  12521. equals(other: Size): boolean;
  12522. /**
  12523. * The surface of the Size : width * height (float).
  12524. */
  12525. readonly surface: number;
  12526. /**
  12527. * Create a new size of zero
  12528. * @returns a new Size set to (0.0, 0.0)
  12529. */
  12530. static Zero(): Size;
  12531. /**
  12532. * Sums the width and height of two sizes
  12533. * @param otherSize size to add to this size
  12534. * @returns a new Size set as the addition result of the current Size and the given one.
  12535. */
  12536. add(otherSize: Size): Size;
  12537. /**
  12538. * Subtracts the width and height of two
  12539. * @param otherSize size to subtract to this size
  12540. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12541. */
  12542. subtract(otherSize: Size): Size;
  12543. /**
  12544. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12545. * @param start starting size to lerp between
  12546. * @param end end size to lerp between
  12547. * @param amount amount to lerp between the start and end values
  12548. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12549. */
  12550. static Lerp(start: Size, end: Size, amount: number): Size;
  12551. }
  12552. }
  12553. declare module BABYLON {
  12554. /**
  12555. * Defines a runtime animation
  12556. */
  12557. export class RuntimeAnimation {
  12558. private _events;
  12559. /**
  12560. * The current frame of the runtime animation
  12561. */
  12562. private _currentFrame;
  12563. /**
  12564. * The animation used by the runtime animation
  12565. */
  12566. private _animation;
  12567. /**
  12568. * The target of the runtime animation
  12569. */
  12570. private _target;
  12571. /**
  12572. * The initiating animatable
  12573. */
  12574. private _host;
  12575. /**
  12576. * The original value of the runtime animation
  12577. */
  12578. private _originalValue;
  12579. /**
  12580. * The original blend value of the runtime animation
  12581. */
  12582. private _originalBlendValue;
  12583. /**
  12584. * The offsets cache of the runtime animation
  12585. */
  12586. private _offsetsCache;
  12587. /**
  12588. * The high limits cache of the runtime animation
  12589. */
  12590. private _highLimitsCache;
  12591. /**
  12592. * Specifies if the runtime animation has been stopped
  12593. */
  12594. private _stopped;
  12595. /**
  12596. * The blending factor of the runtime animation
  12597. */
  12598. private _blendingFactor;
  12599. /**
  12600. * The BabylonJS scene
  12601. */
  12602. private _scene;
  12603. /**
  12604. * The current value of the runtime animation
  12605. */
  12606. private _currentValue;
  12607. /** @hidden */ private _animationState: _IAnimationState;
  12608. /**
  12609. * The active target of the runtime animation
  12610. */
  12611. private _activeTargets;
  12612. private _currentActiveTarget;
  12613. private _directTarget;
  12614. /**
  12615. * The target path of the runtime animation
  12616. */
  12617. private _targetPath;
  12618. /**
  12619. * The weight of the runtime animation
  12620. */
  12621. private _weight;
  12622. /**
  12623. * The ratio offset of the runtime animation
  12624. */
  12625. private _ratioOffset;
  12626. /**
  12627. * The previous delay of the runtime animation
  12628. */
  12629. private _previousDelay;
  12630. /**
  12631. * The previous ratio of the runtime animation
  12632. */
  12633. private _previousRatio;
  12634. private _enableBlending;
  12635. private _keys;
  12636. private _minFrame;
  12637. private _maxFrame;
  12638. private _minValue;
  12639. private _maxValue;
  12640. private _targetIsArray;
  12641. /**
  12642. * Gets the current frame of the runtime animation
  12643. */
  12644. readonly currentFrame: number;
  12645. /**
  12646. * Gets the weight of the runtime animation
  12647. */
  12648. readonly weight: number;
  12649. /**
  12650. * Gets the current value of the runtime animation
  12651. */
  12652. readonly currentValue: any;
  12653. /**
  12654. * Gets the target path of the runtime animation
  12655. */
  12656. readonly targetPath: string;
  12657. /**
  12658. * Gets the actual target of the runtime animation
  12659. */
  12660. readonly target: any;
  12661. /** @hidden */ private _onLoop: () => void;
  12662. /**
  12663. * Create a new RuntimeAnimation object
  12664. * @param target defines the target of the animation
  12665. * @param animation defines the source animation object
  12666. * @param scene defines the hosting scene
  12667. * @param host defines the initiating Animatable
  12668. */
  12669. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12670. private _preparePath;
  12671. /**
  12672. * Gets the animation from the runtime animation
  12673. */
  12674. readonly animation: Animation;
  12675. /**
  12676. * Resets the runtime animation to the beginning
  12677. * @param restoreOriginal defines whether to restore the target property to the original value
  12678. */
  12679. reset(restoreOriginal?: boolean): void;
  12680. /**
  12681. * Specifies if the runtime animation is stopped
  12682. * @returns Boolean specifying if the runtime animation is stopped
  12683. */
  12684. isStopped(): boolean;
  12685. /**
  12686. * Disposes of the runtime animation
  12687. */
  12688. dispose(): void;
  12689. /**
  12690. * Apply the interpolated value to the target
  12691. * @param currentValue defines the value computed by the animation
  12692. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12693. */
  12694. setValue(currentValue: any, weight: number): void;
  12695. private _getOriginalValues;
  12696. private _setValue;
  12697. /**
  12698. * Gets the loop pmode of the runtime animation
  12699. * @returns Loop Mode
  12700. */
  12701. private _getCorrectLoopMode;
  12702. /**
  12703. * Move the current animation to a given frame
  12704. * @param frame defines the frame to move to
  12705. */
  12706. goToFrame(frame: number): void;
  12707. /**
  12708. * @hidden Internal use only
  12709. */ private _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12710. /**
  12711. * Execute the current animation
  12712. * @param delay defines the delay to add to the current frame
  12713. * @param from defines the lower bound of the animation range
  12714. * @param to defines the upper bound of the animation range
  12715. * @param loop defines if the current animation must loop
  12716. * @param speedRatio defines the current speed ratio
  12717. * @param weight defines the weight of the animation (default is -1 so no weight)
  12718. * @param onLoop optional callback called when animation loops
  12719. * @returns a boolean indicating if the animation is running
  12720. */
  12721. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12722. }
  12723. }
  12724. declare module BABYLON {
  12725. /**
  12726. * Class used to store an actual running animation
  12727. */
  12728. export class Animatable {
  12729. /** defines the target object */
  12730. target: any;
  12731. /** defines the starting frame number (default is 0) */
  12732. fromFrame: number;
  12733. /** defines the ending frame number (default is 100) */
  12734. toFrame: number;
  12735. /** defines if the animation must loop (default is false) */
  12736. loopAnimation: boolean;
  12737. /** defines a callback to call when animation ends if it is not looping */
  12738. onAnimationEnd?: (() => void) | null | undefined;
  12739. /** defines a callback to call when animation loops */
  12740. onAnimationLoop?: (() => void) | null | undefined;
  12741. private _localDelayOffset;
  12742. private _pausedDelay;
  12743. private _runtimeAnimations;
  12744. private _paused;
  12745. private _scene;
  12746. private _speedRatio;
  12747. private _weight;
  12748. private _syncRoot;
  12749. /**
  12750. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12751. * This will only apply for non looping animation (default is true)
  12752. */
  12753. disposeOnEnd: boolean;
  12754. /**
  12755. * Gets a boolean indicating if the animation has started
  12756. */
  12757. animationStarted: boolean;
  12758. /**
  12759. * Observer raised when the animation ends
  12760. */
  12761. onAnimationEndObservable: Observable<Animatable>;
  12762. /**
  12763. * Observer raised when the animation loops
  12764. */
  12765. onAnimationLoopObservable: Observable<Animatable>;
  12766. /**
  12767. * Gets the root Animatable used to synchronize and normalize animations
  12768. */
  12769. readonly syncRoot: Nullable<Animatable>;
  12770. /**
  12771. * Gets the current frame of the first RuntimeAnimation
  12772. * Used to synchronize Animatables
  12773. */
  12774. readonly masterFrame: number;
  12775. /**
  12776. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12777. */
  12778. weight: number;
  12779. /**
  12780. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12781. */
  12782. speedRatio: number;
  12783. /**
  12784. * Creates a new Animatable
  12785. * @param scene defines the hosting scene
  12786. * @param target defines the target object
  12787. * @param fromFrame defines the starting frame number (default is 0)
  12788. * @param toFrame defines the ending frame number (default is 100)
  12789. * @param loopAnimation defines if the animation must loop (default is false)
  12790. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  12791. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  12792. * @param animations defines a group of animation to add to the new Animatable
  12793. * @param onAnimationLoop defines a callback to call when animation loops
  12794. */
  12795. constructor(scene: Scene,
  12796. /** defines the target object */
  12797. target: any,
  12798. /** defines the starting frame number (default is 0) */
  12799. fromFrame?: number,
  12800. /** defines the ending frame number (default is 100) */
  12801. toFrame?: number,
  12802. /** defines if the animation must loop (default is false) */
  12803. loopAnimation?: boolean, speedRatio?: number,
  12804. /** defines a callback to call when animation ends if it is not looping */
  12805. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  12806. /** defines a callback to call when animation loops */
  12807. onAnimationLoop?: (() => void) | null | undefined);
  12808. /**
  12809. * Synchronize and normalize current Animatable with a source Animatable
  12810. * This is useful when using animation weights and when animations are not of the same length
  12811. * @param root defines the root Animatable to synchronize with
  12812. * @returns the current Animatable
  12813. */
  12814. syncWith(root: Animatable): Animatable;
  12815. /**
  12816. * Gets the list of runtime animations
  12817. * @returns an array of RuntimeAnimation
  12818. */
  12819. getAnimations(): RuntimeAnimation[];
  12820. /**
  12821. * Adds more animations to the current animatable
  12822. * @param target defines the target of the animations
  12823. * @param animations defines the new animations to add
  12824. */
  12825. appendAnimations(target: any, animations: Animation[]): void;
  12826. /**
  12827. * Gets the source animation for a specific property
  12828. * @param property defines the propertyu to look for
  12829. * @returns null or the source animation for the given property
  12830. */
  12831. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  12832. /**
  12833. * Gets the runtime animation for a specific property
  12834. * @param property defines the propertyu to look for
  12835. * @returns null or the runtime animation for the given property
  12836. */
  12837. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  12838. /**
  12839. * Resets the animatable to its original state
  12840. */
  12841. reset(): void;
  12842. /**
  12843. * Allows the animatable to blend with current running animations
  12844. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12845. * @param blendingSpeed defines the blending speed to use
  12846. */
  12847. enableBlending(blendingSpeed: number): void;
  12848. /**
  12849. * Disable animation blending
  12850. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12851. */
  12852. disableBlending(): void;
  12853. /**
  12854. * Jump directly to a given frame
  12855. * @param frame defines the frame to jump to
  12856. */
  12857. goToFrame(frame: number): void;
  12858. /**
  12859. * Pause the animation
  12860. */
  12861. pause(): void;
  12862. /**
  12863. * Restart the animation
  12864. */
  12865. restart(): void;
  12866. private _raiseOnAnimationEnd;
  12867. /**
  12868. * Stop and delete the current animation
  12869. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  12870. * @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)
  12871. */
  12872. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  12873. /**
  12874. * Wait asynchronously for the animation to end
  12875. * @returns a promise which will be fullfilled when the animation ends
  12876. */
  12877. waitAsync(): Promise<Animatable>;
  12878. /** @hidden */ private _animate(delay: number): boolean;
  12879. }
  12880. interface Scene {
  12881. /** @hidden */ private _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  12882. /** @hidden */ private _processLateAnimationBindingsForMatrices(holder: {
  12883. totalWeight: number;
  12884. animations: RuntimeAnimation[];
  12885. originalValue: Matrix;
  12886. }): any;
  12887. /** @hidden */ private _processLateAnimationBindingsForQuaternions(holder: {
  12888. totalWeight: number;
  12889. animations: RuntimeAnimation[];
  12890. originalValue: Quaternion;
  12891. }, refQuaternion: Quaternion): Quaternion;
  12892. /** @hidden */ private _processLateAnimationBindings(): void;
  12893. /**
  12894. * Will start the animation sequence of a given target
  12895. * @param target defines the target
  12896. * @param from defines from which frame should animation start
  12897. * @param to defines until which frame should animation run.
  12898. * @param weight defines the weight to apply to the animation (1.0 by default)
  12899. * @param loop defines if the animation loops
  12900. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12901. * @param onAnimationEnd defines the function to be executed when the animation ends
  12902. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12903. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12904. * @param onAnimationLoop defines the callback to call when an animation loops
  12905. * @returns the animatable object created for this animation
  12906. */
  12907. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12908. /**
  12909. * Will start the animation sequence of a given target
  12910. * @param target defines the target
  12911. * @param from defines from which frame should animation start
  12912. * @param to defines until which frame should animation run.
  12913. * @param loop defines if the animation loops
  12914. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12915. * @param onAnimationEnd defines the function to be executed when the animation ends
  12916. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12917. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12918. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  12919. * @param onAnimationLoop defines the callback to call when an animation loops
  12920. * @returns the animatable object created for this animation
  12921. */
  12922. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12923. /**
  12924. * Will start the animation sequence of a given target and its hierarchy
  12925. * @param target defines the target
  12926. * @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.
  12927. * @param from defines from which frame should animation start
  12928. * @param to defines until which frame should animation run.
  12929. * @param loop defines if the animation loops
  12930. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12931. * @param onAnimationEnd defines the function to be executed when the animation ends
  12932. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12933. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12934. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12935. * @param onAnimationLoop defines the callback to call when an animation loops
  12936. * @returns the list of created animatables
  12937. */
  12938. 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[];
  12939. /**
  12940. * Begin a new animation on a given node
  12941. * @param target defines the target where the animation will take place
  12942. * @param animations defines the list of animations to start
  12943. * @param from defines the initial value
  12944. * @param to defines the final value
  12945. * @param loop defines if you want animation to loop (off by default)
  12946. * @param speedRatio defines the speed ratio to apply to all animations
  12947. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  12948. * @param onAnimationLoop defines the callback to call when an animation loops
  12949. * @returns the list of created animatables
  12950. */
  12951. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  12952. /**
  12953. * Begin a new animation on a given node and its hierarchy
  12954. * @param target defines the root node where the animation will take place
  12955. * @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.
  12956. * @param animations defines the list of animations to start
  12957. * @param from defines the initial value
  12958. * @param to defines the final value
  12959. * @param loop defines if you want animation to loop (off by default)
  12960. * @param speedRatio defines the speed ratio to apply to all animations
  12961. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  12962. * @param onAnimationLoop defines the callback to call when an animation loops
  12963. * @returns the list of animatables created for all nodes
  12964. */
  12965. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  12966. /**
  12967. * Gets the animatable associated with a specific target
  12968. * @param target defines the target of the animatable
  12969. * @returns the required animatable if found
  12970. */
  12971. getAnimatableByTarget(target: any): Nullable<Animatable>;
  12972. /**
  12973. * Gets all animatables associated with a given target
  12974. * @param target defines the target to look animatables for
  12975. * @returns an array of Animatables
  12976. */
  12977. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  12978. /**
  12979. * Stops and removes all animations that have been applied to the scene
  12980. */
  12981. stopAllAnimations(): void;
  12982. /**
  12983. * Gets the current delta time used by animation engine
  12984. */
  12985. deltaTime: number;
  12986. }
  12987. interface Bone {
  12988. /**
  12989. * Copy an animation range from another bone
  12990. * @param source defines the source bone
  12991. * @param rangeName defines the range name to copy
  12992. * @param frameOffset defines the frame offset
  12993. * @param rescaleAsRequired defines if rescaling must be applied if required
  12994. * @param skelDimensionsRatio defines the scaling ratio
  12995. * @returns true if operation was successful
  12996. */
  12997. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  12998. }
  12999. }
  13000. declare module BABYLON {
  13001. /**
  13002. * Class used to override all child animations of a given target
  13003. */
  13004. export class AnimationPropertiesOverride {
  13005. /**
  13006. * Gets or sets a value indicating if animation blending must be used
  13007. */
  13008. enableBlending: boolean;
  13009. /**
  13010. * Gets or sets the blending speed to use when enableBlending is true
  13011. */
  13012. blendingSpeed: number;
  13013. /**
  13014. * Gets or sets the default loop mode to use
  13015. */
  13016. loopMode: number;
  13017. }
  13018. }
  13019. declare module BABYLON {
  13020. /**
  13021. * Class used to handle skinning animations
  13022. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13023. */
  13024. export class Skeleton implements IAnimatable {
  13025. /** defines the skeleton name */
  13026. name: string;
  13027. /** defines the skeleton Id */
  13028. id: string;
  13029. /**
  13030. * Defines the list of child bones
  13031. */
  13032. bones: Bone[];
  13033. /**
  13034. * Defines an estimate of the dimension of the skeleton at rest
  13035. */
  13036. dimensionsAtRest: Vector3;
  13037. /**
  13038. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13039. */
  13040. needInitialSkinMatrix: boolean;
  13041. /**
  13042. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13043. */
  13044. overrideMesh: Nullable<AbstractMesh>;
  13045. /**
  13046. * Gets the list of animations attached to this skeleton
  13047. */
  13048. animations: Array<Animation>;
  13049. private _scene;
  13050. private _isDirty;
  13051. private _transformMatrices;
  13052. private _transformMatrixTexture;
  13053. private _meshesWithPoseMatrix;
  13054. private _animatables;
  13055. private _identity;
  13056. private _synchronizedWithMesh;
  13057. private _ranges;
  13058. private _lastAbsoluteTransformsUpdateId;
  13059. private _canUseTextureForBones;
  13060. private _uniqueId;
  13061. /** @hidden */ private _numBonesWithLinkedTransformNode: number;
  13062. /** @hidden */ private _hasWaitingData: Nullable<boolean>;
  13063. /**
  13064. * Specifies if the skeleton should be serialized
  13065. */
  13066. doNotSerialize: boolean;
  13067. private _useTextureToStoreBoneMatrices;
  13068. /**
  13069. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13070. * Please note that this option is not available if the hardware does not support it
  13071. */
  13072. useTextureToStoreBoneMatrices: boolean;
  13073. private _animationPropertiesOverride;
  13074. /**
  13075. * Gets or sets the animation properties override
  13076. */
  13077. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13078. /**
  13079. * List of inspectable custom properties (used by the Inspector)
  13080. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13081. */
  13082. inspectableCustomProperties: IInspectable[];
  13083. /**
  13084. * An observable triggered before computing the skeleton's matrices
  13085. */
  13086. onBeforeComputeObservable: Observable<Skeleton>;
  13087. /**
  13088. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13089. */
  13090. readonly isUsingTextureForMatrices: boolean;
  13091. /**
  13092. * Gets the unique ID of this skeleton
  13093. */
  13094. readonly uniqueId: number;
  13095. /**
  13096. * Creates a new skeleton
  13097. * @param name defines the skeleton name
  13098. * @param id defines the skeleton Id
  13099. * @param scene defines the hosting scene
  13100. */
  13101. constructor(
  13102. /** defines the skeleton name */
  13103. name: string,
  13104. /** defines the skeleton Id */
  13105. id: string, scene: Scene);
  13106. /**
  13107. * Gets the current object class name.
  13108. * @return the class name
  13109. */
  13110. getClassName(): string;
  13111. /**
  13112. * Returns an array containing the root bones
  13113. * @returns an array containing the root bones
  13114. */
  13115. getChildren(): Array<Bone>;
  13116. /**
  13117. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13118. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13119. * @returns a Float32Array containing matrices data
  13120. */
  13121. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13122. /**
  13123. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13124. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13125. * @returns a raw texture containing the data
  13126. */
  13127. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13128. /**
  13129. * Gets the current hosting scene
  13130. * @returns a scene object
  13131. */
  13132. getScene(): Scene;
  13133. /**
  13134. * Gets a string representing the current skeleton data
  13135. * @param fullDetails defines a boolean indicating if we want a verbose version
  13136. * @returns a string representing the current skeleton data
  13137. */
  13138. toString(fullDetails?: boolean): string;
  13139. /**
  13140. * Get bone's index searching by name
  13141. * @param name defines bone's name to search for
  13142. * @return the indice of the bone. Returns -1 if not found
  13143. */
  13144. getBoneIndexByName(name: string): number;
  13145. /**
  13146. * Creater a new animation range
  13147. * @param name defines the name of the range
  13148. * @param from defines the start key
  13149. * @param to defines the end key
  13150. */
  13151. createAnimationRange(name: string, from: number, to: number): void;
  13152. /**
  13153. * Delete a specific animation range
  13154. * @param name defines the name of the range
  13155. * @param deleteFrames defines if frames must be removed as well
  13156. */
  13157. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13158. /**
  13159. * Gets a specific animation range
  13160. * @param name defines the name of the range to look for
  13161. * @returns the requested animation range or null if not found
  13162. */
  13163. getAnimationRange(name: string): Nullable<AnimationRange>;
  13164. /**
  13165. * Gets the list of all animation ranges defined on this skeleton
  13166. * @returns an array
  13167. */
  13168. getAnimationRanges(): Nullable<AnimationRange>[];
  13169. /**
  13170. * Copy animation range from a source skeleton.
  13171. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13172. * @param source defines the source skeleton
  13173. * @param name defines the name of the range to copy
  13174. * @param rescaleAsRequired defines if rescaling must be applied if required
  13175. * @returns true if operation was successful
  13176. */
  13177. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13178. /**
  13179. * Forces the skeleton to go to rest pose
  13180. */
  13181. returnToRest(): void;
  13182. private _getHighestAnimationFrame;
  13183. /**
  13184. * Begin a specific animation range
  13185. * @param name defines the name of the range to start
  13186. * @param loop defines if looping must be turned on (false by default)
  13187. * @param speedRatio defines the speed ratio to apply (1 by default)
  13188. * @param onAnimationEnd defines a callback which will be called when animation will end
  13189. * @returns a new animatable
  13190. */
  13191. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13192. /** @hidden */ private _markAsDirty(): void;
  13193. /** @hidden */ private _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13194. /** @hidden */ private _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13195. private _computeTransformMatrices;
  13196. /**
  13197. * Build all resources required to render a skeleton
  13198. */
  13199. prepare(): void;
  13200. /**
  13201. * Gets the list of animatables currently running for this skeleton
  13202. * @returns an array of animatables
  13203. */
  13204. getAnimatables(): IAnimatable[];
  13205. /**
  13206. * Clone the current skeleton
  13207. * @param name defines the name of the new skeleton
  13208. * @param id defines the id of the new skeleton
  13209. * @returns the new skeleton
  13210. */
  13211. clone(name: string, id: string): Skeleton;
  13212. /**
  13213. * Enable animation blending for this skeleton
  13214. * @param blendingSpeed defines the blending speed to apply
  13215. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13216. */
  13217. enableBlending(blendingSpeed?: number): void;
  13218. /**
  13219. * Releases all resources associated with the current skeleton
  13220. */
  13221. dispose(): void;
  13222. /**
  13223. * Serialize the skeleton in a JSON object
  13224. * @returns a JSON object
  13225. */
  13226. serialize(): any;
  13227. /**
  13228. * Creates a new skeleton from serialized data
  13229. * @param parsedSkeleton defines the serialized data
  13230. * @param scene defines the hosting scene
  13231. * @returns a new skeleton
  13232. */
  13233. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13234. /**
  13235. * Compute all node absolute transforms
  13236. * @param forceUpdate defines if computation must be done even if cache is up to date
  13237. */
  13238. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13239. /**
  13240. * Gets the root pose matrix
  13241. * @returns a matrix
  13242. */
  13243. getPoseMatrix(): Nullable<Matrix>;
  13244. /**
  13245. * Sorts bones per internal index
  13246. */
  13247. sortBones(): void;
  13248. private _sortBones;
  13249. }
  13250. }
  13251. declare module BABYLON {
  13252. /**
  13253. * Class used to store bone information
  13254. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13255. */
  13256. export class Bone extends Node {
  13257. /**
  13258. * defines the bone name
  13259. */
  13260. name: string;
  13261. private static _tmpVecs;
  13262. private static _tmpQuat;
  13263. private static _tmpMats;
  13264. /**
  13265. * Gets the list of child bones
  13266. */
  13267. children: Bone[];
  13268. /** Gets the animations associated with this bone */
  13269. animations: Animation[];
  13270. /**
  13271. * Gets or sets bone length
  13272. */
  13273. length: number;
  13274. /**
  13275. * @hidden Internal only
  13276. * Set this value to map this bone to a different index in the transform matrices
  13277. * Set this value to -1 to exclude the bone from the transform matrices
  13278. */ private _index: Nullable<number>;
  13279. private _skeleton;
  13280. private _localMatrix;
  13281. private _restPose;
  13282. private _baseMatrix;
  13283. private _absoluteTransform;
  13284. private _invertedAbsoluteTransform;
  13285. private _parent;
  13286. private _scalingDeterminant;
  13287. private _worldTransform;
  13288. private _localScaling;
  13289. private _localRotation;
  13290. private _localPosition;
  13291. private _needToDecompose;
  13292. private _needToCompose;
  13293. /** @hidden */ private _linkedTransformNode: Nullable<TransformNode>;
  13294. /** @hidden */ private _waitingTransformNodeId: Nullable<string>;
  13295. /** @hidden */
  13296. /** @hidden */ private _matrix: Matrix;
  13297. /**
  13298. * Create a new bone
  13299. * @param name defines the bone name
  13300. * @param skeleton defines the parent skeleton
  13301. * @param parentBone defines the parent (can be null if the bone is the root)
  13302. * @param localMatrix defines the local matrix
  13303. * @param restPose defines the rest pose matrix
  13304. * @param baseMatrix defines the base matrix
  13305. * @param index defines index of the bone in the hiearchy
  13306. */
  13307. constructor(
  13308. /**
  13309. * defines the bone name
  13310. */
  13311. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13312. /**
  13313. * Gets the current object class name.
  13314. * @return the class name
  13315. */
  13316. getClassName(): string;
  13317. /**
  13318. * Gets the parent skeleton
  13319. * @returns a skeleton
  13320. */
  13321. getSkeleton(): Skeleton;
  13322. /**
  13323. * Gets parent bone
  13324. * @returns a bone or null if the bone is the root of the bone hierarchy
  13325. */
  13326. getParent(): Nullable<Bone>;
  13327. /**
  13328. * Returns an array containing the root bones
  13329. * @returns an array containing the root bones
  13330. */
  13331. getChildren(): Array<Bone>;
  13332. /**
  13333. * Sets the parent bone
  13334. * @param parent defines the parent (can be null if the bone is the root)
  13335. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13336. */
  13337. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13338. /**
  13339. * Gets the local matrix
  13340. * @returns a matrix
  13341. */
  13342. getLocalMatrix(): Matrix;
  13343. /**
  13344. * Gets the base matrix (initial matrix which remains unchanged)
  13345. * @returns a matrix
  13346. */
  13347. getBaseMatrix(): Matrix;
  13348. /**
  13349. * Gets the rest pose matrix
  13350. * @returns a matrix
  13351. */
  13352. getRestPose(): Matrix;
  13353. /**
  13354. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13355. */
  13356. getWorldMatrix(): Matrix;
  13357. /**
  13358. * Sets the local matrix to rest pose matrix
  13359. */
  13360. returnToRest(): void;
  13361. /**
  13362. * Gets the inverse of the absolute transform matrix.
  13363. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13364. * @returns a matrix
  13365. */
  13366. getInvertedAbsoluteTransform(): Matrix;
  13367. /**
  13368. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13369. * @returns a matrix
  13370. */
  13371. getAbsoluteTransform(): Matrix;
  13372. /**
  13373. * Links with the given transform node.
  13374. * The local matrix of this bone is copied from the transform node every frame.
  13375. * @param transformNode defines the transform node to link to
  13376. */
  13377. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13378. /**
  13379. * Gets the node used to drive the bone's transformation
  13380. * @returns a transform node or null
  13381. */
  13382. getTransformNode(): Nullable<TransformNode>;
  13383. /** Gets or sets current position (in local space) */
  13384. position: Vector3;
  13385. /** Gets or sets current rotation (in local space) */
  13386. rotation: Vector3;
  13387. /** Gets or sets current rotation quaternion (in local space) */
  13388. rotationQuaternion: Quaternion;
  13389. /** Gets or sets current scaling (in local space) */
  13390. scaling: Vector3;
  13391. /**
  13392. * Gets the animation properties override
  13393. */
  13394. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13395. private _decompose;
  13396. private _compose;
  13397. /**
  13398. * Update the base and local matrices
  13399. * @param matrix defines the new base or local matrix
  13400. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13401. * @param updateLocalMatrix defines if the local matrix should be updated
  13402. */
  13403. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13404. /** @hidden */ private _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13405. /**
  13406. * Flag the bone as dirty (Forcing it to update everything)
  13407. */
  13408. markAsDirty(): void;
  13409. /** @hidden */ private _markAsDirtyAndCompose(): void;
  13410. private _markAsDirtyAndDecompose;
  13411. /**
  13412. * Translate the bone in local or world space
  13413. * @param vec The amount to translate the bone
  13414. * @param space The space that the translation is in
  13415. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13416. */
  13417. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13418. /**
  13419. * Set the postion of the bone in local or world space
  13420. * @param position The position to set the bone
  13421. * @param space The space that the position is in
  13422. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13423. */
  13424. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13425. /**
  13426. * Set the absolute position of the bone (world space)
  13427. * @param position The position to set the bone
  13428. * @param mesh The mesh that this bone is attached to
  13429. */
  13430. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13431. /**
  13432. * Scale the bone on the x, y and z axes (in local space)
  13433. * @param x The amount to scale the bone on the x axis
  13434. * @param y The amount to scale the bone on the y axis
  13435. * @param z The amount to scale the bone on the z axis
  13436. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13437. */
  13438. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13439. /**
  13440. * Set the bone scaling in local space
  13441. * @param scale defines the scaling vector
  13442. */
  13443. setScale(scale: Vector3): void;
  13444. /**
  13445. * Gets the current scaling in local space
  13446. * @returns the current scaling vector
  13447. */
  13448. getScale(): Vector3;
  13449. /**
  13450. * Gets the current scaling in local space and stores it in a target vector
  13451. * @param result defines the target vector
  13452. */
  13453. getScaleToRef(result: Vector3): void;
  13454. /**
  13455. * Set the yaw, pitch, and roll of the bone in local or world space
  13456. * @param yaw The rotation of the bone on the y axis
  13457. * @param pitch The rotation of the bone on the x axis
  13458. * @param roll The rotation of the bone on the z axis
  13459. * @param space The space that the axes of rotation are in
  13460. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13461. */
  13462. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13463. /**
  13464. * Add a rotation to the bone on an axis in local or world space
  13465. * @param axis The axis to rotate the bone on
  13466. * @param amount The amount to rotate the bone
  13467. * @param space The space that the axis is in
  13468. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13469. */
  13470. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13471. /**
  13472. * Set the rotation of the bone to a particular axis angle in local or world space
  13473. * @param axis The axis to rotate the bone on
  13474. * @param angle The angle that the bone should be rotated to
  13475. * @param space The space that the axis is in
  13476. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13477. */
  13478. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13479. /**
  13480. * Set the euler rotation of the bone in local of world space
  13481. * @param rotation The euler rotation that the bone should be set to
  13482. * @param space The space that the rotation is in
  13483. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13484. */
  13485. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13486. /**
  13487. * Set the quaternion rotation of the bone in local of world space
  13488. * @param quat The quaternion rotation that the bone should be set to
  13489. * @param space The space that the rotation is in
  13490. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13491. */
  13492. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13493. /**
  13494. * Set the rotation matrix of the bone in local of world space
  13495. * @param rotMat The rotation matrix that the bone should be set to
  13496. * @param space The space that the rotation is in
  13497. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13498. */
  13499. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13500. private _rotateWithMatrix;
  13501. private _getNegativeRotationToRef;
  13502. /**
  13503. * Get the position of the bone in local or world space
  13504. * @param space The space that the returned position is in
  13505. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13506. * @returns The position of the bone
  13507. */
  13508. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13509. /**
  13510. * Copy the position of the bone to a vector3 in local or world space
  13511. * @param space The space that the returned position is in
  13512. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13513. * @param result The vector3 to copy the position to
  13514. */
  13515. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13516. /**
  13517. * Get the absolute position of the bone (world space)
  13518. * @param mesh The mesh that this bone is attached to
  13519. * @returns The absolute position of the bone
  13520. */
  13521. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13522. /**
  13523. * Copy the absolute position of the bone (world space) to the result param
  13524. * @param mesh The mesh that this bone is attached to
  13525. * @param result The vector3 to copy the absolute position to
  13526. */
  13527. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13528. /**
  13529. * Compute the absolute transforms of this bone and its children
  13530. */
  13531. computeAbsoluteTransforms(): void;
  13532. /**
  13533. * Get the world direction from an axis that is in the local space of the bone
  13534. * @param localAxis The local direction that is used to compute the world direction
  13535. * @param mesh The mesh that this bone is attached to
  13536. * @returns The world direction
  13537. */
  13538. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13539. /**
  13540. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13541. * @param localAxis The local direction that is used to compute the world direction
  13542. * @param mesh The mesh that this bone is attached to
  13543. * @param result The vector3 that the world direction will be copied to
  13544. */
  13545. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13546. /**
  13547. * Get the euler rotation of the bone in local or world space
  13548. * @param space The space that the rotation should be in
  13549. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13550. * @returns The euler rotation
  13551. */
  13552. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13553. /**
  13554. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13555. * @param space The space that the rotation should be in
  13556. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13557. * @param result The vector3 that the rotation should be copied to
  13558. */
  13559. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13560. /**
  13561. * Get the quaternion rotation of the bone in either local or world space
  13562. * @param space The space that the rotation should be in
  13563. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13564. * @returns The quaternion rotation
  13565. */
  13566. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13567. /**
  13568. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13569. * @param space The space that the rotation should be in
  13570. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13571. * @param result The quaternion that the rotation should be copied to
  13572. */
  13573. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13574. /**
  13575. * Get the rotation matrix of the bone in local or world space
  13576. * @param space The space that the rotation should be in
  13577. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13578. * @returns The rotation matrix
  13579. */
  13580. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13581. /**
  13582. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13583. * @param space The space that the rotation should be in
  13584. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13585. * @param result The quaternion that the rotation should be copied to
  13586. */
  13587. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13588. /**
  13589. * Get the world position of a point that is in the local space of the bone
  13590. * @param position The local position
  13591. * @param mesh The mesh that this bone is attached to
  13592. * @returns The world position
  13593. */
  13594. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13595. /**
  13596. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13597. * @param position The local position
  13598. * @param mesh The mesh that this bone is attached to
  13599. * @param result The vector3 that the world position should be copied to
  13600. */
  13601. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13602. /**
  13603. * Get the local position of a point that is in world space
  13604. * @param position The world position
  13605. * @param mesh The mesh that this bone is attached to
  13606. * @returns The local position
  13607. */
  13608. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13609. /**
  13610. * Get the local position of a point that is in world space and copy it to the result param
  13611. * @param position The world position
  13612. * @param mesh The mesh that this bone is attached to
  13613. * @param result The vector3 that the local position should be copied to
  13614. */
  13615. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13616. }
  13617. }
  13618. declare module BABYLON {
  13619. /**
  13620. * 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.
  13621. * @see https://doc.babylonjs.com/how_to/transformnode
  13622. */
  13623. export class TransformNode extends Node {
  13624. /**
  13625. * Object will not rotate to face the camera
  13626. */
  13627. static BILLBOARDMODE_NONE: number;
  13628. /**
  13629. * Object will rotate to face the camera but only on the x axis
  13630. */
  13631. static BILLBOARDMODE_X: number;
  13632. /**
  13633. * Object will rotate to face the camera but only on the y axis
  13634. */
  13635. static BILLBOARDMODE_Y: number;
  13636. /**
  13637. * Object will rotate to face the camera but only on the z axis
  13638. */
  13639. static BILLBOARDMODE_Z: number;
  13640. /**
  13641. * Object will rotate to face the camera
  13642. */
  13643. static BILLBOARDMODE_ALL: number;
  13644. /**
  13645. * Object will rotate to face the camera's position instead of orientation
  13646. */
  13647. static BILLBOARDMODE_USE_POSITION: number;
  13648. private _forward;
  13649. private _forwardInverted;
  13650. private _up;
  13651. private _right;
  13652. private _rightInverted;
  13653. private _position;
  13654. private _rotation;
  13655. private _rotationQuaternion;
  13656. protected _scaling: Vector3;
  13657. protected _isDirty: boolean;
  13658. private _transformToBoneReferal;
  13659. private _isAbsoluteSynced;
  13660. private _billboardMode;
  13661. /**
  13662. * Gets or sets the billboard mode. Default is 0.
  13663. *
  13664. * | Value | Type | Description |
  13665. * | --- | --- | --- |
  13666. * | 0 | BILLBOARDMODE_NONE | |
  13667. * | 1 | BILLBOARDMODE_X | |
  13668. * | 2 | BILLBOARDMODE_Y | |
  13669. * | 4 | BILLBOARDMODE_Z | |
  13670. * | 7 | BILLBOARDMODE_ALL | |
  13671. *
  13672. */
  13673. billboardMode: number;
  13674. private _preserveParentRotationForBillboard;
  13675. /**
  13676. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13677. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13678. */
  13679. preserveParentRotationForBillboard: boolean;
  13680. /**
  13681. * 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
  13682. */
  13683. scalingDeterminant: number;
  13684. private _infiniteDistance;
  13685. /**
  13686. * Gets or sets the distance of the object to max, often used by skybox
  13687. */
  13688. infiniteDistance: boolean;
  13689. /**
  13690. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13691. * By default the system will update normals to compensate
  13692. */
  13693. ignoreNonUniformScaling: boolean;
  13694. /**
  13695. * 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
  13696. */
  13697. reIntegrateRotationIntoRotationQuaternion: boolean;
  13698. /** @hidden */ private _poseMatrix: Nullable<Matrix>;
  13699. /** @hidden */ private _localMatrix: Matrix;
  13700. private _usePivotMatrix;
  13701. private _absolutePosition;
  13702. private _absoluteScaling;
  13703. private _absoluteRotationQuaternion;
  13704. private _pivotMatrix;
  13705. private _pivotMatrixInverse;
  13706. protected _postMultiplyPivotMatrix: boolean;
  13707. protected _isWorldMatrixFrozen: boolean;
  13708. /** @hidden */ private _indexInSceneTransformNodesArray: number;
  13709. /**
  13710. * An event triggered after the world matrix is updated
  13711. */
  13712. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13713. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13714. /**
  13715. * Gets a string identifying the name of the class
  13716. * @returns "TransformNode" string
  13717. */
  13718. getClassName(): string;
  13719. /**
  13720. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13721. */
  13722. position: Vector3;
  13723. /**
  13724. * 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)).
  13725. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13726. */
  13727. rotation: Vector3;
  13728. /**
  13729. * 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)).
  13730. */
  13731. scaling: Vector3;
  13732. /**
  13733. * 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).
  13734. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13735. */
  13736. rotationQuaternion: Nullable<Quaternion>;
  13737. /**
  13738. * The forward direction of that transform in world space.
  13739. */
  13740. readonly forward: Vector3;
  13741. /**
  13742. * The up direction of that transform in world space.
  13743. */
  13744. readonly up: Vector3;
  13745. /**
  13746. * The right direction of that transform in world space.
  13747. */
  13748. readonly right: Vector3;
  13749. /**
  13750. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13751. * @param matrix the matrix to copy the pose from
  13752. * @returns this TransformNode.
  13753. */
  13754. updatePoseMatrix(matrix: Matrix): TransformNode;
  13755. /**
  13756. * Returns the mesh Pose matrix.
  13757. * @returns the pose matrix
  13758. */
  13759. getPoseMatrix(): Matrix;
  13760. /** @hidden */ private _isSynchronized(): boolean;
  13761. /** @hidden */ private _initCache(): void;
  13762. /**
  13763. * Flag the transform node as dirty (Forcing it to update everything)
  13764. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13765. * @returns this transform node
  13766. */
  13767. markAsDirty(property: string): TransformNode;
  13768. /**
  13769. * Returns the current mesh absolute position.
  13770. * Returns a Vector3.
  13771. */
  13772. readonly absolutePosition: Vector3;
  13773. /**
  13774. * Returns the current mesh absolute scaling.
  13775. * Returns a Vector3.
  13776. */
  13777. readonly absoluteScaling: Vector3;
  13778. /**
  13779. * Returns the current mesh absolute rotation.
  13780. * Returns a Quaternion.
  13781. */
  13782. readonly absoluteRotationQuaternion: Quaternion;
  13783. /**
  13784. * Sets a new matrix to apply before all other transformation
  13785. * @param matrix defines the transform matrix
  13786. * @returns the current TransformNode
  13787. */
  13788. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13789. /**
  13790. * Sets a new pivot matrix to the current node
  13791. * @param matrix defines the new pivot matrix to use
  13792. * @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
  13793. * @returns the current TransformNode
  13794. */
  13795. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13796. /**
  13797. * Returns the mesh pivot matrix.
  13798. * Default : Identity.
  13799. * @returns the matrix
  13800. */
  13801. getPivotMatrix(): Matrix;
  13802. /**
  13803. * Instantiate (when possible) or clone that node with its hierarchy
  13804. * @param newParent defines the new parent to use for the instance (or clone)
  13805. * @returns an instance (or a clone) of the current node with its hiearchy
  13806. */
  13807. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  13808. /**
  13809. * Prevents the World matrix to be computed any longer
  13810. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13811. * @returns the TransformNode.
  13812. */
  13813. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13814. /**
  13815. * Allows back the World matrix computation.
  13816. * @returns the TransformNode.
  13817. */
  13818. unfreezeWorldMatrix(): this;
  13819. /**
  13820. * True if the World matrix has been frozen.
  13821. */
  13822. readonly isWorldMatrixFrozen: boolean;
  13823. /**
  13824. * Retuns the mesh absolute position in the World.
  13825. * @returns a Vector3.
  13826. */
  13827. getAbsolutePosition(): Vector3;
  13828. /**
  13829. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13830. * @param absolutePosition the absolute position to set
  13831. * @returns the TransformNode.
  13832. */
  13833. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13834. /**
  13835. * Sets the mesh position in its local space.
  13836. * @param vector3 the position to set in localspace
  13837. * @returns the TransformNode.
  13838. */
  13839. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13840. /**
  13841. * Returns the mesh position in the local space from the current World matrix values.
  13842. * @returns a new Vector3.
  13843. */
  13844. getPositionExpressedInLocalSpace(): Vector3;
  13845. /**
  13846. * Translates the mesh along the passed Vector3 in its local space.
  13847. * @param vector3 the distance to translate in localspace
  13848. * @returns the TransformNode.
  13849. */
  13850. locallyTranslate(vector3: Vector3): TransformNode;
  13851. private static _lookAtVectorCache;
  13852. /**
  13853. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13854. * @param targetPoint the position (must be in same space as current mesh) to look at
  13855. * @param yawCor optional yaw (y-axis) correction in radians
  13856. * @param pitchCor optional pitch (x-axis) correction in radians
  13857. * @param rollCor optional roll (z-axis) correction in radians
  13858. * @param space the choosen space of the target
  13859. * @returns the TransformNode.
  13860. */
  13861. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13862. /**
  13863. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13864. * This Vector3 is expressed in the World space.
  13865. * @param localAxis axis to rotate
  13866. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13867. */
  13868. getDirection(localAxis: Vector3): Vector3;
  13869. /**
  13870. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13871. * localAxis is expressed in the mesh local space.
  13872. * result is computed in the Wordl space from the mesh World matrix.
  13873. * @param localAxis axis to rotate
  13874. * @param result the resulting transformnode
  13875. * @returns this TransformNode.
  13876. */
  13877. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13878. /**
  13879. * Sets this transform node rotation to the given local axis.
  13880. * @param localAxis the axis in local space
  13881. * @param yawCor optional yaw (y-axis) correction in radians
  13882. * @param pitchCor optional pitch (x-axis) correction in radians
  13883. * @param rollCor optional roll (z-axis) correction in radians
  13884. * @returns this TransformNode
  13885. */
  13886. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13887. /**
  13888. * Sets a new pivot point to the current node
  13889. * @param point defines the new pivot point to use
  13890. * @param space defines if the point is in world or local space (local by default)
  13891. * @returns the current TransformNode
  13892. */
  13893. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13894. /**
  13895. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13896. * @returns the pivot point
  13897. */
  13898. getPivotPoint(): Vector3;
  13899. /**
  13900. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13901. * @param result the vector3 to store the result
  13902. * @returns this TransformNode.
  13903. */
  13904. getPivotPointToRef(result: Vector3): TransformNode;
  13905. /**
  13906. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13907. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13908. */
  13909. getAbsolutePivotPoint(): Vector3;
  13910. /**
  13911. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13912. * @param result vector3 to store the result
  13913. * @returns this TransformNode.
  13914. */
  13915. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13916. /**
  13917. * Defines the passed node as the parent of the current node.
  13918. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13919. * @see https://doc.babylonjs.com/how_to/parenting
  13920. * @param node the node ot set as the parent
  13921. * @returns this TransformNode.
  13922. */
  13923. setParent(node: Nullable<Node>): TransformNode;
  13924. private _nonUniformScaling;
  13925. /**
  13926. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13927. */
  13928. readonly nonUniformScaling: boolean;
  13929. /** @hidden */ private _updateNonUniformScalingState(value: boolean): boolean;
  13930. /**
  13931. * Attach the current TransformNode to another TransformNode associated with a bone
  13932. * @param bone Bone affecting the TransformNode
  13933. * @param affectedTransformNode TransformNode associated with the bone
  13934. * @returns this object
  13935. */
  13936. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13937. /**
  13938. * Detach the transform node if its associated with a bone
  13939. * @returns this object
  13940. */
  13941. detachFromBone(): TransformNode;
  13942. private static _rotationAxisCache;
  13943. /**
  13944. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13945. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13946. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13947. * The passed axis is also normalized.
  13948. * @param axis the axis to rotate around
  13949. * @param amount the amount to rotate in radians
  13950. * @param space Space to rotate in (Default: local)
  13951. * @returns the TransformNode.
  13952. */
  13953. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13954. /**
  13955. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13956. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13957. * The passed axis is also normalized. .
  13958. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13959. * @param point the point to rotate around
  13960. * @param axis the axis to rotate around
  13961. * @param amount the amount to rotate in radians
  13962. * @returns the TransformNode
  13963. */
  13964. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  13965. /**
  13966. * Translates the mesh along the axis vector for the passed distance in the given space.
  13967. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13968. * @param axis the axis to translate in
  13969. * @param distance the distance to translate
  13970. * @param space Space to rotate in (Default: local)
  13971. * @returns the TransformNode.
  13972. */
  13973. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13974. /**
  13975. * Adds a rotation step to the mesh current rotation.
  13976. * x, y, z are Euler angles expressed in radians.
  13977. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  13978. * This means this rotation is made in the mesh local space only.
  13979. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  13980. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  13981. * ```javascript
  13982. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  13983. * ```
  13984. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  13985. * 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.
  13986. * @param x Rotation to add
  13987. * @param y Rotation to add
  13988. * @param z Rotation to add
  13989. * @returns the TransformNode.
  13990. */
  13991. addRotation(x: number, y: number, z: number): TransformNode;
  13992. /**
  13993. * @hidden
  13994. */
  13995. protected _getEffectiveParent(): Nullable<Node>;
  13996. /**
  13997. * Computes the world matrix of the node
  13998. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13999. * @returns the world matrix
  14000. */
  14001. computeWorldMatrix(force?: boolean): Matrix;
  14002. protected _afterComputeWorldMatrix(): void;
  14003. /**
  14004. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14005. * @param func callback function to add
  14006. *
  14007. * @returns the TransformNode.
  14008. */
  14009. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14010. /**
  14011. * Removes a registered callback function.
  14012. * @param func callback function to remove
  14013. * @returns the TransformNode.
  14014. */
  14015. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14016. /**
  14017. * Gets the position of the current mesh in camera space
  14018. * @param camera defines the camera to use
  14019. * @returns a position
  14020. */
  14021. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14022. /**
  14023. * Returns the distance from the mesh to the active camera
  14024. * @param camera defines the camera to use
  14025. * @returns the distance
  14026. */
  14027. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14028. /**
  14029. * Clone the current transform node
  14030. * @param name Name of the new clone
  14031. * @param newParent New parent for the clone
  14032. * @param doNotCloneChildren Do not clone children hierarchy
  14033. * @returns the new transform node
  14034. */
  14035. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14036. /**
  14037. * Serializes the objects information.
  14038. * @param currentSerializationObject defines the object to serialize in
  14039. * @returns the serialized object
  14040. */
  14041. serialize(currentSerializationObject?: any): any;
  14042. /**
  14043. * Returns a new TransformNode object parsed from the source provided.
  14044. * @param parsedTransformNode is the source.
  14045. * @param scene the scne the object belongs to
  14046. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14047. * @returns a new TransformNode object parsed from the source provided.
  14048. */
  14049. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14050. /**
  14051. * Get all child-transformNodes of this node
  14052. * @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
  14053. * @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
  14054. * @returns an array of TransformNode
  14055. */
  14056. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14057. /**
  14058. * Releases resources associated with this transform node.
  14059. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14060. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14061. */
  14062. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14063. /**
  14064. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14065. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14066. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14067. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14068. * @returns the current mesh
  14069. */
  14070. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14071. private _syncAbsoluteScalingAndRotation;
  14072. }
  14073. }
  14074. declare module BABYLON {
  14075. /**
  14076. * Defines the types of pose enabled controllers that are supported
  14077. */
  14078. export enum PoseEnabledControllerType {
  14079. /**
  14080. * HTC Vive
  14081. */
  14082. VIVE = 0,
  14083. /**
  14084. * Oculus Rift
  14085. */
  14086. OCULUS = 1,
  14087. /**
  14088. * Windows mixed reality
  14089. */
  14090. WINDOWS = 2,
  14091. /**
  14092. * Samsung gear VR
  14093. */
  14094. GEAR_VR = 3,
  14095. /**
  14096. * Google Daydream
  14097. */
  14098. DAYDREAM = 4,
  14099. /**
  14100. * Generic
  14101. */
  14102. GENERIC = 5
  14103. }
  14104. /**
  14105. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14106. */
  14107. export interface MutableGamepadButton {
  14108. /**
  14109. * Value of the button/trigger
  14110. */
  14111. value: number;
  14112. /**
  14113. * If the button/trigger is currently touched
  14114. */
  14115. touched: boolean;
  14116. /**
  14117. * If the button/trigger is currently pressed
  14118. */
  14119. pressed: boolean;
  14120. }
  14121. /**
  14122. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14123. * @hidden
  14124. */
  14125. export interface ExtendedGamepadButton extends GamepadButton {
  14126. /**
  14127. * If the button/trigger is currently pressed
  14128. */
  14129. readonly pressed: boolean;
  14130. /**
  14131. * If the button/trigger is currently touched
  14132. */
  14133. readonly touched: boolean;
  14134. /**
  14135. * Value of the button/trigger
  14136. */
  14137. readonly value: number;
  14138. }
  14139. /** @hidden */
  14140. export interface _GamePadFactory {
  14141. /**
  14142. * Returns wether or not the current gamepad can be created for this type of controller.
  14143. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14144. * @returns true if it can be created, otherwise false
  14145. */
  14146. canCreate(gamepadInfo: any): boolean;
  14147. /**
  14148. * Creates a new instance of the Gamepad.
  14149. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14150. * @returns the new gamepad instance
  14151. */
  14152. create(gamepadInfo: any): Gamepad;
  14153. }
  14154. /**
  14155. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14156. */
  14157. export class PoseEnabledControllerHelper {
  14158. /** @hidden */ private static _ControllerFactories: _GamePadFactory[];
  14159. /** @hidden */ private static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14160. /**
  14161. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14162. * @param vrGamepad the gamepad to initialized
  14163. * @returns a vr controller of the type the gamepad identified as
  14164. */
  14165. static InitiateController(vrGamepad: any): Gamepad;
  14166. }
  14167. /**
  14168. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14169. */
  14170. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14171. /**
  14172. * If the controller is used in a webXR session
  14173. */
  14174. isXR: boolean;
  14175. private _deviceRoomPosition;
  14176. private _deviceRoomRotationQuaternion;
  14177. /**
  14178. * The device position in babylon space
  14179. */
  14180. devicePosition: Vector3;
  14181. /**
  14182. * The device rotation in babylon space
  14183. */
  14184. deviceRotationQuaternion: Quaternion;
  14185. /**
  14186. * The scale factor of the device in babylon space
  14187. */
  14188. deviceScaleFactor: number;
  14189. /**
  14190. * (Likely devicePosition should be used instead) The device position in its room space
  14191. */
  14192. position: Vector3;
  14193. /**
  14194. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14195. */
  14196. rotationQuaternion: Quaternion;
  14197. /**
  14198. * The type of controller (Eg. Windows mixed reality)
  14199. */
  14200. controllerType: PoseEnabledControllerType;
  14201. protected _calculatedPosition: Vector3;
  14202. private _calculatedRotation;
  14203. /**
  14204. * The raw pose from the device
  14205. */
  14206. rawPose: DevicePose;
  14207. private _trackPosition;
  14208. private _maxRotationDistFromHeadset;
  14209. private _draggedRoomRotation;
  14210. /**
  14211. * @hidden
  14212. */ private _disableTrackPosition(fixedPosition: Vector3): void;
  14213. /**
  14214. * Internal, the mesh attached to the controller
  14215. * @hidden
  14216. */ private _mesh: Nullable<AbstractMesh>;
  14217. private _poseControlledCamera;
  14218. private _leftHandSystemQuaternion;
  14219. /**
  14220. * Internal, matrix used to convert room space to babylon space
  14221. * @hidden
  14222. */ private _deviceToWorld: Matrix;
  14223. /**
  14224. * Node to be used when casting a ray from the controller
  14225. * @hidden
  14226. */ private _pointingPoseNode: Nullable<TransformNode>;
  14227. /**
  14228. * Name of the child mesh that can be used to cast a ray from the controller
  14229. */
  14230. static readonly POINTING_POSE: string;
  14231. /**
  14232. * Creates a new PoseEnabledController from a gamepad
  14233. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14234. */
  14235. constructor(browserGamepad: any);
  14236. private _workingMatrix;
  14237. /**
  14238. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14239. */
  14240. update(): void;
  14241. /**
  14242. * Updates only the pose device and mesh without doing any button event checking
  14243. */
  14244. protected _updatePoseAndMesh(): void;
  14245. /**
  14246. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14247. * @param poseData raw pose fromthe device
  14248. */
  14249. updateFromDevice(poseData: DevicePose): void;
  14250. /**
  14251. * @hidden
  14252. */ private _meshAttachedObservable: Observable<AbstractMesh>;
  14253. /**
  14254. * Attaches a mesh to the controller
  14255. * @param mesh the mesh to be attached
  14256. */
  14257. attachToMesh(mesh: AbstractMesh): void;
  14258. /**
  14259. * Attaches the controllers mesh to a camera
  14260. * @param camera the camera the mesh should be attached to
  14261. */
  14262. attachToPoseControlledCamera(camera: TargetCamera): void;
  14263. /**
  14264. * Disposes of the controller
  14265. */
  14266. dispose(): void;
  14267. /**
  14268. * The mesh that is attached to the controller
  14269. */
  14270. readonly mesh: Nullable<AbstractMesh>;
  14271. /**
  14272. * Gets the ray of the controller in the direction the controller is pointing
  14273. * @param length the length the resulting ray should be
  14274. * @returns a ray in the direction the controller is pointing
  14275. */
  14276. getForwardRay(length?: number): Ray;
  14277. }
  14278. }
  14279. declare module BABYLON {
  14280. /**
  14281. * Defines the WebVRController object that represents controllers tracked in 3D space
  14282. */
  14283. export abstract class WebVRController extends PoseEnabledController {
  14284. /**
  14285. * Internal, the default controller model for the controller
  14286. */
  14287. protected _defaultModel: Nullable<AbstractMesh>;
  14288. /**
  14289. * Fired when the trigger state has changed
  14290. */
  14291. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14292. /**
  14293. * Fired when the main button state has changed
  14294. */
  14295. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14296. /**
  14297. * Fired when the secondary button state has changed
  14298. */
  14299. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14300. /**
  14301. * Fired when the pad state has changed
  14302. */
  14303. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14304. /**
  14305. * Fired when controllers stick values have changed
  14306. */
  14307. onPadValuesChangedObservable: Observable<StickValues>;
  14308. /**
  14309. * Array of button availible on the controller
  14310. */
  14311. protected _buttons: Array<MutableGamepadButton>;
  14312. private _onButtonStateChange;
  14313. /**
  14314. * Fired when a controller button's state has changed
  14315. * @param callback the callback containing the button that was modified
  14316. */
  14317. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14318. /**
  14319. * X and Y axis corresponding to the controllers joystick
  14320. */
  14321. pad: StickValues;
  14322. /**
  14323. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14324. */
  14325. hand: string;
  14326. /**
  14327. * The default controller model for the controller
  14328. */
  14329. readonly defaultModel: Nullable<AbstractMesh>;
  14330. /**
  14331. * Creates a new WebVRController from a gamepad
  14332. * @param vrGamepad the gamepad that the WebVRController should be created from
  14333. */
  14334. constructor(vrGamepad: any);
  14335. /**
  14336. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14337. */
  14338. update(): void;
  14339. /**
  14340. * Function to be called when a button is modified
  14341. */
  14342. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14343. /**
  14344. * Loads a mesh and attaches it to the controller
  14345. * @param scene the scene the mesh should be added to
  14346. * @param meshLoaded callback for when the mesh has been loaded
  14347. */
  14348. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14349. private _setButtonValue;
  14350. private _changes;
  14351. private _checkChanges;
  14352. /**
  14353. * Disposes of th webVRCOntroller
  14354. */
  14355. dispose(): void;
  14356. }
  14357. }
  14358. declare module BABYLON {
  14359. /**
  14360. * The HemisphericLight simulates the ambient environment light,
  14361. * so the passed direction is the light reflection direction, not the incoming direction.
  14362. */
  14363. export class HemisphericLight extends Light {
  14364. /**
  14365. * The groundColor is the light in the opposite direction to the one specified during creation.
  14366. * 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.
  14367. */
  14368. groundColor: Color3;
  14369. /**
  14370. * The light reflection direction, not the incoming direction.
  14371. */
  14372. direction: Vector3;
  14373. /**
  14374. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14375. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14376. * The HemisphericLight can't cast shadows.
  14377. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14378. * @param name The friendly name of the light
  14379. * @param direction The direction of the light reflection
  14380. * @param scene The scene the light belongs to
  14381. */
  14382. constructor(name: string, direction: Vector3, scene: Scene);
  14383. protected _buildUniformLayout(): void;
  14384. /**
  14385. * Returns the string "HemisphericLight".
  14386. * @return The class name
  14387. */
  14388. getClassName(): string;
  14389. /**
  14390. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14391. * Returns the updated direction.
  14392. * @param target The target the direction should point to
  14393. * @return The computed direction
  14394. */
  14395. setDirectionToTarget(target: Vector3): Vector3;
  14396. /**
  14397. * Returns the shadow generator associated to the light.
  14398. * @returns Always null for hemispheric lights because it does not support shadows.
  14399. */
  14400. getShadowGenerator(): Nullable<IShadowGenerator>;
  14401. /**
  14402. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14403. * @param effect The effect to update
  14404. * @param lightIndex The index of the light in the effect to update
  14405. * @returns The hemispheric light
  14406. */
  14407. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14408. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14409. /**
  14410. * Computes the world matrix of the node
  14411. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14412. * @param useWasUpdatedFlag defines a reserved property
  14413. * @returns the world matrix
  14414. */
  14415. computeWorldMatrix(): Matrix;
  14416. /**
  14417. * Returns the integer 3.
  14418. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14419. */
  14420. getTypeID(): number;
  14421. /**
  14422. * Prepares the list of defines specific to the light type.
  14423. * @param defines the list of defines
  14424. * @param lightIndex defines the index of the light for the effect
  14425. */
  14426. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14427. }
  14428. }
  14429. declare module BABYLON {
  14430. /** @hidden */
  14431. export var vrMultiviewToSingleviewPixelShader: {
  14432. name: string;
  14433. shader: string;
  14434. };
  14435. }
  14436. declare module BABYLON {
  14437. /**
  14438. * Renders to multiple views with a single draw call
  14439. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14440. */
  14441. export class MultiviewRenderTarget extends RenderTargetTexture {
  14442. /**
  14443. * Creates a multiview render target
  14444. * @param scene scene used with the render target
  14445. * @param size the size of the render target (used for each view)
  14446. */
  14447. constructor(scene: Scene, size?: number | {
  14448. width: number;
  14449. height: number;
  14450. } | {
  14451. ratio: number;
  14452. });
  14453. /**
  14454. * @hidden
  14455. * @param faceIndex the face index, if its a cube texture
  14456. */ private _bindFrameBuffer(faceIndex?: number): void;
  14457. /**
  14458. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14459. * @returns the view count
  14460. */
  14461. getViewCount(): number;
  14462. }
  14463. }
  14464. declare module BABYLON {
  14465. /**
  14466. * Represents a camera frustum
  14467. */
  14468. export class Frustum {
  14469. /**
  14470. * Gets the planes representing the frustum
  14471. * @param transform matrix to be applied to the returned planes
  14472. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14473. */
  14474. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14475. /**
  14476. * Gets the near frustum plane transformed by the transform matrix
  14477. * @param transform transformation matrix to be applied to the resulting frustum plane
  14478. * @param frustumPlane the resuling frustum plane
  14479. */
  14480. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14481. /**
  14482. * Gets the far frustum plane transformed by the transform matrix
  14483. * @param transform transformation matrix to be applied to the resulting frustum plane
  14484. * @param frustumPlane the resuling frustum plane
  14485. */
  14486. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14487. /**
  14488. * Gets the left frustum plane transformed by the transform matrix
  14489. * @param transform transformation matrix to be applied to the resulting frustum plane
  14490. * @param frustumPlane the resuling frustum plane
  14491. */
  14492. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14493. /**
  14494. * Gets the right frustum plane transformed by the transform matrix
  14495. * @param transform transformation matrix to be applied to the resulting frustum plane
  14496. * @param frustumPlane the resuling frustum plane
  14497. */
  14498. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14499. /**
  14500. * Gets the top frustum plane transformed by the transform matrix
  14501. * @param transform transformation matrix to be applied to the resulting frustum plane
  14502. * @param frustumPlane the resuling frustum plane
  14503. */
  14504. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14505. /**
  14506. * Gets the bottom frustum plane transformed by the transform matrix
  14507. * @param transform transformation matrix to be applied to the resulting frustum plane
  14508. * @param frustumPlane the resuling frustum plane
  14509. */
  14510. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14511. /**
  14512. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14513. * @param transform transformation matrix to be applied to the resulting frustum planes
  14514. * @param frustumPlanes the resuling frustum planes
  14515. */
  14516. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14517. }
  14518. }
  14519. declare module BABYLON {
  14520. interface Engine {
  14521. /**
  14522. * Creates a new multiview render target
  14523. * @param width defines the width of the texture
  14524. * @param height defines the height of the texture
  14525. * @returns the created multiview texture
  14526. */
  14527. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14528. /**
  14529. * Binds a multiview framebuffer to be drawn to
  14530. * @param multiviewTexture texture to bind
  14531. */
  14532. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14533. }
  14534. interface Camera {
  14535. /**
  14536. * @hidden
  14537. * 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)
  14538. */ private _useMultiviewToSingleView: boolean;
  14539. /**
  14540. * @hidden
  14541. * 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)
  14542. */ private _multiviewTexture: Nullable<RenderTargetTexture>;
  14543. /**
  14544. * @hidden
  14545. * ensures the multiview texture of the camera exists and has the specified width/height
  14546. * @param width height to set on the multiview texture
  14547. * @param height width to set on the multiview texture
  14548. */ private _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14549. }
  14550. interface Scene {
  14551. /** @hidden */ private _transformMatrixR: Matrix;
  14552. /** @hidden */ private _multiviewSceneUbo: Nullable<UniformBuffer>;
  14553. /** @hidden */ private _createMultiviewUbo(): void;
  14554. /** @hidden */ private _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14555. /** @hidden */ private _renderMultiviewToSingleView(camera: Camera): void;
  14556. }
  14557. }
  14558. declare module BABYLON {
  14559. /**
  14560. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14561. * This will not be used for webXR as it supports displaying texture arrays directly
  14562. */
  14563. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14564. /**
  14565. * Initializes a VRMultiviewToSingleview
  14566. * @param name name of the post process
  14567. * @param camera camera to be applied to
  14568. * @param scaleFactor scaling factor to the size of the output texture
  14569. */
  14570. constructor(name: string, camera: Camera, scaleFactor: number);
  14571. }
  14572. }
  14573. declare module BABYLON {
  14574. interface Engine {
  14575. /** @hidden */ private _vrDisplay: any;
  14576. /** @hidden */ private _vrSupported: boolean;
  14577. /** @hidden */ private _oldSize: Size;
  14578. /** @hidden */ private _oldHardwareScaleFactor: number;
  14579. /** @hidden */ private _vrExclusivePointerMode: boolean;
  14580. /** @hidden */ private _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14581. /** @hidden */ private _onVRDisplayPointerRestricted: () => void;
  14582. /** @hidden */ private _onVRDisplayPointerUnrestricted: () => void;
  14583. /** @hidden */ private _onVrDisplayConnect: Nullable<(display: any) => void>;
  14584. /** @hidden */ private _onVrDisplayDisconnect: Nullable<() => void>;
  14585. /** @hidden */ private _onVrDisplayPresentChange: Nullable<() => void>;
  14586. /**
  14587. * Observable signaled when VR display mode changes
  14588. */
  14589. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14590. /**
  14591. * Observable signaled when VR request present is complete
  14592. */
  14593. onVRRequestPresentComplete: Observable<boolean>;
  14594. /**
  14595. * Observable signaled when VR request present starts
  14596. */
  14597. onVRRequestPresentStart: Observable<Engine>;
  14598. /**
  14599. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14600. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14601. */
  14602. isInVRExclusivePointerMode: boolean;
  14603. /**
  14604. * Gets a boolean indicating if a webVR device was detected
  14605. * @returns true if a webVR device was detected
  14606. */
  14607. isVRDevicePresent(): boolean;
  14608. /**
  14609. * Gets the current webVR device
  14610. * @returns the current webVR device (or null)
  14611. */
  14612. getVRDevice(): any;
  14613. /**
  14614. * Initializes a webVR display and starts listening to display change events
  14615. * The onVRDisplayChangedObservable will be notified upon these changes
  14616. * @returns A promise containing a VRDisplay and if vr is supported
  14617. */
  14618. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14619. /** @hidden */ private _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14620. /**
  14621. * Call this function to switch to webVR mode
  14622. * Will do nothing if webVR is not supported or if there is no webVR device
  14623. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14624. */
  14625. enableVR(): void;
  14626. /** @hidden */ private _onVRFullScreenTriggered(): void;
  14627. }
  14628. }
  14629. declare module BABYLON {
  14630. /**
  14631. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14632. * IMPORTANT!! The data is right-hand data.
  14633. * @export
  14634. * @interface DevicePose
  14635. */
  14636. export interface DevicePose {
  14637. /**
  14638. * The position of the device, values in array are [x,y,z].
  14639. */
  14640. readonly position: Nullable<Float32Array>;
  14641. /**
  14642. * The linearVelocity of the device, values in array are [x,y,z].
  14643. */
  14644. readonly linearVelocity: Nullable<Float32Array>;
  14645. /**
  14646. * The linearAcceleration of the device, values in array are [x,y,z].
  14647. */
  14648. readonly linearAcceleration: Nullable<Float32Array>;
  14649. /**
  14650. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14651. */
  14652. readonly orientation: Nullable<Float32Array>;
  14653. /**
  14654. * The angularVelocity of the device, values in array are [x,y,z].
  14655. */
  14656. readonly angularVelocity: Nullable<Float32Array>;
  14657. /**
  14658. * The angularAcceleration of the device, values in array are [x,y,z].
  14659. */
  14660. readonly angularAcceleration: Nullable<Float32Array>;
  14661. }
  14662. /**
  14663. * Interface representing a pose controlled object in Babylon.
  14664. * A pose controlled object has both regular pose values as well as pose values
  14665. * from an external device such as a VR head mounted display
  14666. */
  14667. export interface PoseControlled {
  14668. /**
  14669. * The position of the object in babylon space.
  14670. */
  14671. position: Vector3;
  14672. /**
  14673. * The rotation quaternion of the object in babylon space.
  14674. */
  14675. rotationQuaternion: Quaternion;
  14676. /**
  14677. * The position of the device in babylon space.
  14678. */
  14679. devicePosition?: Vector3;
  14680. /**
  14681. * The rotation quaternion of the device in babylon space.
  14682. */
  14683. deviceRotationQuaternion: Quaternion;
  14684. /**
  14685. * The raw pose coming from the device.
  14686. */
  14687. rawPose: Nullable<DevicePose>;
  14688. /**
  14689. * The scale of the device to be used when translating from device space to babylon space.
  14690. */
  14691. deviceScaleFactor: number;
  14692. /**
  14693. * Updates the poseControlled values based on the input device pose.
  14694. * @param poseData the pose data to update the object with
  14695. */
  14696. updateFromDevice(poseData: DevicePose): void;
  14697. }
  14698. /**
  14699. * Set of options to customize the webVRCamera
  14700. */
  14701. export interface WebVROptions {
  14702. /**
  14703. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14704. */
  14705. trackPosition?: boolean;
  14706. /**
  14707. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14708. */
  14709. positionScale?: number;
  14710. /**
  14711. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14712. */
  14713. displayName?: string;
  14714. /**
  14715. * Should the native controller meshes be initialized. (default: true)
  14716. */
  14717. controllerMeshes?: boolean;
  14718. /**
  14719. * Creating a default HemiLight only on controllers. (default: true)
  14720. */
  14721. defaultLightingOnControllers?: boolean;
  14722. /**
  14723. * If you don't want to use the default VR button of the helper. (default: false)
  14724. */
  14725. useCustomVRButton?: boolean;
  14726. /**
  14727. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14728. */
  14729. customVRButton?: HTMLButtonElement;
  14730. /**
  14731. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14732. */
  14733. rayLength?: number;
  14734. /**
  14735. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  14736. */
  14737. defaultHeight?: number;
  14738. /**
  14739. * If multiview should be used if availible (default: false)
  14740. */
  14741. useMultiview?: boolean;
  14742. }
  14743. /**
  14744. * This represents a WebVR camera.
  14745. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  14746. * @example http://doc.babylonjs.com/how_to/webvr_camera
  14747. */
  14748. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  14749. private webVROptions;
  14750. /**
  14751. * @hidden
  14752. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  14753. */ private _vrDevice: any;
  14754. /**
  14755. * The rawPose of the vrDevice.
  14756. */
  14757. rawPose: Nullable<DevicePose>;
  14758. private _onVREnabled;
  14759. private _specsVersion;
  14760. private _attached;
  14761. private _frameData;
  14762. protected _descendants: Array<Node>;
  14763. private _deviceRoomPosition;
  14764. /** @hidden */ private _deviceRoomRotationQuaternion: Quaternion;
  14765. private _standingMatrix;
  14766. /**
  14767. * Represents device position in babylon space.
  14768. */
  14769. devicePosition: Vector3;
  14770. /**
  14771. * Represents device rotation in babylon space.
  14772. */
  14773. deviceRotationQuaternion: Quaternion;
  14774. /**
  14775. * The scale of the device to be used when translating from device space to babylon space.
  14776. */
  14777. deviceScaleFactor: number;
  14778. private _deviceToWorld;
  14779. private _worldToDevice;
  14780. /**
  14781. * References to the webVR controllers for the vrDevice.
  14782. */
  14783. controllers: Array<WebVRController>;
  14784. /**
  14785. * Emits an event when a controller is attached.
  14786. */
  14787. onControllersAttachedObservable: Observable<WebVRController[]>;
  14788. /**
  14789. * Emits an event when a controller's mesh has been loaded;
  14790. */
  14791. onControllerMeshLoadedObservable: Observable<WebVRController>;
  14792. /**
  14793. * Emits an event when the HMD's pose has been updated.
  14794. */
  14795. onPoseUpdatedFromDeviceObservable: Observable<any>;
  14796. private _poseSet;
  14797. /**
  14798. * If the rig cameras be used as parent instead of this camera.
  14799. */
  14800. rigParenting: boolean;
  14801. private _lightOnControllers;
  14802. private _defaultHeight?;
  14803. /**
  14804. * Instantiates a WebVRFreeCamera.
  14805. * @param name The name of the WebVRFreeCamera
  14806. * @param position The starting anchor position for the camera
  14807. * @param scene The scene the camera belongs to
  14808. * @param webVROptions a set of customizable options for the webVRCamera
  14809. */
  14810. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  14811. /**
  14812. * Gets the device distance from the ground in meters.
  14813. * @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.
  14814. */
  14815. deviceDistanceToRoomGround(): number;
  14816. /**
  14817. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14818. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  14819. */
  14820. useStandingMatrix(callback?: (bool: boolean) => void): void;
  14821. /**
  14822. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14823. * @returns A promise with a boolean set to if the standing matrix is supported.
  14824. */
  14825. useStandingMatrixAsync(): Promise<boolean>;
  14826. /**
  14827. * Disposes the camera
  14828. */
  14829. dispose(): void;
  14830. /**
  14831. * Gets a vrController by name.
  14832. * @param name The name of the controller to retreive
  14833. * @returns the controller matching the name specified or null if not found
  14834. */
  14835. getControllerByName(name: string): Nullable<WebVRController>;
  14836. private _leftController;
  14837. /**
  14838. * The controller corresponding to the users left hand.
  14839. */
  14840. readonly leftController: Nullable<WebVRController>;
  14841. private _rightController;
  14842. /**
  14843. * The controller corresponding to the users right hand.
  14844. */
  14845. readonly rightController: Nullable<WebVRController>;
  14846. /**
  14847. * Casts a ray forward from the vrCamera's gaze.
  14848. * @param length Length of the ray (default: 100)
  14849. * @returns the ray corresponding to the gaze
  14850. */
  14851. getForwardRay(length?: number): Ray;
  14852. /**
  14853. * @hidden
  14854. * Updates the camera based on device's frame data
  14855. */ private _checkInputs(): void;
  14856. /**
  14857. * Updates the poseControlled values based on the input device pose.
  14858. * @param poseData Pose coming from the device
  14859. */
  14860. updateFromDevice(poseData: DevicePose): void;
  14861. private _htmlElementAttached;
  14862. private _detachIfAttached;
  14863. /**
  14864. * WebVR's attach control will start broadcasting frames to the device.
  14865. * Note that in certain browsers (chrome for example) this function must be called
  14866. * within a user-interaction callback. Example:
  14867. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  14868. *
  14869. * @param element html element to attach the vrDevice to
  14870. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  14871. */
  14872. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  14873. /**
  14874. * Detaches the camera from the html element and disables VR
  14875. *
  14876. * @param element html element to detach from
  14877. */
  14878. detachControl(element: HTMLElement): void;
  14879. /**
  14880. * @returns the name of this class
  14881. */
  14882. getClassName(): string;
  14883. /**
  14884. * Calls resetPose on the vrDisplay
  14885. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  14886. */
  14887. resetToCurrentRotation(): void;
  14888. /**
  14889. * @hidden
  14890. * Updates the rig cameras (left and right eye)
  14891. */ private _updateRigCameras(): void;
  14892. private _workingVector;
  14893. private _oneVector;
  14894. private _workingMatrix;
  14895. private updateCacheCalled;
  14896. private _correctPositionIfNotTrackPosition;
  14897. /**
  14898. * @hidden
  14899. * Updates the cached values of the camera
  14900. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  14901. */ private _updateCache(ignoreParentClass?: boolean): void;
  14902. /**
  14903. * @hidden
  14904. * Get current device position in babylon world
  14905. */ private _computeDevicePosition(): void;
  14906. /**
  14907. * Updates the current device position and rotation in the babylon world
  14908. */
  14909. update(): void;
  14910. /**
  14911. * @hidden
  14912. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  14913. * @returns an identity matrix
  14914. */ private _getViewMatrix(): Matrix;
  14915. private _tmpMatrix;
  14916. /**
  14917. * This function is called by the two RIG cameras.
  14918. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  14919. * @hidden
  14920. */ private _getWebVRViewMatrix(): Matrix;
  14921. /** @hidden */ private _getWebVRProjectionMatrix(): Matrix;
  14922. private _onGamepadConnectedObserver;
  14923. private _onGamepadDisconnectedObserver;
  14924. private _updateCacheWhenTrackingDisabledObserver;
  14925. /**
  14926. * Initializes the controllers and their meshes
  14927. */
  14928. initControllers(): void;
  14929. }
  14930. }
  14931. declare module BABYLON {
  14932. /**
  14933. * Size options for a post process
  14934. */
  14935. export type PostProcessOptions = {
  14936. width: number;
  14937. height: number;
  14938. };
  14939. /**
  14940. * PostProcess can be used to apply a shader to a texture after it has been rendered
  14941. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  14942. */
  14943. export class PostProcess {
  14944. /** Name of the PostProcess. */
  14945. name: string;
  14946. /**
  14947. * Gets or sets the unique id of the post process
  14948. */
  14949. uniqueId: number;
  14950. /**
  14951. * Width of the texture to apply the post process on
  14952. */
  14953. width: number;
  14954. /**
  14955. * Height of the texture to apply the post process on
  14956. */
  14957. height: number;
  14958. /**
  14959. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  14960. * @hidden
  14961. */ private _outputTexture: Nullable<InternalTexture>;
  14962. /**
  14963. * Sampling mode used by the shader
  14964. * See https://doc.babylonjs.com/classes/3.1/texture
  14965. */
  14966. renderTargetSamplingMode: number;
  14967. /**
  14968. * Clear color to use when screen clearing
  14969. */
  14970. clearColor: Color4;
  14971. /**
  14972. * If the buffer needs to be cleared before applying the post process. (default: true)
  14973. * Should be set to false if shader will overwrite all previous pixels.
  14974. */
  14975. autoClear: boolean;
  14976. /**
  14977. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  14978. */
  14979. alphaMode: number;
  14980. /**
  14981. * Sets the setAlphaBlendConstants of the babylon engine
  14982. */
  14983. alphaConstants: Color4;
  14984. /**
  14985. * Animations to be used for the post processing
  14986. */
  14987. animations: Animation[];
  14988. /**
  14989. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  14990. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  14991. */
  14992. enablePixelPerfectMode: boolean;
  14993. /**
  14994. * Force the postprocess to be applied without taking in account viewport
  14995. */
  14996. forceFullscreenViewport: boolean;
  14997. /**
  14998. * List of inspectable custom properties (used by the Inspector)
  14999. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15000. */
  15001. inspectableCustomProperties: IInspectable[];
  15002. /**
  15003. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15004. *
  15005. * | Value | Type | Description |
  15006. * | ----- | ----------------------------------- | ----------- |
  15007. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15008. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15009. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15010. *
  15011. */
  15012. scaleMode: number;
  15013. /**
  15014. * Force textures to be a power of two (default: false)
  15015. */
  15016. alwaysForcePOT: boolean;
  15017. private _samples;
  15018. /**
  15019. * Number of sample textures (default: 1)
  15020. */
  15021. samples: number;
  15022. /**
  15023. * Modify the scale of the post process to be the same as the viewport (default: false)
  15024. */
  15025. adaptScaleToCurrentViewport: boolean;
  15026. private _camera;
  15027. private _scene;
  15028. private _engine;
  15029. private _options;
  15030. private _reusable;
  15031. private _textureType;
  15032. /**
  15033. * Smart array of input and output textures for the post process.
  15034. * @hidden
  15035. */ private _textures: SmartArray<InternalTexture>;
  15036. /**
  15037. * The index in _textures that corresponds to the output texture.
  15038. * @hidden
  15039. */ private _currentRenderTextureInd: number;
  15040. private _effect;
  15041. private _samplers;
  15042. private _fragmentUrl;
  15043. private _vertexUrl;
  15044. private _parameters;
  15045. private _scaleRatio;
  15046. protected _indexParameters: any;
  15047. private _shareOutputWithPostProcess;
  15048. private _texelSize;
  15049. private _forcedOutputTexture;
  15050. /**
  15051. * Returns the fragment url or shader name used in the post process.
  15052. * @returns the fragment url or name in the shader store.
  15053. */
  15054. getEffectName(): string;
  15055. /**
  15056. * An event triggered when the postprocess is activated.
  15057. */
  15058. onActivateObservable: Observable<Camera>;
  15059. private _onActivateObserver;
  15060. /**
  15061. * A function that is added to the onActivateObservable
  15062. */
  15063. onActivate: Nullable<(camera: Camera) => void>;
  15064. /**
  15065. * An event triggered when the postprocess changes its size.
  15066. */
  15067. onSizeChangedObservable: Observable<PostProcess>;
  15068. private _onSizeChangedObserver;
  15069. /**
  15070. * A function that is added to the onSizeChangedObservable
  15071. */
  15072. onSizeChanged: (postProcess: PostProcess) => void;
  15073. /**
  15074. * An event triggered when the postprocess applies its effect.
  15075. */
  15076. onApplyObservable: Observable<Effect>;
  15077. private _onApplyObserver;
  15078. /**
  15079. * A function that is added to the onApplyObservable
  15080. */
  15081. onApply: (effect: Effect) => void;
  15082. /**
  15083. * An event triggered before rendering the postprocess
  15084. */
  15085. onBeforeRenderObservable: Observable<Effect>;
  15086. private _onBeforeRenderObserver;
  15087. /**
  15088. * A function that is added to the onBeforeRenderObservable
  15089. */
  15090. onBeforeRender: (effect: Effect) => void;
  15091. /**
  15092. * An event triggered after rendering the postprocess
  15093. */
  15094. onAfterRenderObservable: Observable<Effect>;
  15095. private _onAfterRenderObserver;
  15096. /**
  15097. * A function that is added to the onAfterRenderObservable
  15098. */
  15099. onAfterRender: (efect: Effect) => void;
  15100. /**
  15101. * 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
  15102. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15103. */
  15104. inputTexture: InternalTexture;
  15105. /**
  15106. * Gets the camera which post process is applied to.
  15107. * @returns The camera the post process is applied to.
  15108. */
  15109. getCamera(): Camera;
  15110. /**
  15111. * Gets the texel size of the postprocess.
  15112. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15113. */
  15114. readonly texelSize: Vector2;
  15115. /**
  15116. * Creates a new instance PostProcess
  15117. * @param name The name of the PostProcess.
  15118. * @param fragmentUrl The url of the fragment shader to be used.
  15119. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15120. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15121. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15122. * @param camera The camera to apply the render pass to.
  15123. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15124. * @param engine The engine which the post process will be applied. (default: current engine)
  15125. * @param reusable If the post process can be reused on the same frame. (default: false)
  15126. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15127. * @param textureType Type of textures used when performing the post process. (default: 0)
  15128. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15129. * @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
  15130. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15131. */
  15132. constructor(
  15133. /** Name of the PostProcess. */
  15134. 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);
  15135. /**
  15136. * Gets a string idenfifying the name of the class
  15137. * @returns "PostProcess" string
  15138. */
  15139. getClassName(): string;
  15140. /**
  15141. * Gets the engine which this post process belongs to.
  15142. * @returns The engine the post process was enabled with.
  15143. */
  15144. getEngine(): Engine;
  15145. /**
  15146. * The effect that is created when initializing the post process.
  15147. * @returns The created effect corresponding the the postprocess.
  15148. */
  15149. getEffect(): Effect;
  15150. /**
  15151. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15152. * @param postProcess The post process to share the output with.
  15153. * @returns This post process.
  15154. */
  15155. shareOutputWith(postProcess: PostProcess): PostProcess;
  15156. /**
  15157. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15158. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15159. */
  15160. useOwnOutput(): void;
  15161. /**
  15162. * Updates the effect with the current post process compile time values and recompiles the shader.
  15163. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15164. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15165. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15166. * @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
  15167. * @param onCompiled Called when the shader has been compiled.
  15168. * @param onError Called if there is an error when compiling a shader.
  15169. */
  15170. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15171. /**
  15172. * The post process is reusable if it can be used multiple times within one frame.
  15173. * @returns If the post process is reusable
  15174. */
  15175. isReusable(): boolean;
  15176. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15177. markTextureDirty(): void;
  15178. /**
  15179. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15180. * 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.
  15181. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15182. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15183. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15184. * @returns The target texture that was bound to be written to.
  15185. */
  15186. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15187. /**
  15188. * If the post process is supported.
  15189. */
  15190. readonly isSupported: boolean;
  15191. /**
  15192. * The aspect ratio of the output texture.
  15193. */
  15194. readonly aspectRatio: number;
  15195. /**
  15196. * Get a value indicating if the post-process is ready to be used
  15197. * @returns true if the post-process is ready (shader is compiled)
  15198. */
  15199. isReady(): boolean;
  15200. /**
  15201. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15202. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15203. */
  15204. apply(): Nullable<Effect>;
  15205. private _disposeTextures;
  15206. /**
  15207. * Disposes the post process.
  15208. * @param camera The camera to dispose the post process on.
  15209. */
  15210. dispose(camera?: Camera): void;
  15211. }
  15212. }
  15213. declare module BABYLON {
  15214. /** @hidden */
  15215. export var kernelBlurVaryingDeclaration: {
  15216. name: string;
  15217. shader: string;
  15218. };
  15219. }
  15220. declare module BABYLON {
  15221. /** @hidden */
  15222. export var kernelBlurFragment: {
  15223. name: string;
  15224. shader: string;
  15225. };
  15226. }
  15227. declare module BABYLON {
  15228. /** @hidden */
  15229. export var kernelBlurFragment2: {
  15230. name: string;
  15231. shader: string;
  15232. };
  15233. }
  15234. declare module BABYLON {
  15235. /** @hidden */
  15236. export var kernelBlurPixelShader: {
  15237. name: string;
  15238. shader: string;
  15239. };
  15240. }
  15241. declare module BABYLON {
  15242. /** @hidden */
  15243. export var kernelBlurVertex: {
  15244. name: string;
  15245. shader: string;
  15246. };
  15247. }
  15248. declare module BABYLON {
  15249. /** @hidden */
  15250. export var kernelBlurVertexShader: {
  15251. name: string;
  15252. shader: string;
  15253. };
  15254. }
  15255. declare module BABYLON {
  15256. /**
  15257. * The Blur Post Process which blurs an image based on a kernel and direction.
  15258. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15259. */
  15260. export class BlurPostProcess extends PostProcess {
  15261. /** The direction in which to blur the image. */
  15262. direction: Vector2;
  15263. private blockCompilation;
  15264. protected _kernel: number;
  15265. protected _idealKernel: number;
  15266. protected _packedFloat: boolean;
  15267. private _staticDefines;
  15268. /**
  15269. * Sets the length in pixels of the blur sample region
  15270. */
  15271. /**
  15272. * Gets the length in pixels of the blur sample region
  15273. */
  15274. kernel: number;
  15275. /**
  15276. * Sets wether or not the blur needs to unpack/repack floats
  15277. */
  15278. /**
  15279. * Gets wether or not the blur is unpacking/repacking floats
  15280. */
  15281. packedFloat: boolean;
  15282. /**
  15283. * Creates a new instance BlurPostProcess
  15284. * @param name The name of the effect.
  15285. * @param direction The direction in which to blur the image.
  15286. * @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.
  15287. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15288. * @param camera The camera to apply the render pass to.
  15289. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15290. * @param engine The engine which the post process will be applied. (default: current engine)
  15291. * @param reusable If the post process can be reused on the same frame. (default: false)
  15292. * @param textureType Type of textures used when performing the post process. (default: 0)
  15293. * @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)
  15294. */
  15295. constructor(name: string,
  15296. /** The direction in which to blur the image. */
  15297. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15298. /**
  15299. * Updates the effect with the current post process compile time values and recompiles the shader.
  15300. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15301. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15302. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15303. * @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
  15304. * @param onCompiled Called when the shader has been compiled.
  15305. * @param onError Called if there is an error when compiling a shader.
  15306. */
  15307. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15308. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15309. /**
  15310. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15311. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15312. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15313. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15314. * The gaps between physical kernels are compensated for in the weighting of the samples
  15315. * @param idealKernel Ideal blur kernel.
  15316. * @return Nearest best kernel.
  15317. */
  15318. protected _nearestBestKernel(idealKernel: number): number;
  15319. /**
  15320. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15321. * @param x The point on the Gaussian distribution to sample.
  15322. * @return the value of the Gaussian function at x.
  15323. */
  15324. protected _gaussianWeight(x: number): number;
  15325. /**
  15326. * Generates a string that can be used as a floating point number in GLSL.
  15327. * @param x Value to print.
  15328. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15329. * @return GLSL float string.
  15330. */
  15331. protected _glslFloat(x: number, decimalFigures?: number): string;
  15332. }
  15333. }
  15334. declare module BABYLON {
  15335. /**
  15336. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15337. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15338. * You can then easily use it as a reflectionTexture on a flat surface.
  15339. * In case the surface is not a plane, please consider relying on reflection probes.
  15340. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15341. */
  15342. export class MirrorTexture extends RenderTargetTexture {
  15343. private scene;
  15344. /**
  15345. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15346. * 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.
  15347. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15348. */
  15349. mirrorPlane: Plane;
  15350. /**
  15351. * Define the blur ratio used to blur the reflection if needed.
  15352. */
  15353. blurRatio: number;
  15354. /**
  15355. * Define the adaptive blur kernel used to blur the reflection if needed.
  15356. * This will autocompute the closest best match for the `blurKernel`
  15357. */
  15358. adaptiveBlurKernel: number;
  15359. /**
  15360. * Define the blur kernel used to blur the reflection if needed.
  15361. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15362. */
  15363. blurKernel: number;
  15364. /**
  15365. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15366. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15367. */
  15368. blurKernelX: number;
  15369. /**
  15370. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15371. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15372. */
  15373. blurKernelY: number;
  15374. private _autoComputeBlurKernel;
  15375. protected _onRatioRescale(): void;
  15376. private _updateGammaSpace;
  15377. private _imageProcessingConfigChangeObserver;
  15378. private _transformMatrix;
  15379. private _mirrorMatrix;
  15380. private _savedViewMatrix;
  15381. private _blurX;
  15382. private _blurY;
  15383. private _adaptiveBlurKernel;
  15384. private _blurKernelX;
  15385. private _blurKernelY;
  15386. private _blurRatio;
  15387. /**
  15388. * Instantiates a Mirror Texture.
  15389. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15390. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15391. * You can then easily use it as a reflectionTexture on a flat surface.
  15392. * In case the surface is not a plane, please consider relying on reflection probes.
  15393. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15394. * @param name
  15395. * @param size
  15396. * @param scene
  15397. * @param generateMipMaps
  15398. * @param type
  15399. * @param samplingMode
  15400. * @param generateDepthBuffer
  15401. */
  15402. constructor(name: string, size: number | {
  15403. width: number;
  15404. height: number;
  15405. } | {
  15406. ratio: number;
  15407. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15408. private _preparePostProcesses;
  15409. /**
  15410. * Clone the mirror texture.
  15411. * @returns the cloned texture
  15412. */
  15413. clone(): MirrorTexture;
  15414. /**
  15415. * Serialize the texture to a JSON representation you could use in Parse later on
  15416. * @returns the serialized JSON representation
  15417. */
  15418. serialize(): any;
  15419. /**
  15420. * Dispose the texture and release its associated resources.
  15421. */
  15422. dispose(): void;
  15423. }
  15424. }
  15425. declare module BABYLON {
  15426. /**
  15427. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15428. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15429. */
  15430. export class Texture extends BaseTexture {
  15431. /**
  15432. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15433. */
  15434. static SerializeBuffers: boolean;
  15435. /** @hidden */ private static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15436. /** @hidden */ private static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15437. /** @hidden */ private static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15438. /** nearest is mag = nearest and min = nearest and mip = linear */
  15439. static readonly NEAREST_SAMPLINGMODE: number;
  15440. /** nearest is mag = nearest and min = nearest and mip = linear */
  15441. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15442. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15443. static readonly BILINEAR_SAMPLINGMODE: number;
  15444. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15445. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15446. /** Trilinear is mag = linear and min = linear and mip = linear */
  15447. static readonly TRILINEAR_SAMPLINGMODE: number;
  15448. /** Trilinear is mag = linear and min = linear and mip = linear */
  15449. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15450. /** mag = nearest and min = nearest and mip = nearest */
  15451. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15452. /** mag = nearest and min = linear and mip = nearest */
  15453. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15454. /** mag = nearest and min = linear and mip = linear */
  15455. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15456. /** mag = nearest and min = linear and mip = none */
  15457. static readonly NEAREST_LINEAR: number;
  15458. /** mag = nearest and min = nearest and mip = none */
  15459. static readonly NEAREST_NEAREST: number;
  15460. /** mag = linear and min = nearest and mip = nearest */
  15461. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15462. /** mag = linear and min = nearest and mip = linear */
  15463. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15464. /** mag = linear and min = linear and mip = none */
  15465. static readonly LINEAR_LINEAR: number;
  15466. /** mag = linear and min = nearest and mip = none */
  15467. static readonly LINEAR_NEAREST: number;
  15468. /** Explicit coordinates mode */
  15469. static readonly EXPLICIT_MODE: number;
  15470. /** Spherical coordinates mode */
  15471. static readonly SPHERICAL_MODE: number;
  15472. /** Planar coordinates mode */
  15473. static readonly PLANAR_MODE: number;
  15474. /** Cubic coordinates mode */
  15475. static readonly CUBIC_MODE: number;
  15476. /** Projection coordinates mode */
  15477. static readonly PROJECTION_MODE: number;
  15478. /** Inverse Cubic coordinates mode */
  15479. static readonly SKYBOX_MODE: number;
  15480. /** Inverse Cubic coordinates mode */
  15481. static readonly INVCUBIC_MODE: number;
  15482. /** Equirectangular coordinates mode */
  15483. static readonly EQUIRECTANGULAR_MODE: number;
  15484. /** Equirectangular Fixed coordinates mode */
  15485. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15486. /** Equirectangular Fixed Mirrored coordinates mode */
  15487. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15488. /** Texture is not repeating outside of 0..1 UVs */
  15489. static readonly CLAMP_ADDRESSMODE: number;
  15490. /** Texture is repeating outside of 0..1 UVs */
  15491. static readonly WRAP_ADDRESSMODE: number;
  15492. /** Texture is repeating and mirrored */
  15493. static readonly MIRROR_ADDRESSMODE: number;
  15494. /**
  15495. * 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
  15496. */
  15497. static UseSerializedUrlIfAny: boolean;
  15498. /**
  15499. * Define the url of the texture.
  15500. */
  15501. url: Nullable<string>;
  15502. /**
  15503. * Define an offset on the texture to offset the u coordinates of the UVs
  15504. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15505. */
  15506. uOffset: number;
  15507. /**
  15508. * Define an offset on the texture to offset the v coordinates of the UVs
  15509. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15510. */
  15511. vOffset: number;
  15512. /**
  15513. * Define an offset on the texture to scale the u coordinates of the UVs
  15514. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15515. */
  15516. uScale: number;
  15517. /**
  15518. * Define an offset on the texture to scale the v coordinates of the UVs
  15519. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15520. */
  15521. vScale: number;
  15522. /**
  15523. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15524. * @see http://doc.babylonjs.com/how_to/more_materials
  15525. */
  15526. uAng: number;
  15527. /**
  15528. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15529. * @see http://doc.babylonjs.com/how_to/more_materials
  15530. */
  15531. vAng: number;
  15532. /**
  15533. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15534. * @see http://doc.babylonjs.com/how_to/more_materials
  15535. */
  15536. wAng: number;
  15537. /**
  15538. * Defines the center of rotation (U)
  15539. */
  15540. uRotationCenter: number;
  15541. /**
  15542. * Defines the center of rotation (V)
  15543. */
  15544. vRotationCenter: number;
  15545. /**
  15546. * Defines the center of rotation (W)
  15547. */
  15548. wRotationCenter: number;
  15549. /**
  15550. * Are mip maps generated for this texture or not.
  15551. */
  15552. readonly noMipmap: boolean;
  15553. /**
  15554. * List of inspectable custom properties (used by the Inspector)
  15555. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15556. */
  15557. inspectableCustomProperties: Nullable<IInspectable[]>;
  15558. private _noMipmap;
  15559. /** @hidden */ private _invertY: boolean;
  15560. private _rowGenerationMatrix;
  15561. private _cachedTextureMatrix;
  15562. private _projectionModeMatrix;
  15563. private _t0;
  15564. private _t1;
  15565. private _t2;
  15566. private _cachedUOffset;
  15567. private _cachedVOffset;
  15568. private _cachedUScale;
  15569. private _cachedVScale;
  15570. private _cachedUAng;
  15571. private _cachedVAng;
  15572. private _cachedWAng;
  15573. private _cachedProjectionMatrixId;
  15574. private _cachedCoordinatesMode;
  15575. /** @hidden */
  15576. protected _initialSamplingMode: number;
  15577. /** @hidden */ private _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  15578. private _deleteBuffer;
  15579. protected _format: Nullable<number>;
  15580. private _delayedOnLoad;
  15581. private _delayedOnError;
  15582. private _mimeType?;
  15583. /**
  15584. * Observable triggered once the texture has been loaded.
  15585. */
  15586. onLoadObservable: Observable<Texture>;
  15587. protected _isBlocking: boolean;
  15588. /**
  15589. * Is the texture preventing material to render while loading.
  15590. * If false, a default texture will be used instead of the loading one during the preparation step.
  15591. */
  15592. isBlocking: boolean;
  15593. /**
  15594. * Get the current sampling mode associated with the texture.
  15595. */
  15596. readonly samplingMode: number;
  15597. /**
  15598. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15599. */
  15600. readonly invertY: boolean;
  15601. /**
  15602. * Instantiates a new texture.
  15603. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15604. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15605. * @param url defines the url of the picture to load as a texture
  15606. * @param scene defines the scene or engine the texture will belong to
  15607. * @param noMipmap defines if the texture will require mip maps or not
  15608. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  15609. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15610. * @param onLoad defines a callback triggered when the texture has been loaded
  15611. * @param onError defines a callback triggered when an error occurred during the loading session
  15612. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  15613. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  15614. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15615. * @param mimeType defines an optional mime type information
  15616. */
  15617. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  15618. /**
  15619. * Update the url (and optional buffer) of this texture if url was null during construction.
  15620. * @param url the url of the texture
  15621. * @param buffer the buffer of the texture (defaults to null)
  15622. * @param onLoad callback called when the texture is loaded (defaults to null)
  15623. */
  15624. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15625. /**
  15626. * Finish the loading sequence of a texture flagged as delayed load.
  15627. * @hidden
  15628. */
  15629. delayLoad(): void;
  15630. private _prepareRowForTextureGeneration;
  15631. /**
  15632. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15633. * @returns the transform matrix of the texture.
  15634. */
  15635. getTextureMatrix(): Matrix;
  15636. /**
  15637. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15638. * @returns The reflection texture transform
  15639. */
  15640. getReflectionTextureMatrix(): Matrix;
  15641. /**
  15642. * Clones the texture.
  15643. * @returns the cloned texture
  15644. */
  15645. clone(): Texture;
  15646. /**
  15647. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15648. * @returns The JSON representation of the texture
  15649. */
  15650. serialize(): any;
  15651. /**
  15652. * Get the current class name of the texture useful for serialization or dynamic coding.
  15653. * @returns "Texture"
  15654. */
  15655. getClassName(): string;
  15656. /**
  15657. * Dispose the texture and release its associated resources.
  15658. */
  15659. dispose(): void;
  15660. /**
  15661. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15662. * @param parsedTexture Define the JSON representation of the texture
  15663. * @param scene Define the scene the parsed texture should be instantiated in
  15664. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15665. * @returns The parsed texture if successful
  15666. */
  15667. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15668. /**
  15669. * Creates a texture from its base 64 representation.
  15670. * @param data Define the base64 payload without the data: prefix
  15671. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15672. * @param scene Define the scene the texture should belong to
  15673. * @param noMipmap Forces the texture to not create mip map information if true
  15674. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15675. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15676. * @param onLoad define a callback triggered when the texture has been loaded
  15677. * @param onError define a callback triggered when an error occurred during the loading session
  15678. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15679. * @returns the created texture
  15680. */
  15681. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15682. /**
  15683. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15684. * @param data Define the base64 payload without the data: prefix
  15685. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15686. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15687. * @param scene Define the scene the texture should belong to
  15688. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15689. * @param noMipmap Forces the texture to not create mip map information if true
  15690. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15691. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15692. * @param onLoad define a callback triggered when the texture has been loaded
  15693. * @param onError define a callback triggered when an error occurred during the loading session
  15694. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15695. * @returns the created texture
  15696. */
  15697. 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;
  15698. }
  15699. }
  15700. declare module BABYLON {
  15701. /**
  15702. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15703. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15704. */
  15705. export class PostProcessManager {
  15706. private _scene;
  15707. private _indexBuffer;
  15708. private _vertexBuffers;
  15709. /**
  15710. * Creates a new instance PostProcess
  15711. * @param scene The scene that the post process is associated with.
  15712. */
  15713. constructor(scene: Scene);
  15714. private _prepareBuffers;
  15715. private _buildIndexBuffer;
  15716. /**
  15717. * Rebuilds the vertex buffers of the manager.
  15718. * @hidden
  15719. */ private _rebuild(): void;
  15720. /**
  15721. * Prepares a frame to be run through a post process.
  15722. * @param sourceTexture The input texture to the post procesess. (default: null)
  15723. * @param postProcesses An array of post processes to be run. (default: null)
  15724. * @returns True if the post processes were able to be run.
  15725. * @hidden
  15726. */ private _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  15727. /**
  15728. * Manually render a set of post processes to a texture.
  15729. * @param postProcesses An array of post processes to be run.
  15730. * @param targetTexture The target texture to render to.
  15731. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  15732. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  15733. * @param lodLevel defines which lod of the texture to render to
  15734. */
  15735. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  15736. /**
  15737. * Finalize the result of the output of the postprocesses.
  15738. * @param doNotPresent If true the result will not be displayed to the screen.
  15739. * @param targetTexture The target texture to render to.
  15740. * @param faceIndex The index of the face to bind the target texture to.
  15741. * @param postProcesses The array of post processes to render.
  15742. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  15743. * @hidden
  15744. */ private _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  15745. /**
  15746. * Disposes of the post process manager.
  15747. */
  15748. dispose(): void;
  15749. }
  15750. }
  15751. declare module BABYLON {
  15752. /** Interface used by value gradients (color, factor, ...) */
  15753. export interface IValueGradient {
  15754. /**
  15755. * Gets or sets the gradient value (between 0 and 1)
  15756. */
  15757. gradient: number;
  15758. }
  15759. /** Class used to store color4 gradient */
  15760. export class ColorGradient implements IValueGradient {
  15761. /**
  15762. * Gets or sets the gradient value (between 0 and 1)
  15763. */
  15764. gradient: number;
  15765. /**
  15766. * Gets or sets first associated color
  15767. */
  15768. color1: Color4;
  15769. /**
  15770. * Gets or sets second associated color
  15771. */
  15772. color2?: Color4;
  15773. /**
  15774. * Will get a color picked randomly between color1 and color2.
  15775. * If color2 is undefined then color1 will be used
  15776. * @param result defines the target Color4 to store the result in
  15777. */
  15778. getColorToRef(result: Color4): void;
  15779. }
  15780. /** Class used to store color 3 gradient */
  15781. export class Color3Gradient implements IValueGradient {
  15782. /**
  15783. * Gets or sets the gradient value (between 0 and 1)
  15784. */
  15785. gradient: number;
  15786. /**
  15787. * Gets or sets the associated color
  15788. */
  15789. color: Color3;
  15790. }
  15791. /** Class used to store factor gradient */
  15792. export class FactorGradient implements IValueGradient {
  15793. /**
  15794. * Gets or sets the gradient value (between 0 and 1)
  15795. */
  15796. gradient: number;
  15797. /**
  15798. * Gets or sets first associated factor
  15799. */
  15800. factor1: number;
  15801. /**
  15802. * Gets or sets second associated factor
  15803. */
  15804. factor2?: number;
  15805. /**
  15806. * Will get a number picked randomly between factor1 and factor2.
  15807. * If factor2 is undefined then factor1 will be used
  15808. * @returns the picked number
  15809. */
  15810. getFactor(): number;
  15811. }
  15812. /**
  15813. * Helper used to simplify some generic gradient tasks
  15814. */
  15815. export class GradientHelper {
  15816. /**
  15817. * Gets the current gradient from an array of IValueGradient
  15818. * @param ratio defines the current ratio to get
  15819. * @param gradients defines the array of IValueGradient
  15820. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  15821. */
  15822. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  15823. }
  15824. }
  15825. declare module BABYLON {
  15826. interface ThinEngine {
  15827. /**
  15828. * Creates a dynamic texture
  15829. * @param width defines the width of the texture
  15830. * @param height defines the height of the texture
  15831. * @param generateMipMaps defines if the engine should generate the mip levels
  15832. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  15833. * @returns the dynamic texture inside an InternalTexture
  15834. */
  15835. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  15836. /**
  15837. * Update the content of a dynamic texture
  15838. * @param texture defines the texture to update
  15839. * @param canvas defines the canvas containing the source
  15840. * @param invertY defines if data must be stored with Y axis inverted
  15841. * @param premulAlpha defines if alpha is stored as premultiplied
  15842. * @param format defines the format of the data
  15843. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  15844. */
  15845. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  15846. }
  15847. }
  15848. declare module BABYLON {
  15849. /**
  15850. * Helper class used to generate a canvas to manipulate images
  15851. */
  15852. export class CanvasGenerator {
  15853. /**
  15854. * Create a new canvas (or offscreen canvas depending on the context)
  15855. * @param width defines the expected width
  15856. * @param height defines the expected height
  15857. * @return a new canvas or offscreen canvas
  15858. */
  15859. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  15860. }
  15861. }
  15862. declare module BABYLON {
  15863. /**
  15864. * A class extending Texture allowing drawing on a texture
  15865. * @see http://doc.babylonjs.com/how_to/dynamictexture
  15866. */
  15867. export class DynamicTexture extends Texture {
  15868. private _generateMipMaps;
  15869. private _canvas;
  15870. private _context;
  15871. private _engine;
  15872. /**
  15873. * Creates a DynamicTexture
  15874. * @param name defines the name of the texture
  15875. * @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
  15876. * @param scene defines the scene where you want the texture
  15877. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  15878. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  15879. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  15880. */
  15881. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  15882. /**
  15883. * Get the current class name of the texture useful for serialization or dynamic coding.
  15884. * @returns "DynamicTexture"
  15885. */
  15886. getClassName(): string;
  15887. /**
  15888. * Gets the current state of canRescale
  15889. */
  15890. readonly canRescale: boolean;
  15891. private _recreate;
  15892. /**
  15893. * Scales the texture
  15894. * @param ratio the scale factor to apply to both width and height
  15895. */
  15896. scale(ratio: number): void;
  15897. /**
  15898. * Resizes the texture
  15899. * @param width the new width
  15900. * @param height the new height
  15901. */
  15902. scaleTo(width: number, height: number): void;
  15903. /**
  15904. * Gets the context of the canvas used by the texture
  15905. * @returns the canvas context of the dynamic texture
  15906. */
  15907. getContext(): CanvasRenderingContext2D;
  15908. /**
  15909. * Clears the texture
  15910. */
  15911. clear(): void;
  15912. /**
  15913. * Updates the texture
  15914. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  15915. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  15916. */
  15917. update(invertY?: boolean, premulAlpha?: boolean): void;
  15918. /**
  15919. * Draws text onto the texture
  15920. * @param text defines the text to be drawn
  15921. * @param x defines the placement of the text from the left
  15922. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  15923. * @param font defines the font to be used with font-style, font-size, font-name
  15924. * @param color defines the color used for the text
  15925. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  15926. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  15927. * @param update defines whether texture is immediately update (default is true)
  15928. */
  15929. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  15930. /**
  15931. * Clones the texture
  15932. * @returns the clone of the texture.
  15933. */
  15934. clone(): DynamicTexture;
  15935. /**
  15936. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  15937. * @returns a serialized dynamic texture object
  15938. */
  15939. serialize(): any;
  15940. /** @hidden */ private _rebuild(): void;
  15941. }
  15942. }
  15943. declare module BABYLON {
  15944. interface AbstractScene {
  15945. /**
  15946. * The list of procedural textures added to the scene
  15947. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15948. */
  15949. proceduralTextures: Array<ProceduralTexture>;
  15950. }
  15951. /**
  15952. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  15953. * in a given scene.
  15954. */
  15955. export class ProceduralTextureSceneComponent implements ISceneComponent {
  15956. /**
  15957. * The component name helpfull to identify the component in the list of scene components.
  15958. */
  15959. readonly name: string;
  15960. /**
  15961. * The scene the component belongs to.
  15962. */
  15963. scene: Scene;
  15964. /**
  15965. * Creates a new instance of the component for the given scene
  15966. * @param scene Defines the scene to register the component in
  15967. */
  15968. constructor(scene: Scene);
  15969. /**
  15970. * Registers the component in a given scene
  15971. */
  15972. register(): void;
  15973. /**
  15974. * Rebuilds the elements related to this component in case of
  15975. * context lost for instance.
  15976. */
  15977. rebuild(): void;
  15978. /**
  15979. * Disposes the component and the associated ressources.
  15980. */
  15981. dispose(): void;
  15982. private _beforeClear;
  15983. }
  15984. }
  15985. declare module BABYLON {
  15986. interface ThinEngine {
  15987. /**
  15988. * Creates a new render target cube texture
  15989. * @param size defines the size of the texture
  15990. * @param options defines the options used to create the texture
  15991. * @returns a new render target cube texture stored in an InternalTexture
  15992. */
  15993. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  15994. }
  15995. }
  15996. declare module BABYLON {
  15997. /** @hidden */
  15998. export var proceduralVertexShader: {
  15999. name: string;
  16000. shader: string;
  16001. };
  16002. }
  16003. declare module BABYLON {
  16004. /**
  16005. * 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.
  16006. * This is the base class of any Procedural texture and contains most of the shareable code.
  16007. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16008. */
  16009. export class ProceduralTexture extends Texture {
  16010. isCube: boolean;
  16011. /**
  16012. * Define if the texture is enabled or not (disabled texture will not render)
  16013. */
  16014. isEnabled: boolean;
  16015. /**
  16016. * Define if the texture must be cleared before rendering (default is true)
  16017. */
  16018. autoClear: boolean;
  16019. /**
  16020. * Callback called when the texture is generated
  16021. */
  16022. onGenerated: () => void;
  16023. /**
  16024. * Event raised when the texture is generated
  16025. */
  16026. onGeneratedObservable: Observable<ProceduralTexture>;
  16027. /** @hidden */ private _generateMipMaps: boolean;
  16028. /** @hidden **/ private _effect: Effect;
  16029. /** @hidden */ private _textures: {
  16030. [key: string]: Texture;
  16031. };
  16032. private _size;
  16033. private _currentRefreshId;
  16034. private _refreshRate;
  16035. private _vertexBuffers;
  16036. private _indexBuffer;
  16037. private _uniforms;
  16038. private _samplers;
  16039. private _fragment;
  16040. private _floats;
  16041. private _ints;
  16042. private _floatsArrays;
  16043. private _colors3;
  16044. private _colors4;
  16045. private _vectors2;
  16046. private _vectors3;
  16047. private _matrices;
  16048. private _fallbackTexture;
  16049. private _fallbackTextureUsed;
  16050. private _engine;
  16051. private _cachedDefines;
  16052. private _contentUpdateId;
  16053. private _contentData;
  16054. /**
  16055. * Instantiates a new procedural texture.
  16056. * 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.
  16057. * This is the base class of any Procedural texture and contains most of the shareable code.
  16058. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16059. * @param name Define the name of the texture
  16060. * @param size Define the size of the texture to create
  16061. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16062. * @param scene Define the scene the texture belongs to
  16063. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16064. * @param generateMipMaps Define if the texture should creates mip maps or not
  16065. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16066. */
  16067. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16068. /**
  16069. * The effect that is created when initializing the post process.
  16070. * @returns The created effect corresponding the the postprocess.
  16071. */
  16072. getEffect(): Effect;
  16073. /**
  16074. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16075. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16076. */
  16077. getContent(): Nullable<ArrayBufferView>;
  16078. private _createIndexBuffer;
  16079. /** @hidden */ private _rebuild(): void;
  16080. /**
  16081. * Resets the texture in order to recreate its associated resources.
  16082. * This can be called in case of context loss
  16083. */
  16084. reset(): void;
  16085. protected _getDefines(): string;
  16086. /**
  16087. * Is the texture ready to be used ? (rendered at least once)
  16088. * @returns true if ready, otherwise, false.
  16089. */
  16090. isReady(): boolean;
  16091. /**
  16092. * Resets the refresh counter of the texture and start bak from scratch.
  16093. * Could be useful to regenerate the texture if it is setup to render only once.
  16094. */
  16095. resetRefreshCounter(): void;
  16096. /**
  16097. * Set the fragment shader to use in order to render the texture.
  16098. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16099. */
  16100. setFragment(fragment: any): void;
  16101. /**
  16102. * Define the refresh rate of the texture or the rendering frequency.
  16103. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16104. */
  16105. refreshRate: number;
  16106. /** @hidden */ private _shouldRender(): boolean;
  16107. /**
  16108. * Get the size the texture is rendering at.
  16109. * @returns the size (texture is always squared)
  16110. */
  16111. getRenderSize(): number;
  16112. /**
  16113. * Resize the texture to new value.
  16114. * @param size Define the new size the texture should have
  16115. * @param generateMipMaps Define whether the new texture should create mip maps
  16116. */
  16117. resize(size: number, generateMipMaps: boolean): void;
  16118. private _checkUniform;
  16119. /**
  16120. * Set a texture in the shader program used to render.
  16121. * @param name Define the name of the uniform samplers as defined in the shader
  16122. * @param texture Define the texture to bind to this sampler
  16123. * @return the texture itself allowing "fluent" like uniform updates
  16124. */
  16125. setTexture(name: string, texture: Texture): ProceduralTexture;
  16126. /**
  16127. * Set a float in the shader.
  16128. * @param name Define the name of the uniform as defined in the shader
  16129. * @param value Define the value to give to the uniform
  16130. * @return the texture itself allowing "fluent" like uniform updates
  16131. */
  16132. setFloat(name: string, value: number): ProceduralTexture;
  16133. /**
  16134. * Set a int in the shader.
  16135. * @param name Define the name of the uniform as defined in the shader
  16136. * @param value Define the value to give to the uniform
  16137. * @return the texture itself allowing "fluent" like uniform updates
  16138. */
  16139. setInt(name: string, value: number): ProceduralTexture;
  16140. /**
  16141. * Set an array of floats in the shader.
  16142. * @param name Define the name of the uniform as defined in the shader
  16143. * @param value Define the value to give to the uniform
  16144. * @return the texture itself allowing "fluent" like uniform updates
  16145. */
  16146. setFloats(name: string, value: number[]): ProceduralTexture;
  16147. /**
  16148. * Set a vec3 in the shader from a Color3.
  16149. * @param name Define the name of the uniform as defined in the shader
  16150. * @param value Define the value to give to the uniform
  16151. * @return the texture itself allowing "fluent" like uniform updates
  16152. */
  16153. setColor3(name: string, value: Color3): ProceduralTexture;
  16154. /**
  16155. * Set a vec4 in the shader from a Color4.
  16156. * @param name Define the name of the uniform as defined in the shader
  16157. * @param value Define the value to give to the uniform
  16158. * @return the texture itself allowing "fluent" like uniform updates
  16159. */
  16160. setColor4(name: string, value: Color4): ProceduralTexture;
  16161. /**
  16162. * Set a vec2 in the shader from a Vector2.
  16163. * @param name Define the name of the uniform as defined in the shader
  16164. * @param value Define the value to give to the uniform
  16165. * @return the texture itself allowing "fluent" like uniform updates
  16166. */
  16167. setVector2(name: string, value: Vector2): ProceduralTexture;
  16168. /**
  16169. * Set a vec3 in the shader from a Vector3.
  16170. * @param name Define the name of the uniform as defined in the shader
  16171. * @param value Define the value to give to the uniform
  16172. * @return the texture itself allowing "fluent" like uniform updates
  16173. */
  16174. setVector3(name: string, value: Vector3): ProceduralTexture;
  16175. /**
  16176. * Set a mat4 in the shader from a MAtrix.
  16177. * @param name Define the name of the uniform as defined in the shader
  16178. * @param value Define the value to give to the uniform
  16179. * @return the texture itself allowing "fluent" like uniform updates
  16180. */
  16181. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16182. /**
  16183. * Render the texture to its associated render target.
  16184. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16185. */
  16186. render(useCameraPostProcess?: boolean): void;
  16187. /**
  16188. * Clone the texture.
  16189. * @returns the cloned texture
  16190. */
  16191. clone(): ProceduralTexture;
  16192. /**
  16193. * Dispose the texture and release its asoociated resources.
  16194. */
  16195. dispose(): void;
  16196. }
  16197. }
  16198. declare module BABYLON {
  16199. /**
  16200. * This represents the base class for particle system in Babylon.
  16201. * 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.
  16202. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16203. * @example https://doc.babylonjs.com/babylon101/particles
  16204. */
  16205. export class BaseParticleSystem {
  16206. /**
  16207. * Source color is added to the destination color without alpha affecting the result
  16208. */
  16209. static BLENDMODE_ONEONE: number;
  16210. /**
  16211. * Blend current color and particle color using particle’s alpha
  16212. */
  16213. static BLENDMODE_STANDARD: number;
  16214. /**
  16215. * Add current color and particle color multiplied by particle’s alpha
  16216. */
  16217. static BLENDMODE_ADD: number;
  16218. /**
  16219. * Multiply current color with particle color
  16220. */
  16221. static BLENDMODE_MULTIPLY: number;
  16222. /**
  16223. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16224. */
  16225. static BLENDMODE_MULTIPLYADD: number;
  16226. /**
  16227. * List of animations used by the particle system.
  16228. */
  16229. animations: Animation[];
  16230. /**
  16231. * The id of the Particle system.
  16232. */
  16233. id: string;
  16234. /**
  16235. * The friendly name of the Particle system.
  16236. */
  16237. name: string;
  16238. /**
  16239. * The rendering group used by the Particle system to chose when to render.
  16240. */
  16241. renderingGroupId: number;
  16242. /**
  16243. * The emitter represents the Mesh or position we are attaching the particle system to.
  16244. */
  16245. emitter: Nullable<AbstractMesh | Vector3>;
  16246. /**
  16247. * The maximum number of particles to emit per frame
  16248. */
  16249. emitRate: number;
  16250. /**
  16251. * If you want to launch only a few particles at once, that can be done, as well.
  16252. */
  16253. manualEmitCount: number;
  16254. /**
  16255. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16256. */
  16257. updateSpeed: number;
  16258. /**
  16259. * The amount of time the particle system is running (depends of the overall update speed).
  16260. */
  16261. targetStopDuration: number;
  16262. /**
  16263. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16264. */
  16265. disposeOnStop: boolean;
  16266. /**
  16267. * Minimum power of emitting particles.
  16268. */
  16269. minEmitPower: number;
  16270. /**
  16271. * Maximum power of emitting particles.
  16272. */
  16273. maxEmitPower: number;
  16274. /**
  16275. * Minimum life time of emitting particles.
  16276. */
  16277. minLifeTime: number;
  16278. /**
  16279. * Maximum life time of emitting particles.
  16280. */
  16281. maxLifeTime: number;
  16282. /**
  16283. * Minimum Size of emitting particles.
  16284. */
  16285. minSize: number;
  16286. /**
  16287. * Maximum Size of emitting particles.
  16288. */
  16289. maxSize: number;
  16290. /**
  16291. * Minimum scale of emitting particles on X axis.
  16292. */
  16293. minScaleX: number;
  16294. /**
  16295. * Maximum scale of emitting particles on X axis.
  16296. */
  16297. maxScaleX: number;
  16298. /**
  16299. * Minimum scale of emitting particles on Y axis.
  16300. */
  16301. minScaleY: number;
  16302. /**
  16303. * Maximum scale of emitting particles on Y axis.
  16304. */
  16305. maxScaleY: number;
  16306. /**
  16307. * Gets or sets the minimal initial rotation in radians.
  16308. */
  16309. minInitialRotation: number;
  16310. /**
  16311. * Gets or sets the maximal initial rotation in radians.
  16312. */
  16313. maxInitialRotation: number;
  16314. /**
  16315. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16316. */
  16317. minAngularSpeed: number;
  16318. /**
  16319. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16320. */
  16321. maxAngularSpeed: number;
  16322. /**
  16323. * The texture used to render each particle. (this can be a spritesheet)
  16324. */
  16325. particleTexture: Nullable<Texture>;
  16326. /**
  16327. * The layer mask we are rendering the particles through.
  16328. */
  16329. layerMask: number;
  16330. /**
  16331. * This can help using your own shader to render the particle system.
  16332. * The according effect will be created
  16333. */
  16334. customShader: any;
  16335. /**
  16336. * By default particle system starts as soon as they are created. This prevents the
  16337. * automatic start to happen and let you decide when to start emitting particles.
  16338. */
  16339. preventAutoStart: boolean;
  16340. private _noiseTexture;
  16341. /**
  16342. * Gets or sets a texture used to add random noise to particle positions
  16343. */
  16344. noiseTexture: Nullable<ProceduralTexture>;
  16345. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16346. noiseStrength: Vector3;
  16347. /**
  16348. * Callback triggered when the particle animation is ending.
  16349. */
  16350. onAnimationEnd: Nullable<() => void>;
  16351. /**
  16352. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16353. */
  16354. blendMode: number;
  16355. /**
  16356. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16357. * to override the particles.
  16358. */
  16359. forceDepthWrite: boolean;
  16360. /** 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 */
  16361. preWarmCycles: number;
  16362. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16363. preWarmStepOffset: number;
  16364. /**
  16365. * 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)
  16366. */
  16367. spriteCellChangeSpeed: number;
  16368. /**
  16369. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16370. */
  16371. startSpriteCellID: number;
  16372. /**
  16373. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16374. */
  16375. endSpriteCellID: number;
  16376. /**
  16377. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16378. */
  16379. spriteCellWidth: number;
  16380. /**
  16381. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16382. */
  16383. spriteCellHeight: number;
  16384. /**
  16385. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16386. */
  16387. spriteRandomStartCell: boolean;
  16388. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16389. translationPivot: Vector2;
  16390. /** @hidden */
  16391. protected _isAnimationSheetEnabled: boolean;
  16392. /**
  16393. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16394. */
  16395. beginAnimationOnStart: boolean;
  16396. /**
  16397. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16398. */
  16399. beginAnimationFrom: number;
  16400. /**
  16401. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16402. */
  16403. beginAnimationTo: number;
  16404. /**
  16405. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16406. */
  16407. beginAnimationLoop: boolean;
  16408. /**
  16409. * Gets or sets a world offset applied to all particles
  16410. */
  16411. worldOffset: Vector3;
  16412. /**
  16413. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16414. */
  16415. isAnimationSheetEnabled: boolean;
  16416. /**
  16417. * Get hosting scene
  16418. * @returns the scene
  16419. */
  16420. getScene(): Scene;
  16421. /**
  16422. * You can use gravity if you want to give an orientation to your particles.
  16423. */
  16424. gravity: Vector3;
  16425. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16426. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16427. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16428. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16429. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16430. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16431. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16432. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16433. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16434. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16435. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16436. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16437. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16438. /**
  16439. * Defines the delay in milliseconds before starting the system (0 by default)
  16440. */
  16441. startDelay: number;
  16442. /**
  16443. * Gets the current list of drag gradients.
  16444. * You must use addDragGradient and removeDragGradient to udpate this list
  16445. * @returns the list of drag gradients
  16446. */
  16447. getDragGradients(): Nullable<Array<FactorGradient>>;
  16448. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16449. limitVelocityDamping: number;
  16450. /**
  16451. * Gets the current list of limit velocity gradients.
  16452. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16453. * @returns the list of limit velocity gradients
  16454. */
  16455. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16456. /**
  16457. * Gets the current list of color gradients.
  16458. * You must use addColorGradient and removeColorGradient to udpate this list
  16459. * @returns the list of color gradients
  16460. */
  16461. getColorGradients(): Nullable<Array<ColorGradient>>;
  16462. /**
  16463. * Gets the current list of size gradients.
  16464. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16465. * @returns the list of size gradients
  16466. */
  16467. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16468. /**
  16469. * Gets the current list of color remap gradients.
  16470. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16471. * @returns the list of color remap gradients
  16472. */
  16473. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16474. /**
  16475. * Gets the current list of alpha remap gradients.
  16476. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16477. * @returns the list of alpha remap gradients
  16478. */
  16479. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16480. /**
  16481. * Gets the current list of life time gradients.
  16482. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16483. * @returns the list of life time gradients
  16484. */
  16485. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16486. /**
  16487. * Gets the current list of angular speed gradients.
  16488. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16489. * @returns the list of angular speed gradients
  16490. */
  16491. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16492. /**
  16493. * Gets the current list of velocity gradients.
  16494. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16495. * @returns the list of velocity gradients
  16496. */
  16497. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16498. /**
  16499. * Gets the current list of start size gradients.
  16500. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16501. * @returns the list of start size gradients
  16502. */
  16503. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16504. /**
  16505. * Gets the current list of emit rate gradients.
  16506. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16507. * @returns the list of emit rate gradients
  16508. */
  16509. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16510. /**
  16511. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16512. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16513. */
  16514. direction1: Vector3;
  16515. /**
  16516. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16517. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16518. */
  16519. direction2: Vector3;
  16520. /**
  16521. * 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.
  16522. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16523. */
  16524. minEmitBox: Vector3;
  16525. /**
  16526. * 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.
  16527. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16528. */
  16529. maxEmitBox: Vector3;
  16530. /**
  16531. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16532. */
  16533. color1: Color4;
  16534. /**
  16535. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16536. */
  16537. color2: Color4;
  16538. /**
  16539. * Color the particle will have at the end of its lifetime
  16540. */
  16541. colorDead: Color4;
  16542. /**
  16543. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16544. */
  16545. textureMask: Color4;
  16546. /**
  16547. * The particle emitter type defines the emitter used by the particle system.
  16548. * It can be for example box, sphere, or cone...
  16549. */
  16550. particleEmitterType: IParticleEmitterType;
  16551. /** @hidden */ private _isSubEmitter: boolean;
  16552. /**
  16553. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16554. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16555. */
  16556. billboardMode: number;
  16557. protected _isBillboardBased: boolean;
  16558. /**
  16559. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16560. */
  16561. isBillboardBased: boolean;
  16562. /**
  16563. * The scene the particle system belongs to.
  16564. */
  16565. protected _scene: Scene;
  16566. /**
  16567. * Local cache of defines for image processing.
  16568. */
  16569. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16570. /**
  16571. * Default configuration related to image processing available in the standard Material.
  16572. */
  16573. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16574. /**
  16575. * Gets the image processing configuration used either in this material.
  16576. */
  16577. /**
  16578. * Sets the Default image processing configuration used either in the this material.
  16579. *
  16580. * If sets to null, the scene one is in use.
  16581. */
  16582. imageProcessingConfiguration: ImageProcessingConfiguration;
  16583. /**
  16584. * Attaches a new image processing configuration to the Standard Material.
  16585. * @param configuration
  16586. */
  16587. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16588. /** @hidden */
  16589. protected _reset(): void;
  16590. /** @hidden */
  16591. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16592. /**
  16593. * Instantiates a particle system.
  16594. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  16595. * @param name The name of the particle system
  16596. */
  16597. constructor(name: string);
  16598. /**
  16599. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16600. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16601. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16602. * @returns the emitter
  16603. */
  16604. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16605. /**
  16606. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16607. * @param radius The radius of the hemisphere to emit from
  16608. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16609. * @returns the emitter
  16610. */
  16611. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16612. /**
  16613. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16614. * @param radius The radius of the sphere to emit from
  16615. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16616. * @returns the emitter
  16617. */
  16618. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16619. /**
  16620. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16621. * @param radius The radius of the sphere to emit from
  16622. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16623. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16624. * @returns the emitter
  16625. */
  16626. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16627. /**
  16628. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16629. * @param radius The radius of the emission cylinder
  16630. * @param height The height of the emission cylinder
  16631. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16632. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16633. * @returns the emitter
  16634. */
  16635. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16636. /**
  16637. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16638. * @param radius The radius of the cylinder to emit from
  16639. * @param height The height of the emission cylinder
  16640. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16641. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16642. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16643. * @returns the emitter
  16644. */
  16645. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16646. /**
  16647. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16648. * @param radius The radius of the cone to emit from
  16649. * @param angle The base angle of the cone
  16650. * @returns the emitter
  16651. */
  16652. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16653. /**
  16654. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16655. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16656. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16657. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16658. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16659. * @returns the emitter
  16660. */
  16661. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16662. }
  16663. }
  16664. declare module BABYLON {
  16665. /**
  16666. * Type of sub emitter
  16667. */
  16668. export enum SubEmitterType {
  16669. /**
  16670. * Attached to the particle over it's lifetime
  16671. */
  16672. ATTACHED = 0,
  16673. /**
  16674. * Created when the particle dies
  16675. */
  16676. END = 1
  16677. }
  16678. /**
  16679. * Sub emitter class used to emit particles from an existing particle
  16680. */
  16681. export class SubEmitter {
  16682. /**
  16683. * the particle system to be used by the sub emitter
  16684. */
  16685. particleSystem: ParticleSystem;
  16686. /**
  16687. * Type of the submitter (Default: END)
  16688. */
  16689. type: SubEmitterType;
  16690. /**
  16691. * 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)
  16692. * Note: This only is supported when using an emitter of type Mesh
  16693. */
  16694. inheritDirection: boolean;
  16695. /**
  16696. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16697. */
  16698. inheritedVelocityAmount: number;
  16699. /**
  16700. * Creates a sub emitter
  16701. * @param particleSystem the particle system to be used by the sub emitter
  16702. */
  16703. constructor(
  16704. /**
  16705. * the particle system to be used by the sub emitter
  16706. */
  16707. particleSystem: ParticleSystem);
  16708. /**
  16709. * Clones the sub emitter
  16710. * @returns the cloned sub emitter
  16711. */
  16712. clone(): SubEmitter;
  16713. /**
  16714. * Serialize current object to a JSON object
  16715. * @returns the serialized object
  16716. */
  16717. serialize(): any;
  16718. /** @hidden */ private static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  16719. /**
  16720. * Creates a new SubEmitter from a serialized JSON version
  16721. * @param serializationObject defines the JSON object to read from
  16722. * @param scene defines the hosting scene
  16723. * @param rootUrl defines the rootUrl for data loading
  16724. * @returns a new SubEmitter
  16725. */
  16726. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  16727. /** Release associated resources */
  16728. dispose(): void;
  16729. }
  16730. }
  16731. declare module BABYLON {
  16732. /** @hidden */
  16733. export var clipPlaneFragmentDeclaration: {
  16734. name: string;
  16735. shader: string;
  16736. };
  16737. }
  16738. declare module BABYLON {
  16739. /** @hidden */
  16740. export var imageProcessingDeclaration: {
  16741. name: string;
  16742. shader: string;
  16743. };
  16744. }
  16745. declare module BABYLON {
  16746. /** @hidden */
  16747. export var imageProcessingFunctions: {
  16748. name: string;
  16749. shader: string;
  16750. };
  16751. }
  16752. declare module BABYLON {
  16753. /** @hidden */
  16754. export var clipPlaneFragment: {
  16755. name: string;
  16756. shader: string;
  16757. };
  16758. }
  16759. declare module BABYLON {
  16760. /** @hidden */
  16761. export var particlesPixelShader: {
  16762. name: string;
  16763. shader: string;
  16764. };
  16765. }
  16766. declare module BABYLON {
  16767. /** @hidden */
  16768. export var clipPlaneVertexDeclaration: {
  16769. name: string;
  16770. shader: string;
  16771. };
  16772. }
  16773. declare module BABYLON {
  16774. /** @hidden */
  16775. export var clipPlaneVertex: {
  16776. name: string;
  16777. shader: string;
  16778. };
  16779. }
  16780. declare module BABYLON {
  16781. /** @hidden */
  16782. export var particlesVertexShader: {
  16783. name: string;
  16784. shader: string;
  16785. };
  16786. }
  16787. declare module BABYLON {
  16788. /**
  16789. * This represents a particle system in Babylon.
  16790. * 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.
  16791. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16792. * @example https://doc.babylonjs.com/babylon101/particles
  16793. */
  16794. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  16795. /**
  16796. * Billboard mode will only apply to Y axis
  16797. */
  16798. static readonly BILLBOARDMODE_Y: number;
  16799. /**
  16800. * Billboard mode will apply to all axes
  16801. */
  16802. static readonly BILLBOARDMODE_ALL: number;
  16803. /**
  16804. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  16805. */
  16806. static readonly BILLBOARDMODE_STRETCHED: number;
  16807. /**
  16808. * This function can be defined to provide custom update for active particles.
  16809. * This function will be called instead of regular update (age, position, color, etc.).
  16810. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  16811. */
  16812. updateFunction: (particles: Particle[]) => void;
  16813. private _emitterWorldMatrix;
  16814. /**
  16815. * This function can be defined to specify initial direction for every new particle.
  16816. * It by default use the emitterType defined function
  16817. */
  16818. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  16819. /**
  16820. * This function can be defined to specify initial position for every new particle.
  16821. * It by default use the emitterType defined function
  16822. */
  16823. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  16824. /**
  16825. * @hidden
  16826. */ private _inheritedVelocityOffset: Vector3;
  16827. /**
  16828. * An event triggered when the system is disposed
  16829. */
  16830. onDisposeObservable: Observable<ParticleSystem>;
  16831. private _onDisposeObserver;
  16832. /**
  16833. * Sets a callback that will be triggered when the system is disposed
  16834. */
  16835. onDispose: () => void;
  16836. private _particles;
  16837. private _epsilon;
  16838. private _capacity;
  16839. private _stockParticles;
  16840. private _newPartsExcess;
  16841. private _vertexData;
  16842. private _vertexBuffer;
  16843. private _vertexBuffers;
  16844. private _spriteBuffer;
  16845. private _indexBuffer;
  16846. private _effect;
  16847. private _customEffect;
  16848. private _cachedDefines;
  16849. private _scaledColorStep;
  16850. private _colorDiff;
  16851. private _scaledDirection;
  16852. private _scaledGravity;
  16853. private _currentRenderId;
  16854. private _alive;
  16855. private _useInstancing;
  16856. private _started;
  16857. private _stopped;
  16858. private _actualFrame;
  16859. private _scaledUpdateSpeed;
  16860. private _vertexBufferSize;
  16861. /** @hidden */ private _currentEmitRateGradient: Nullable<FactorGradient>;
  16862. /** @hidden */ private _currentEmitRate1: number;
  16863. /** @hidden */ private _currentEmitRate2: number;
  16864. /** @hidden */ private _currentStartSizeGradient: Nullable<FactorGradient>;
  16865. /** @hidden */ private _currentStartSize1: number;
  16866. /** @hidden */ private _currentStartSize2: number;
  16867. private readonly _rawTextureWidth;
  16868. private _rampGradientsTexture;
  16869. private _useRampGradients;
  16870. /** Gets or sets a boolean indicating that ramp gradients must be used
  16871. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16872. */
  16873. useRampGradients: boolean;
  16874. /**
  16875. * 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.
  16876. * 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: [])
  16877. */
  16878. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  16879. private _subEmitters;
  16880. /**
  16881. * @hidden
  16882. * If the particle systems emitter should be disposed when the particle system is disposed
  16883. */ private _disposeEmitterOnDispose: boolean;
  16884. /**
  16885. * The current active Sub-systems, this property is used by the root particle system only.
  16886. */
  16887. activeSubSystems: Array<ParticleSystem>;
  16888. private _rootParticleSystem;
  16889. /**
  16890. * Gets the current list of active particles
  16891. */
  16892. readonly particles: Particle[];
  16893. /**
  16894. * Returns the string "ParticleSystem"
  16895. * @returns a string containing the class name
  16896. */
  16897. getClassName(): string;
  16898. /**
  16899. * Instantiates a particle system.
  16900. * 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.
  16901. * @param name The name of the particle system
  16902. * @param capacity The max number of particles alive at the same time
  16903. * @param scene The scene the particle system belongs to
  16904. * @param customEffect a custom effect used to change the way particles are rendered by default
  16905. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  16906. * @param epsilon Offset used to render the particles
  16907. */
  16908. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  16909. private _addFactorGradient;
  16910. private _removeFactorGradient;
  16911. /**
  16912. * Adds a new life time gradient
  16913. * @param gradient defines the gradient to use (between 0 and 1)
  16914. * @param factor defines the life time factor to affect to the specified gradient
  16915. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16916. * @returns the current particle system
  16917. */
  16918. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16919. /**
  16920. * Remove a specific life time gradient
  16921. * @param gradient defines the gradient to remove
  16922. * @returns the current particle system
  16923. */
  16924. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16925. /**
  16926. * Adds a new size gradient
  16927. * @param gradient defines the gradient to use (between 0 and 1)
  16928. * @param factor defines the size factor to affect to the specified gradient
  16929. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16930. * @returns the current particle system
  16931. */
  16932. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16933. /**
  16934. * Remove a specific size gradient
  16935. * @param gradient defines the gradient to remove
  16936. * @returns the current particle system
  16937. */
  16938. removeSizeGradient(gradient: number): IParticleSystem;
  16939. /**
  16940. * Adds a new color remap gradient
  16941. * @param gradient defines the gradient to use (between 0 and 1)
  16942. * @param min defines the color remap minimal range
  16943. * @param max defines the color remap maximal range
  16944. * @returns the current particle system
  16945. */
  16946. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16947. /**
  16948. * Remove a specific color remap gradient
  16949. * @param gradient defines the gradient to remove
  16950. * @returns the current particle system
  16951. */
  16952. removeColorRemapGradient(gradient: number): IParticleSystem;
  16953. /**
  16954. * Adds a new alpha remap gradient
  16955. * @param gradient defines the gradient to use (between 0 and 1)
  16956. * @param min defines the alpha remap minimal range
  16957. * @param max defines the alpha remap maximal range
  16958. * @returns the current particle system
  16959. */
  16960. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16961. /**
  16962. * Remove a specific alpha remap gradient
  16963. * @param gradient defines the gradient to remove
  16964. * @returns the current particle system
  16965. */
  16966. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  16967. /**
  16968. * Adds a new angular speed gradient
  16969. * @param gradient defines the gradient to use (between 0 and 1)
  16970. * @param factor defines the angular speed to affect to the specified gradient
  16971. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16972. * @returns the current particle system
  16973. */
  16974. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16975. /**
  16976. * Remove a specific angular speed gradient
  16977. * @param gradient defines the gradient to remove
  16978. * @returns the current particle system
  16979. */
  16980. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16981. /**
  16982. * Adds a new velocity gradient
  16983. * @param gradient defines the gradient to use (between 0 and 1)
  16984. * @param factor defines the velocity to affect to the specified gradient
  16985. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16986. * @returns the current particle system
  16987. */
  16988. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16989. /**
  16990. * Remove a specific velocity gradient
  16991. * @param gradient defines the gradient to remove
  16992. * @returns the current particle system
  16993. */
  16994. removeVelocityGradient(gradient: number): IParticleSystem;
  16995. /**
  16996. * Adds a new limit velocity gradient
  16997. * @param gradient defines the gradient to use (between 0 and 1)
  16998. * @param factor defines the limit velocity value to affect to the specified gradient
  16999. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17000. * @returns the current particle system
  17001. */
  17002. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17003. /**
  17004. * Remove a specific limit velocity gradient
  17005. * @param gradient defines the gradient to remove
  17006. * @returns the current particle system
  17007. */
  17008. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17009. /**
  17010. * Adds a new drag gradient
  17011. * @param gradient defines the gradient to use (between 0 and 1)
  17012. * @param factor defines the drag value to affect to the specified gradient
  17013. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17014. * @returns the current particle system
  17015. */
  17016. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17017. /**
  17018. * Remove a specific drag gradient
  17019. * @param gradient defines the gradient to remove
  17020. * @returns the current particle system
  17021. */
  17022. removeDragGradient(gradient: number): IParticleSystem;
  17023. /**
  17024. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17025. * @param gradient defines the gradient to use (between 0 and 1)
  17026. * @param factor defines the emit rate value to affect to the specified gradient
  17027. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17028. * @returns the current particle system
  17029. */
  17030. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17031. /**
  17032. * Remove a specific emit rate gradient
  17033. * @param gradient defines the gradient to remove
  17034. * @returns the current particle system
  17035. */
  17036. removeEmitRateGradient(gradient: number): IParticleSystem;
  17037. /**
  17038. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17039. * @param gradient defines the gradient to use (between 0 and 1)
  17040. * @param factor defines the start size value to affect to the specified gradient
  17041. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17042. * @returns the current particle system
  17043. */
  17044. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17045. /**
  17046. * Remove a specific start size gradient
  17047. * @param gradient defines the gradient to remove
  17048. * @returns the current particle system
  17049. */
  17050. removeStartSizeGradient(gradient: number): IParticleSystem;
  17051. private _createRampGradientTexture;
  17052. /**
  17053. * Gets the current list of ramp gradients.
  17054. * You must use addRampGradient and removeRampGradient to udpate this list
  17055. * @returns the list of ramp gradients
  17056. */
  17057. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17058. /**
  17059. * Adds a new ramp gradient used to remap particle colors
  17060. * @param gradient defines the gradient to use (between 0 and 1)
  17061. * @param color defines the color to affect to the specified gradient
  17062. * @returns the current particle system
  17063. */
  17064. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17065. /**
  17066. * Remove a specific ramp gradient
  17067. * @param gradient defines the gradient to remove
  17068. * @returns the current particle system
  17069. */
  17070. removeRampGradient(gradient: number): ParticleSystem;
  17071. /**
  17072. * Adds a new color gradient
  17073. * @param gradient defines the gradient to use (between 0 and 1)
  17074. * @param color1 defines the color to affect to the specified gradient
  17075. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17076. * @returns this particle system
  17077. */
  17078. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17079. /**
  17080. * Remove a specific color gradient
  17081. * @param gradient defines the gradient to remove
  17082. * @returns this particle system
  17083. */
  17084. removeColorGradient(gradient: number): IParticleSystem;
  17085. private _fetchR;
  17086. protected _reset(): void;
  17087. private _resetEffect;
  17088. private _createVertexBuffers;
  17089. private _createIndexBuffer;
  17090. /**
  17091. * Gets the maximum number of particles active at the same time.
  17092. * @returns The max number of active particles.
  17093. */
  17094. getCapacity(): number;
  17095. /**
  17096. * Gets whether there are still active particles in the system.
  17097. * @returns True if it is alive, otherwise false.
  17098. */
  17099. isAlive(): boolean;
  17100. /**
  17101. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17102. * @returns True if it has been started, otherwise false.
  17103. */
  17104. isStarted(): boolean;
  17105. private _prepareSubEmitterInternalArray;
  17106. /**
  17107. * Starts the particle system and begins to emit
  17108. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17109. */
  17110. start(delay?: number): void;
  17111. /**
  17112. * Stops the particle system.
  17113. * @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.
  17114. */
  17115. stop(stopSubEmitters?: boolean): void;
  17116. /**
  17117. * Remove all active particles
  17118. */
  17119. reset(): void;
  17120. /**
  17121. * @hidden (for internal use only)
  17122. */ private _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17123. /**
  17124. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17125. * Its lifetime will start back at 0.
  17126. */
  17127. recycleParticle: (particle: Particle) => void;
  17128. private _stopSubEmitters;
  17129. private _createParticle;
  17130. private _removeFromRoot;
  17131. private _emitFromParticle;
  17132. private _update;
  17133. /** @hidden */ private static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17134. /** @hidden */ private static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17135. /** @hidden */
  17136. private _getEffect;
  17137. /**
  17138. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17139. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17140. */
  17141. animate(preWarmOnly?: boolean): void;
  17142. private _appendParticleVertices;
  17143. /**
  17144. * Rebuilds the particle system.
  17145. */
  17146. rebuild(): void;
  17147. /**
  17148. * Is this system ready to be used/rendered
  17149. * @return true if the system is ready
  17150. */
  17151. isReady(): boolean;
  17152. private _render;
  17153. /**
  17154. * Renders the particle system in its current state.
  17155. * @returns the current number of particles
  17156. */
  17157. render(): number;
  17158. /**
  17159. * Disposes the particle system and free the associated resources
  17160. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17161. */
  17162. dispose(disposeTexture?: boolean): void;
  17163. /**
  17164. * Clones the particle system.
  17165. * @param name The name of the cloned object
  17166. * @param newEmitter The new emitter to use
  17167. * @returns the cloned particle system
  17168. */
  17169. clone(name: string, newEmitter: any): ParticleSystem;
  17170. /**
  17171. * Serializes the particle system to a JSON object.
  17172. * @returns the JSON object
  17173. */
  17174. serialize(): any;
  17175. /** @hidden */ private static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17176. /** @hidden */ private static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17177. /**
  17178. * Parses a JSON object to create a particle system.
  17179. * @param parsedParticleSystem The JSON object to parse
  17180. * @param scene The scene to create the particle system in
  17181. * @param rootUrl The root url to use to load external dependencies like texture
  17182. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17183. * @returns the Parsed particle system
  17184. */
  17185. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17186. }
  17187. }
  17188. declare module BABYLON {
  17189. /**
  17190. * A particle represents one of the element emitted by a particle system.
  17191. * This is mainly define by its coordinates, direction, velocity and age.
  17192. */
  17193. export class Particle {
  17194. /**
  17195. * The particle system the particle belongs to.
  17196. */
  17197. particleSystem: ParticleSystem;
  17198. private static _Count;
  17199. /**
  17200. * Unique ID of the particle
  17201. */
  17202. id: number;
  17203. /**
  17204. * The world position of the particle in the scene.
  17205. */
  17206. position: Vector3;
  17207. /**
  17208. * The world direction of the particle in the scene.
  17209. */
  17210. direction: Vector3;
  17211. /**
  17212. * The color of the particle.
  17213. */
  17214. color: Color4;
  17215. /**
  17216. * The color change of the particle per step.
  17217. */
  17218. colorStep: Color4;
  17219. /**
  17220. * Defines how long will the life of the particle be.
  17221. */
  17222. lifeTime: number;
  17223. /**
  17224. * The current age of the particle.
  17225. */
  17226. age: number;
  17227. /**
  17228. * The current size of the particle.
  17229. */
  17230. size: number;
  17231. /**
  17232. * The current scale of the particle.
  17233. */
  17234. scale: Vector2;
  17235. /**
  17236. * The current angle of the particle.
  17237. */
  17238. angle: number;
  17239. /**
  17240. * Defines how fast is the angle changing.
  17241. */
  17242. angularSpeed: number;
  17243. /**
  17244. * Defines the cell index used by the particle to be rendered from a sprite.
  17245. */
  17246. cellIndex: number;
  17247. /**
  17248. * The information required to support color remapping
  17249. */
  17250. remapData: Vector4;
  17251. /** @hidden */ private _randomCellOffset?: number;
  17252. /** @hidden */ private _initialDirection: Nullable<Vector3>;
  17253. /** @hidden */ private _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17254. /** @hidden */ private _initialStartSpriteCellID: number;
  17255. /** @hidden */ private _initialEndSpriteCellID: number;
  17256. /** @hidden */ private _currentColorGradient: Nullable<ColorGradient>;
  17257. /** @hidden */ private _currentColor1: Color4;
  17258. /** @hidden */ private _currentColor2: Color4;
  17259. /** @hidden */ private _currentSizeGradient: Nullable<FactorGradient>;
  17260. /** @hidden */ private _currentSize1: number;
  17261. /** @hidden */ private _currentSize2: number;
  17262. /** @hidden */ private _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17263. /** @hidden */ private _currentAngularSpeed1: number;
  17264. /** @hidden */ private _currentAngularSpeed2: number;
  17265. /** @hidden */ private _currentVelocityGradient: Nullable<FactorGradient>;
  17266. /** @hidden */ private _currentVelocity1: number;
  17267. /** @hidden */ private _currentVelocity2: number;
  17268. /** @hidden */ private _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17269. /** @hidden */ private _currentLimitVelocity1: number;
  17270. /** @hidden */ private _currentLimitVelocity2: number;
  17271. /** @hidden */ private _currentDragGradient: Nullable<FactorGradient>;
  17272. /** @hidden */ private _currentDrag1: number;
  17273. /** @hidden */ private _currentDrag2: number;
  17274. /** @hidden */ private _randomNoiseCoordinates1: Vector3;
  17275. /** @hidden */ private _randomNoiseCoordinates2: Vector3;
  17276. /**
  17277. * Creates a new instance Particle
  17278. * @param particleSystem the particle system the particle belongs to
  17279. */
  17280. constructor(
  17281. /**
  17282. * The particle system the particle belongs to.
  17283. */
  17284. particleSystem: ParticleSystem);
  17285. private updateCellInfoFromSystem;
  17286. /**
  17287. * Defines how the sprite cell index is updated for the particle
  17288. */
  17289. updateCellIndex(): void;
  17290. /** @hidden */ private _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17291. /** @hidden */ private _inheritParticleInfoToSubEmitters(): void;
  17292. /** @hidden */ private _reset(): void;
  17293. /**
  17294. * Copy the properties of particle to another one.
  17295. * @param other the particle to copy the information to.
  17296. */
  17297. copyTo(other: Particle): void;
  17298. }
  17299. }
  17300. declare module BABYLON {
  17301. /**
  17302. * Particle emitter represents a volume emitting particles.
  17303. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17304. */
  17305. export interface IParticleEmitterType {
  17306. /**
  17307. * Called by the particle System when the direction is computed for the created particle.
  17308. * @param worldMatrix is the world matrix of the particle system
  17309. * @param directionToUpdate is the direction vector to update with the result
  17310. * @param particle is the particle we are computed the direction for
  17311. */
  17312. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17313. /**
  17314. * Called by the particle System when the position is computed for the created particle.
  17315. * @param worldMatrix is the world matrix of the particle system
  17316. * @param positionToUpdate is the position vector to update with the result
  17317. * @param particle is the particle we are computed the position for
  17318. */
  17319. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17320. /**
  17321. * Clones the current emitter and returns a copy of it
  17322. * @returns the new emitter
  17323. */
  17324. clone(): IParticleEmitterType;
  17325. /**
  17326. * Called by the GPUParticleSystem to setup the update shader
  17327. * @param effect defines the update shader
  17328. */
  17329. applyToShader(effect: Effect): void;
  17330. /**
  17331. * Returns a string to use to update the GPU particles update shader
  17332. * @returns the effect defines string
  17333. */
  17334. getEffectDefines(): string;
  17335. /**
  17336. * Returns a string representing the class name
  17337. * @returns a string containing the class name
  17338. */
  17339. getClassName(): string;
  17340. /**
  17341. * Serializes the particle system to a JSON object.
  17342. * @returns the JSON object
  17343. */
  17344. serialize(): any;
  17345. /**
  17346. * Parse properties from a JSON object
  17347. * @param serializationObject defines the JSON object
  17348. */
  17349. parse(serializationObject: any): void;
  17350. }
  17351. }
  17352. declare module BABYLON {
  17353. /**
  17354. * Particle emitter emitting particles from the inside of a box.
  17355. * It emits the particles randomly between 2 given directions.
  17356. */
  17357. export class BoxParticleEmitter implements IParticleEmitterType {
  17358. /**
  17359. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17360. */
  17361. direction1: Vector3;
  17362. /**
  17363. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17364. */
  17365. direction2: Vector3;
  17366. /**
  17367. * 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.
  17368. */
  17369. minEmitBox: Vector3;
  17370. /**
  17371. * 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.
  17372. */
  17373. maxEmitBox: Vector3;
  17374. /**
  17375. * Creates a new instance BoxParticleEmitter
  17376. */
  17377. constructor();
  17378. /**
  17379. * Called by the particle System when the direction is computed for the created particle.
  17380. * @param worldMatrix is the world matrix of the particle system
  17381. * @param directionToUpdate is the direction vector to update with the result
  17382. * @param particle is the particle we are computed the direction for
  17383. */
  17384. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17385. /**
  17386. * Called by the particle System when the position is computed for the created particle.
  17387. * @param worldMatrix is the world matrix of the particle system
  17388. * @param positionToUpdate is the position vector to update with the result
  17389. * @param particle is the particle we are computed the position for
  17390. */
  17391. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17392. /**
  17393. * Clones the current emitter and returns a copy of it
  17394. * @returns the new emitter
  17395. */
  17396. clone(): BoxParticleEmitter;
  17397. /**
  17398. * Called by the GPUParticleSystem to setup the update shader
  17399. * @param effect defines the update shader
  17400. */
  17401. applyToShader(effect: Effect): void;
  17402. /**
  17403. * Returns a string to use to update the GPU particles update shader
  17404. * @returns a string containng the defines string
  17405. */
  17406. getEffectDefines(): string;
  17407. /**
  17408. * Returns the string "BoxParticleEmitter"
  17409. * @returns a string containing the class name
  17410. */
  17411. getClassName(): string;
  17412. /**
  17413. * Serializes the particle system to a JSON object.
  17414. * @returns the JSON object
  17415. */
  17416. serialize(): any;
  17417. /**
  17418. * Parse properties from a JSON object
  17419. * @param serializationObject defines the JSON object
  17420. */
  17421. parse(serializationObject: any): void;
  17422. }
  17423. }
  17424. declare module BABYLON {
  17425. /**
  17426. * Particle emitter emitting particles from the inside of a cone.
  17427. * It emits the particles alongside the cone volume from the base to the particle.
  17428. * The emission direction might be randomized.
  17429. */
  17430. export class ConeParticleEmitter implements IParticleEmitterType {
  17431. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17432. directionRandomizer: number;
  17433. private _radius;
  17434. private _angle;
  17435. private _height;
  17436. /**
  17437. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17438. */
  17439. radiusRange: number;
  17440. /**
  17441. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17442. */
  17443. heightRange: number;
  17444. /**
  17445. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17446. */
  17447. emitFromSpawnPointOnly: boolean;
  17448. /**
  17449. * Gets or sets the radius of the emission cone
  17450. */
  17451. radius: number;
  17452. /**
  17453. * Gets or sets the angle of the emission cone
  17454. */
  17455. angle: number;
  17456. private _buildHeight;
  17457. /**
  17458. * Creates a new instance ConeParticleEmitter
  17459. * @param radius the radius of the emission cone (1 by default)
  17460. * @param angle the cone base angle (PI by default)
  17461. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17462. */
  17463. constructor(radius?: number, angle?: number,
  17464. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17465. directionRandomizer?: number);
  17466. /**
  17467. * Called by the particle System when the direction is computed for the created particle.
  17468. * @param worldMatrix is the world matrix of the particle system
  17469. * @param directionToUpdate is the direction vector to update with the result
  17470. * @param particle is the particle we are computed the direction for
  17471. */
  17472. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17473. /**
  17474. * Called by the particle System when the position is computed for the created particle.
  17475. * @param worldMatrix is the world matrix of the particle system
  17476. * @param positionToUpdate is the position vector to update with the result
  17477. * @param particle is the particle we are computed the position for
  17478. */
  17479. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17480. /**
  17481. * Clones the current emitter and returns a copy of it
  17482. * @returns the new emitter
  17483. */
  17484. clone(): ConeParticleEmitter;
  17485. /**
  17486. * Called by the GPUParticleSystem to setup the update shader
  17487. * @param effect defines the update shader
  17488. */
  17489. applyToShader(effect: Effect): void;
  17490. /**
  17491. * Returns a string to use to update the GPU particles update shader
  17492. * @returns a string containng the defines string
  17493. */
  17494. getEffectDefines(): string;
  17495. /**
  17496. * Returns the string "ConeParticleEmitter"
  17497. * @returns a string containing the class name
  17498. */
  17499. getClassName(): string;
  17500. /**
  17501. * Serializes the particle system to a JSON object.
  17502. * @returns the JSON object
  17503. */
  17504. serialize(): any;
  17505. /**
  17506. * Parse properties from a JSON object
  17507. * @param serializationObject defines the JSON object
  17508. */
  17509. parse(serializationObject: any): void;
  17510. }
  17511. }
  17512. declare module BABYLON {
  17513. /**
  17514. * Particle emitter emitting particles from the inside of a cylinder.
  17515. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17516. */
  17517. export class CylinderParticleEmitter implements IParticleEmitterType {
  17518. /**
  17519. * The radius of the emission cylinder.
  17520. */
  17521. radius: number;
  17522. /**
  17523. * The height of the emission cylinder.
  17524. */
  17525. height: number;
  17526. /**
  17527. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17528. */
  17529. radiusRange: number;
  17530. /**
  17531. * How much to randomize the particle direction [0-1].
  17532. */
  17533. directionRandomizer: number;
  17534. /**
  17535. * Creates a new instance CylinderParticleEmitter
  17536. * @param radius the radius of the emission cylinder (1 by default)
  17537. * @param height the height of the emission cylinder (1 by default)
  17538. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17539. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17540. */
  17541. constructor(
  17542. /**
  17543. * The radius of the emission cylinder.
  17544. */
  17545. radius?: number,
  17546. /**
  17547. * The height of the emission cylinder.
  17548. */
  17549. height?: number,
  17550. /**
  17551. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17552. */
  17553. radiusRange?: number,
  17554. /**
  17555. * How much to randomize the particle direction [0-1].
  17556. */
  17557. directionRandomizer?: number);
  17558. /**
  17559. * Called by the particle System when the direction is computed for the created particle.
  17560. * @param worldMatrix is the world matrix of the particle system
  17561. * @param directionToUpdate is the direction vector to update with the result
  17562. * @param particle is the particle we are computed the direction for
  17563. */
  17564. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17565. /**
  17566. * Called by the particle System when the position is computed for the created particle.
  17567. * @param worldMatrix is the world matrix of the particle system
  17568. * @param positionToUpdate is the position vector to update with the result
  17569. * @param particle is the particle we are computed the position for
  17570. */
  17571. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17572. /**
  17573. * Clones the current emitter and returns a copy of it
  17574. * @returns the new emitter
  17575. */
  17576. clone(): CylinderParticleEmitter;
  17577. /**
  17578. * Called by the GPUParticleSystem to setup the update shader
  17579. * @param effect defines the update shader
  17580. */
  17581. applyToShader(effect: Effect): void;
  17582. /**
  17583. * Returns a string to use to update the GPU particles update shader
  17584. * @returns a string containng the defines string
  17585. */
  17586. getEffectDefines(): string;
  17587. /**
  17588. * Returns the string "CylinderParticleEmitter"
  17589. * @returns a string containing the class name
  17590. */
  17591. getClassName(): string;
  17592. /**
  17593. * Serializes the particle system to a JSON object.
  17594. * @returns the JSON object
  17595. */
  17596. serialize(): any;
  17597. /**
  17598. * Parse properties from a JSON object
  17599. * @param serializationObject defines the JSON object
  17600. */
  17601. parse(serializationObject: any): void;
  17602. }
  17603. /**
  17604. * Particle emitter emitting particles from the inside of a cylinder.
  17605. * It emits the particles randomly between two vectors.
  17606. */
  17607. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17608. /**
  17609. * The min limit of the emission direction.
  17610. */
  17611. direction1: Vector3;
  17612. /**
  17613. * The max limit of the emission direction.
  17614. */
  17615. direction2: Vector3;
  17616. /**
  17617. * Creates a new instance CylinderDirectedParticleEmitter
  17618. * @param radius the radius of the emission cylinder (1 by default)
  17619. * @param height the height of the emission cylinder (1 by default)
  17620. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17621. * @param direction1 the min limit of the emission direction (up vector by default)
  17622. * @param direction2 the max limit of the emission direction (up vector by default)
  17623. */
  17624. constructor(radius?: number, height?: number, radiusRange?: number,
  17625. /**
  17626. * The min limit of the emission direction.
  17627. */
  17628. direction1?: Vector3,
  17629. /**
  17630. * The max limit of the emission direction.
  17631. */
  17632. direction2?: Vector3);
  17633. /**
  17634. * Called by the particle System when the direction is computed for the created particle.
  17635. * @param worldMatrix is the world matrix of the particle system
  17636. * @param directionToUpdate is the direction vector to update with the result
  17637. * @param particle is the particle we are computed the direction for
  17638. */
  17639. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17640. /**
  17641. * Clones the current emitter and returns a copy of it
  17642. * @returns the new emitter
  17643. */
  17644. clone(): CylinderDirectedParticleEmitter;
  17645. /**
  17646. * Called by the GPUParticleSystem to setup the update shader
  17647. * @param effect defines the update shader
  17648. */
  17649. applyToShader(effect: Effect): void;
  17650. /**
  17651. * Returns a string to use to update the GPU particles update shader
  17652. * @returns a string containng the defines string
  17653. */
  17654. getEffectDefines(): string;
  17655. /**
  17656. * Returns the string "CylinderDirectedParticleEmitter"
  17657. * @returns a string containing the class name
  17658. */
  17659. getClassName(): string;
  17660. /**
  17661. * Serializes the particle system to a JSON object.
  17662. * @returns the JSON object
  17663. */
  17664. serialize(): any;
  17665. /**
  17666. * Parse properties from a JSON object
  17667. * @param serializationObject defines the JSON object
  17668. */
  17669. parse(serializationObject: any): void;
  17670. }
  17671. }
  17672. declare module BABYLON {
  17673. /**
  17674. * Particle emitter emitting particles from the inside of a hemisphere.
  17675. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17676. */
  17677. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17678. /**
  17679. * The radius of the emission hemisphere.
  17680. */
  17681. radius: number;
  17682. /**
  17683. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17684. */
  17685. radiusRange: number;
  17686. /**
  17687. * How much to randomize the particle direction [0-1].
  17688. */
  17689. directionRandomizer: number;
  17690. /**
  17691. * Creates a new instance HemisphericParticleEmitter
  17692. * @param radius the radius of the emission hemisphere (1 by default)
  17693. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17694. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17695. */
  17696. constructor(
  17697. /**
  17698. * The radius of the emission hemisphere.
  17699. */
  17700. radius?: number,
  17701. /**
  17702. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17703. */
  17704. radiusRange?: number,
  17705. /**
  17706. * How much to randomize the particle direction [0-1].
  17707. */
  17708. directionRandomizer?: number);
  17709. /**
  17710. * Called by the particle System when the direction is computed for the created particle.
  17711. * @param worldMatrix is the world matrix of the particle system
  17712. * @param directionToUpdate is the direction vector to update with the result
  17713. * @param particle is the particle we are computed the direction for
  17714. */
  17715. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17716. /**
  17717. * Called by the particle System when the position is computed for the created particle.
  17718. * @param worldMatrix is the world matrix of the particle system
  17719. * @param positionToUpdate is the position vector to update with the result
  17720. * @param particle is the particle we are computed the position for
  17721. */
  17722. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17723. /**
  17724. * Clones the current emitter and returns a copy of it
  17725. * @returns the new emitter
  17726. */
  17727. clone(): HemisphericParticleEmitter;
  17728. /**
  17729. * Called by the GPUParticleSystem to setup the update shader
  17730. * @param effect defines the update shader
  17731. */
  17732. applyToShader(effect: Effect): void;
  17733. /**
  17734. * Returns a string to use to update the GPU particles update shader
  17735. * @returns a string containng the defines string
  17736. */
  17737. getEffectDefines(): string;
  17738. /**
  17739. * Returns the string "HemisphericParticleEmitter"
  17740. * @returns a string containing the class name
  17741. */
  17742. getClassName(): string;
  17743. /**
  17744. * Serializes the particle system to a JSON object.
  17745. * @returns the JSON object
  17746. */
  17747. serialize(): any;
  17748. /**
  17749. * Parse properties from a JSON object
  17750. * @param serializationObject defines the JSON object
  17751. */
  17752. parse(serializationObject: any): void;
  17753. }
  17754. }
  17755. declare module BABYLON {
  17756. /**
  17757. * Particle emitter emitting particles from a point.
  17758. * It emits the particles randomly between 2 given directions.
  17759. */
  17760. export class PointParticleEmitter implements IParticleEmitterType {
  17761. /**
  17762. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17763. */
  17764. direction1: Vector3;
  17765. /**
  17766. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17767. */
  17768. direction2: Vector3;
  17769. /**
  17770. * Creates a new instance PointParticleEmitter
  17771. */
  17772. constructor();
  17773. /**
  17774. * Called by the particle System when the direction is computed for the created particle.
  17775. * @param worldMatrix is the world matrix of the particle system
  17776. * @param directionToUpdate is the direction vector to update with the result
  17777. * @param particle is the particle we are computed the direction for
  17778. */
  17779. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17780. /**
  17781. * Called by the particle System when the position is computed for the created particle.
  17782. * @param worldMatrix is the world matrix of the particle system
  17783. * @param positionToUpdate is the position vector to update with the result
  17784. * @param particle is the particle we are computed the position for
  17785. */
  17786. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17787. /**
  17788. * Clones the current emitter and returns a copy of it
  17789. * @returns the new emitter
  17790. */
  17791. clone(): PointParticleEmitter;
  17792. /**
  17793. * Called by the GPUParticleSystem to setup the update shader
  17794. * @param effect defines the update shader
  17795. */
  17796. applyToShader(effect: Effect): void;
  17797. /**
  17798. * Returns a string to use to update the GPU particles update shader
  17799. * @returns a string containng the defines string
  17800. */
  17801. getEffectDefines(): string;
  17802. /**
  17803. * Returns the string "PointParticleEmitter"
  17804. * @returns a string containing the class name
  17805. */
  17806. getClassName(): string;
  17807. /**
  17808. * Serializes the particle system to a JSON object.
  17809. * @returns the JSON object
  17810. */
  17811. serialize(): any;
  17812. /**
  17813. * Parse properties from a JSON object
  17814. * @param serializationObject defines the JSON object
  17815. */
  17816. parse(serializationObject: any): void;
  17817. }
  17818. }
  17819. declare module BABYLON {
  17820. /**
  17821. * Particle emitter emitting particles from the inside of a sphere.
  17822. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  17823. */
  17824. export class SphereParticleEmitter implements IParticleEmitterType {
  17825. /**
  17826. * The radius of the emission sphere.
  17827. */
  17828. radius: number;
  17829. /**
  17830. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17831. */
  17832. radiusRange: number;
  17833. /**
  17834. * How much to randomize the particle direction [0-1].
  17835. */
  17836. directionRandomizer: number;
  17837. /**
  17838. * Creates a new instance SphereParticleEmitter
  17839. * @param radius the radius of the emission sphere (1 by default)
  17840. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17841. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17842. */
  17843. constructor(
  17844. /**
  17845. * The radius of the emission sphere.
  17846. */
  17847. radius?: number,
  17848. /**
  17849. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17850. */
  17851. radiusRange?: number,
  17852. /**
  17853. * How much to randomize the particle direction [0-1].
  17854. */
  17855. directionRandomizer?: number);
  17856. /**
  17857. * Called by the particle System when the direction is computed for the created particle.
  17858. * @param worldMatrix is the world matrix of the particle system
  17859. * @param directionToUpdate is the direction vector to update with the result
  17860. * @param particle is the particle we are computed the direction for
  17861. */
  17862. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17863. /**
  17864. * Called by the particle System when the position is computed for the created particle.
  17865. * @param worldMatrix is the world matrix of the particle system
  17866. * @param positionToUpdate is the position vector to update with the result
  17867. * @param particle is the particle we are computed the position for
  17868. */
  17869. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17870. /**
  17871. * Clones the current emitter and returns a copy of it
  17872. * @returns the new emitter
  17873. */
  17874. clone(): SphereParticleEmitter;
  17875. /**
  17876. * Called by the GPUParticleSystem to setup the update shader
  17877. * @param effect defines the update shader
  17878. */
  17879. applyToShader(effect: Effect): void;
  17880. /**
  17881. * Returns a string to use to update the GPU particles update shader
  17882. * @returns a string containng the defines string
  17883. */
  17884. getEffectDefines(): string;
  17885. /**
  17886. * Returns the string "SphereParticleEmitter"
  17887. * @returns a string containing the class name
  17888. */
  17889. getClassName(): string;
  17890. /**
  17891. * Serializes the particle system to a JSON object.
  17892. * @returns the JSON object
  17893. */
  17894. serialize(): any;
  17895. /**
  17896. * Parse properties from a JSON object
  17897. * @param serializationObject defines the JSON object
  17898. */
  17899. parse(serializationObject: any): void;
  17900. }
  17901. /**
  17902. * Particle emitter emitting particles from the inside of a sphere.
  17903. * It emits the particles randomly between two vectors.
  17904. */
  17905. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  17906. /**
  17907. * The min limit of the emission direction.
  17908. */
  17909. direction1: Vector3;
  17910. /**
  17911. * The max limit of the emission direction.
  17912. */
  17913. direction2: Vector3;
  17914. /**
  17915. * Creates a new instance SphereDirectedParticleEmitter
  17916. * @param radius the radius of the emission sphere (1 by default)
  17917. * @param direction1 the min limit of the emission direction (up vector by default)
  17918. * @param direction2 the max limit of the emission direction (up vector by default)
  17919. */
  17920. constructor(radius?: number,
  17921. /**
  17922. * The min limit of the emission direction.
  17923. */
  17924. direction1?: Vector3,
  17925. /**
  17926. * The max limit of the emission direction.
  17927. */
  17928. direction2?: Vector3);
  17929. /**
  17930. * Called by the particle System when the direction is computed for the created particle.
  17931. * @param worldMatrix is the world matrix of the particle system
  17932. * @param directionToUpdate is the direction vector to update with the result
  17933. * @param particle is the particle we are computed the direction for
  17934. */
  17935. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17936. /**
  17937. * Clones the current emitter and returns a copy of it
  17938. * @returns the new emitter
  17939. */
  17940. clone(): SphereDirectedParticleEmitter;
  17941. /**
  17942. * Called by the GPUParticleSystem to setup the update shader
  17943. * @param effect defines the update shader
  17944. */
  17945. applyToShader(effect: Effect): void;
  17946. /**
  17947. * Returns a string to use to update the GPU particles update shader
  17948. * @returns a string containng the defines string
  17949. */
  17950. getEffectDefines(): string;
  17951. /**
  17952. * Returns the string "SphereDirectedParticleEmitter"
  17953. * @returns a string containing the class name
  17954. */
  17955. getClassName(): string;
  17956. /**
  17957. * Serializes the particle system to a JSON object.
  17958. * @returns the JSON object
  17959. */
  17960. serialize(): any;
  17961. /**
  17962. * Parse properties from a JSON object
  17963. * @param serializationObject defines the JSON object
  17964. */
  17965. parse(serializationObject: any): void;
  17966. }
  17967. }
  17968. declare module BABYLON {
  17969. /**
  17970. * Interface representing a particle system in Babylon.js.
  17971. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17972. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  17973. */
  17974. export interface IParticleSystem {
  17975. /**
  17976. * List of animations used by the particle system.
  17977. */
  17978. animations: Animation[];
  17979. /**
  17980. * The id of the Particle system.
  17981. */
  17982. id: string;
  17983. /**
  17984. * The name of the Particle system.
  17985. */
  17986. name: string;
  17987. /**
  17988. * The emitter represents the Mesh or position we are attaching the particle system to.
  17989. */
  17990. emitter: Nullable<AbstractMesh | Vector3>;
  17991. /**
  17992. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17993. */
  17994. isBillboardBased: boolean;
  17995. /**
  17996. * The rendering group used by the Particle system to chose when to render.
  17997. */
  17998. renderingGroupId: number;
  17999. /**
  18000. * The layer mask we are rendering the particles through.
  18001. */
  18002. layerMask: number;
  18003. /**
  18004. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18005. */
  18006. updateSpeed: number;
  18007. /**
  18008. * The amount of time the particle system is running (depends of the overall update speed).
  18009. */
  18010. targetStopDuration: number;
  18011. /**
  18012. * The texture used to render each particle. (this can be a spritesheet)
  18013. */
  18014. particleTexture: Nullable<Texture>;
  18015. /**
  18016. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18017. */
  18018. blendMode: number;
  18019. /**
  18020. * Minimum life time of emitting particles.
  18021. */
  18022. minLifeTime: number;
  18023. /**
  18024. * Maximum life time of emitting particles.
  18025. */
  18026. maxLifeTime: number;
  18027. /**
  18028. * Minimum Size of emitting particles.
  18029. */
  18030. minSize: number;
  18031. /**
  18032. * Maximum Size of emitting particles.
  18033. */
  18034. maxSize: number;
  18035. /**
  18036. * Minimum scale of emitting particles on X axis.
  18037. */
  18038. minScaleX: number;
  18039. /**
  18040. * Maximum scale of emitting particles on X axis.
  18041. */
  18042. maxScaleX: number;
  18043. /**
  18044. * Minimum scale of emitting particles on Y axis.
  18045. */
  18046. minScaleY: number;
  18047. /**
  18048. * Maximum scale of emitting particles on Y axis.
  18049. */
  18050. maxScaleY: number;
  18051. /**
  18052. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18053. */
  18054. color1: Color4;
  18055. /**
  18056. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18057. */
  18058. color2: Color4;
  18059. /**
  18060. * Color the particle will have at the end of its lifetime.
  18061. */
  18062. colorDead: Color4;
  18063. /**
  18064. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18065. */
  18066. emitRate: number;
  18067. /**
  18068. * You can use gravity if you want to give an orientation to your particles.
  18069. */
  18070. gravity: Vector3;
  18071. /**
  18072. * Minimum power of emitting particles.
  18073. */
  18074. minEmitPower: number;
  18075. /**
  18076. * Maximum power of emitting particles.
  18077. */
  18078. maxEmitPower: number;
  18079. /**
  18080. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18081. */
  18082. minAngularSpeed: number;
  18083. /**
  18084. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18085. */
  18086. maxAngularSpeed: number;
  18087. /**
  18088. * Gets or sets the minimal initial rotation in radians.
  18089. */
  18090. minInitialRotation: number;
  18091. /**
  18092. * Gets or sets the maximal initial rotation in radians.
  18093. */
  18094. maxInitialRotation: number;
  18095. /**
  18096. * The particle emitter type defines the emitter used by the particle system.
  18097. * It can be for example box, sphere, or cone...
  18098. */
  18099. particleEmitterType: Nullable<IParticleEmitterType>;
  18100. /**
  18101. * Defines the delay in milliseconds before starting the system (0 by default)
  18102. */
  18103. startDelay: number;
  18104. /**
  18105. * 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
  18106. */
  18107. preWarmCycles: number;
  18108. /**
  18109. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18110. */
  18111. preWarmStepOffset: number;
  18112. /**
  18113. * 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)
  18114. */
  18115. spriteCellChangeSpeed: number;
  18116. /**
  18117. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18118. */
  18119. startSpriteCellID: number;
  18120. /**
  18121. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18122. */
  18123. endSpriteCellID: number;
  18124. /**
  18125. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18126. */
  18127. spriteCellWidth: number;
  18128. /**
  18129. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18130. */
  18131. spriteCellHeight: number;
  18132. /**
  18133. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18134. */
  18135. spriteRandomStartCell: boolean;
  18136. /**
  18137. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18138. */
  18139. isAnimationSheetEnabled: boolean;
  18140. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18141. translationPivot: Vector2;
  18142. /**
  18143. * Gets or sets a texture used to add random noise to particle positions
  18144. */
  18145. noiseTexture: Nullable<BaseTexture>;
  18146. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18147. noiseStrength: Vector3;
  18148. /**
  18149. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18150. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18151. */
  18152. billboardMode: number;
  18153. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18154. limitVelocityDamping: number;
  18155. /**
  18156. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18157. */
  18158. beginAnimationOnStart: boolean;
  18159. /**
  18160. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18161. */
  18162. beginAnimationFrom: number;
  18163. /**
  18164. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18165. */
  18166. beginAnimationTo: number;
  18167. /**
  18168. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18169. */
  18170. beginAnimationLoop: boolean;
  18171. /**
  18172. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18173. */
  18174. disposeOnStop: boolean;
  18175. /**
  18176. * Gets the maximum number of particles active at the same time.
  18177. * @returns The max number of active particles.
  18178. */
  18179. getCapacity(): number;
  18180. /**
  18181. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18182. * @returns True if it has been started, otherwise false.
  18183. */
  18184. isStarted(): boolean;
  18185. /**
  18186. * Animates the particle system for this frame.
  18187. */
  18188. animate(): void;
  18189. /**
  18190. * Renders the particle system in its current state.
  18191. * @returns the current number of particles
  18192. */
  18193. render(): number;
  18194. /**
  18195. * Dispose the particle system and frees its associated resources.
  18196. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18197. */
  18198. dispose(disposeTexture?: boolean): void;
  18199. /**
  18200. * Clones the particle system.
  18201. * @param name The name of the cloned object
  18202. * @param newEmitter The new emitter to use
  18203. * @returns the cloned particle system
  18204. */
  18205. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18206. /**
  18207. * Serializes the particle system to a JSON object.
  18208. * @returns the JSON object
  18209. */
  18210. serialize(): any;
  18211. /**
  18212. * Rebuild the particle system
  18213. */
  18214. rebuild(): void;
  18215. /**
  18216. * Starts the particle system and begins to emit
  18217. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18218. */
  18219. start(delay?: number): void;
  18220. /**
  18221. * Stops the particle system.
  18222. */
  18223. stop(): void;
  18224. /**
  18225. * Remove all active particles
  18226. */
  18227. reset(): void;
  18228. /**
  18229. * Is this system ready to be used/rendered
  18230. * @return true if the system is ready
  18231. */
  18232. isReady(): boolean;
  18233. /**
  18234. * Adds a new color gradient
  18235. * @param gradient defines the gradient to use (between 0 and 1)
  18236. * @param color1 defines the color to affect to the specified gradient
  18237. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18238. * @returns the current particle system
  18239. */
  18240. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18241. /**
  18242. * Remove a specific color gradient
  18243. * @param gradient defines the gradient to remove
  18244. * @returns the current particle system
  18245. */
  18246. removeColorGradient(gradient: number): IParticleSystem;
  18247. /**
  18248. * Adds a new size gradient
  18249. * @param gradient defines the gradient to use (between 0 and 1)
  18250. * @param factor defines the size factor to affect to the specified gradient
  18251. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18252. * @returns the current particle system
  18253. */
  18254. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18255. /**
  18256. * Remove a specific size gradient
  18257. * @param gradient defines the gradient to remove
  18258. * @returns the current particle system
  18259. */
  18260. removeSizeGradient(gradient: number): IParticleSystem;
  18261. /**
  18262. * Gets the current list of color gradients.
  18263. * You must use addColorGradient and removeColorGradient to udpate this list
  18264. * @returns the list of color gradients
  18265. */
  18266. getColorGradients(): Nullable<Array<ColorGradient>>;
  18267. /**
  18268. * Gets the current list of size gradients.
  18269. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18270. * @returns the list of size gradients
  18271. */
  18272. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18273. /**
  18274. * Gets the current list of angular speed gradients.
  18275. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18276. * @returns the list of angular speed gradients
  18277. */
  18278. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18279. /**
  18280. * Adds a new angular speed gradient
  18281. * @param gradient defines the gradient to use (between 0 and 1)
  18282. * @param factor defines the angular speed to affect to the specified gradient
  18283. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18284. * @returns the current particle system
  18285. */
  18286. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18287. /**
  18288. * Remove a specific angular speed gradient
  18289. * @param gradient defines the gradient to remove
  18290. * @returns the current particle system
  18291. */
  18292. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18293. /**
  18294. * Gets the current list of velocity gradients.
  18295. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18296. * @returns the list of velocity gradients
  18297. */
  18298. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18299. /**
  18300. * Adds a new velocity gradient
  18301. * @param gradient defines the gradient to use (between 0 and 1)
  18302. * @param factor defines the velocity to affect to the specified gradient
  18303. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18304. * @returns the current particle system
  18305. */
  18306. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18307. /**
  18308. * Remove a specific velocity gradient
  18309. * @param gradient defines the gradient to remove
  18310. * @returns the current particle system
  18311. */
  18312. removeVelocityGradient(gradient: number): IParticleSystem;
  18313. /**
  18314. * Gets the current list of limit velocity gradients.
  18315. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18316. * @returns the list of limit velocity gradients
  18317. */
  18318. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18319. /**
  18320. * Adds a new limit velocity gradient
  18321. * @param gradient defines the gradient to use (between 0 and 1)
  18322. * @param factor defines the limit velocity to affect to the specified gradient
  18323. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18324. * @returns the current particle system
  18325. */
  18326. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18327. /**
  18328. * Remove a specific limit velocity gradient
  18329. * @param gradient defines the gradient to remove
  18330. * @returns the current particle system
  18331. */
  18332. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18333. /**
  18334. * Adds a new drag gradient
  18335. * @param gradient defines the gradient to use (between 0 and 1)
  18336. * @param factor defines the drag to affect to the specified gradient
  18337. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18338. * @returns the current particle system
  18339. */
  18340. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18341. /**
  18342. * Remove a specific drag gradient
  18343. * @param gradient defines the gradient to remove
  18344. * @returns the current particle system
  18345. */
  18346. removeDragGradient(gradient: number): IParticleSystem;
  18347. /**
  18348. * Gets the current list of drag gradients.
  18349. * You must use addDragGradient and removeDragGradient to udpate this list
  18350. * @returns the list of drag gradients
  18351. */
  18352. getDragGradients(): Nullable<Array<FactorGradient>>;
  18353. /**
  18354. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18355. * @param gradient defines the gradient to use (between 0 and 1)
  18356. * @param factor defines the emit rate to affect to the specified gradient
  18357. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18358. * @returns the current particle system
  18359. */
  18360. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18361. /**
  18362. * Remove a specific emit rate gradient
  18363. * @param gradient defines the gradient to remove
  18364. * @returns the current particle system
  18365. */
  18366. removeEmitRateGradient(gradient: number): IParticleSystem;
  18367. /**
  18368. * Gets the current list of emit rate gradients.
  18369. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18370. * @returns the list of emit rate gradients
  18371. */
  18372. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18373. /**
  18374. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18375. * @param gradient defines the gradient to use (between 0 and 1)
  18376. * @param factor defines the start size to affect to the specified gradient
  18377. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18378. * @returns the current particle system
  18379. */
  18380. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18381. /**
  18382. * Remove a specific start size gradient
  18383. * @param gradient defines the gradient to remove
  18384. * @returns the current particle system
  18385. */
  18386. removeStartSizeGradient(gradient: number): IParticleSystem;
  18387. /**
  18388. * Gets the current list of start size gradients.
  18389. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18390. * @returns the list of start size gradients
  18391. */
  18392. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18393. /**
  18394. * Adds a new life time gradient
  18395. * @param gradient defines the gradient to use (between 0 and 1)
  18396. * @param factor defines the life time factor to affect to the specified gradient
  18397. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18398. * @returns the current particle system
  18399. */
  18400. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18401. /**
  18402. * Remove a specific life time gradient
  18403. * @param gradient defines the gradient to remove
  18404. * @returns the current particle system
  18405. */
  18406. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18407. /**
  18408. * Gets the current list of life time gradients.
  18409. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18410. * @returns the list of life time gradients
  18411. */
  18412. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18413. /**
  18414. * Gets the current list of color gradients.
  18415. * You must use addColorGradient and removeColorGradient to udpate this list
  18416. * @returns the list of color gradients
  18417. */
  18418. getColorGradients(): Nullable<Array<ColorGradient>>;
  18419. /**
  18420. * Adds a new ramp gradient used to remap particle colors
  18421. * @param gradient defines the gradient to use (between 0 and 1)
  18422. * @param color defines the color to affect to the specified gradient
  18423. * @returns the current particle system
  18424. */
  18425. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18426. /**
  18427. * Gets the current list of ramp gradients.
  18428. * You must use addRampGradient and removeRampGradient to udpate this list
  18429. * @returns the list of ramp gradients
  18430. */
  18431. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18432. /** Gets or sets a boolean indicating that ramp gradients must be used
  18433. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18434. */
  18435. useRampGradients: boolean;
  18436. /**
  18437. * Adds a new color remap gradient
  18438. * @param gradient defines the gradient to use (between 0 and 1)
  18439. * @param min defines the color remap minimal range
  18440. * @param max defines the color remap maximal range
  18441. * @returns the current particle system
  18442. */
  18443. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18444. /**
  18445. * Gets the current list of color remap gradients.
  18446. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18447. * @returns the list of color remap gradients
  18448. */
  18449. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18450. /**
  18451. * Adds a new alpha remap gradient
  18452. * @param gradient defines the gradient to use (between 0 and 1)
  18453. * @param min defines the alpha remap minimal range
  18454. * @param max defines the alpha remap maximal range
  18455. * @returns the current particle system
  18456. */
  18457. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18458. /**
  18459. * Gets the current list of alpha remap gradients.
  18460. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18461. * @returns the list of alpha remap gradients
  18462. */
  18463. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18464. /**
  18465. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18466. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18467. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18468. * @returns the emitter
  18469. */
  18470. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18471. /**
  18472. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18473. * @param radius The radius of the hemisphere to emit from
  18474. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18475. * @returns the emitter
  18476. */
  18477. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18478. /**
  18479. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18480. * @param radius The radius of the sphere to emit from
  18481. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18482. * @returns the emitter
  18483. */
  18484. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18485. /**
  18486. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18487. * @param radius The radius of the sphere to emit from
  18488. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18489. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18490. * @returns the emitter
  18491. */
  18492. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18493. /**
  18494. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18495. * @param radius The radius of the emission cylinder
  18496. * @param height The height of the emission cylinder
  18497. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18498. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18499. * @returns the emitter
  18500. */
  18501. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18502. /**
  18503. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18504. * @param radius The radius of the cylinder to emit from
  18505. * @param height The height of the emission cylinder
  18506. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18507. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18508. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18509. * @returns the emitter
  18510. */
  18511. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18512. /**
  18513. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18514. * @param radius The radius of the cone to emit from
  18515. * @param angle The base angle of the cone
  18516. * @returns the emitter
  18517. */
  18518. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18519. /**
  18520. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18521. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18522. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18523. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18524. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18525. * @returns the emitter
  18526. */
  18527. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18528. /**
  18529. * Get hosting scene
  18530. * @returns the scene
  18531. */
  18532. getScene(): Scene;
  18533. }
  18534. }
  18535. declare module BABYLON {
  18536. /**
  18537. * Creates an instance based on a source mesh.
  18538. */
  18539. export class InstancedMesh extends AbstractMesh {
  18540. private _sourceMesh;
  18541. private _currentLOD;
  18542. /** @hidden */ private _indexInSourceMeshInstanceArray: number;
  18543. constructor(name: string, source: Mesh);
  18544. /**
  18545. * Returns the string "InstancedMesh".
  18546. */
  18547. getClassName(): string;
  18548. /** Gets the list of lights affecting that mesh */
  18549. readonly lightSources: Light[]; private _resyncLightSources(): void; private _resyncLighSource(light: Light): void; private _removeLightSource(light: Light, dispose: boolean): void;
  18550. /**
  18551. * If the source mesh receives shadows
  18552. */
  18553. readonly receiveShadows: boolean;
  18554. /**
  18555. * The material of the source mesh
  18556. */
  18557. readonly material: Nullable<Material>;
  18558. /**
  18559. * Visibility of the source mesh
  18560. */
  18561. readonly visibility: number;
  18562. /**
  18563. * Skeleton of the source mesh
  18564. */
  18565. readonly skeleton: Nullable<Skeleton>;
  18566. /**
  18567. * Rendering ground id of the source mesh
  18568. */
  18569. renderingGroupId: number;
  18570. /**
  18571. * Returns the total number of vertices (integer).
  18572. */
  18573. getTotalVertices(): number;
  18574. /**
  18575. * Returns a positive integer : the total number of indices in this mesh geometry.
  18576. * @returns the numner of indices or zero if the mesh has no geometry.
  18577. */
  18578. getTotalIndices(): number;
  18579. /**
  18580. * The source mesh of the instance
  18581. */
  18582. readonly sourceMesh: Mesh;
  18583. /**
  18584. * Is this node ready to be used/rendered
  18585. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18586. * @return {boolean} is it ready
  18587. */
  18588. isReady(completeCheck?: boolean): boolean;
  18589. /**
  18590. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18591. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18592. * @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.
  18593. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18594. */
  18595. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18596. /**
  18597. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18598. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18599. * The `data` are either a numeric array either a Float32Array.
  18600. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18601. * 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).
  18602. * Note that a new underlying VertexBuffer object is created each call.
  18603. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18604. *
  18605. * Possible `kind` values :
  18606. * - VertexBuffer.PositionKind
  18607. * - VertexBuffer.UVKind
  18608. * - VertexBuffer.UV2Kind
  18609. * - VertexBuffer.UV3Kind
  18610. * - VertexBuffer.UV4Kind
  18611. * - VertexBuffer.UV5Kind
  18612. * - VertexBuffer.UV6Kind
  18613. * - VertexBuffer.ColorKind
  18614. * - VertexBuffer.MatricesIndicesKind
  18615. * - VertexBuffer.MatricesIndicesExtraKind
  18616. * - VertexBuffer.MatricesWeightsKind
  18617. * - VertexBuffer.MatricesWeightsExtraKind
  18618. *
  18619. * Returns the Mesh.
  18620. */
  18621. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18622. /**
  18623. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18624. * If the mesh has no geometry, it is simply returned as it is.
  18625. * The `data` are either a numeric array either a Float32Array.
  18626. * No new underlying VertexBuffer object is created.
  18627. * 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.
  18628. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18629. *
  18630. * Possible `kind` values :
  18631. * - VertexBuffer.PositionKind
  18632. * - VertexBuffer.UVKind
  18633. * - VertexBuffer.UV2Kind
  18634. * - VertexBuffer.UV3Kind
  18635. * - VertexBuffer.UV4Kind
  18636. * - VertexBuffer.UV5Kind
  18637. * - VertexBuffer.UV6Kind
  18638. * - VertexBuffer.ColorKind
  18639. * - VertexBuffer.MatricesIndicesKind
  18640. * - VertexBuffer.MatricesIndicesExtraKind
  18641. * - VertexBuffer.MatricesWeightsKind
  18642. * - VertexBuffer.MatricesWeightsExtraKind
  18643. *
  18644. * Returns the Mesh.
  18645. */
  18646. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18647. /**
  18648. * Sets the mesh indices.
  18649. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18650. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18651. * This method creates a new index buffer each call.
  18652. * Returns the Mesh.
  18653. */
  18654. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18655. /**
  18656. * Boolean : True if the mesh owns the requested kind of data.
  18657. */
  18658. isVerticesDataPresent(kind: string): boolean;
  18659. /**
  18660. * Returns an array of indices (IndicesArray).
  18661. */
  18662. getIndices(): Nullable<IndicesArray>; protected readonly _positions: Nullable<Vector3[]>;
  18663. /**
  18664. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18665. * This means the mesh underlying bounding box and sphere are recomputed.
  18666. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18667. * @returns the current mesh
  18668. */
  18669. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18670. /** @hidden */ private _preActivate(): InstancedMesh;
  18671. /** @hidden */ private _activate(renderId: number, intermediateRendering: boolean): boolean;
  18672. /** @hidden */ private _postActivate(): void;
  18673. getWorldMatrix(): Matrix;
  18674. readonly isAnInstance: boolean;
  18675. /**
  18676. * Returns the current associated LOD AbstractMesh.
  18677. */
  18678. getLOD(camera: Camera): AbstractMesh;
  18679. /** @hidden */ private _syncSubMeshes(): InstancedMesh;
  18680. /** @hidden */ private _generatePointsArray(): boolean;
  18681. /**
  18682. * Creates a new InstancedMesh from the current mesh.
  18683. * - name (string) : the cloned mesh name
  18684. * - newParent (optional Node) : the optional Node to parent the clone to.
  18685. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  18686. *
  18687. * Returns the clone.
  18688. */
  18689. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  18690. /**
  18691. * Disposes the InstancedMesh.
  18692. * Returns nothing.
  18693. */
  18694. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18695. }
  18696. interface Mesh {
  18697. /**
  18698. * Register a custom buffer that will be instanced
  18699. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  18700. * @param kind defines the buffer kind
  18701. * @param stride defines the stride in floats
  18702. */
  18703. registerInstancedBuffer(kind: string, stride: number): void;
  18704. /** @hidden */ private _userInstancedBuffersStorage: {
  18705. data: {
  18706. [key: string]: Float32Array;
  18707. };
  18708. sizes: {
  18709. [key: string]: number;
  18710. };
  18711. vertexBuffers: {
  18712. [key: string]: Nullable<VertexBuffer>;
  18713. };
  18714. strides: {
  18715. [key: string]: number;
  18716. };
  18717. };
  18718. }
  18719. interface AbstractMesh {
  18720. /**
  18721. * Object used to store instanced buffers defined by user
  18722. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  18723. */
  18724. instancedBuffers: {
  18725. [key: string]: any;
  18726. };
  18727. }
  18728. }
  18729. declare module BABYLON {
  18730. /**
  18731. * Defines the options associated with the creation of a shader material.
  18732. */
  18733. export interface IShaderMaterialOptions {
  18734. /**
  18735. * Does the material work in alpha blend mode
  18736. */
  18737. needAlphaBlending: boolean;
  18738. /**
  18739. * Does the material work in alpha test mode
  18740. */
  18741. needAlphaTesting: boolean;
  18742. /**
  18743. * The list of attribute names used in the shader
  18744. */
  18745. attributes: string[];
  18746. /**
  18747. * The list of unifrom names used in the shader
  18748. */
  18749. uniforms: string[];
  18750. /**
  18751. * The list of UBO names used in the shader
  18752. */
  18753. uniformBuffers: string[];
  18754. /**
  18755. * The list of sampler names used in the shader
  18756. */
  18757. samplers: string[];
  18758. /**
  18759. * The list of defines used in the shader
  18760. */
  18761. defines: string[];
  18762. }
  18763. /**
  18764. * 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.
  18765. *
  18766. * This returned material effects how the mesh will look based on the code in the shaders.
  18767. *
  18768. * @see http://doc.babylonjs.com/how_to/shader_material
  18769. */
  18770. export class ShaderMaterial extends Material {
  18771. private _shaderPath;
  18772. private _options;
  18773. private _textures;
  18774. private _textureArrays;
  18775. private _floats;
  18776. private _ints;
  18777. private _floatsArrays;
  18778. private _colors3;
  18779. private _colors3Arrays;
  18780. private _colors4;
  18781. private _colors4Arrays;
  18782. private _vectors2;
  18783. private _vectors3;
  18784. private _vectors4;
  18785. private _matrices;
  18786. private _matrices3x3;
  18787. private _matrices2x2;
  18788. private _vectors2Arrays;
  18789. private _vectors3Arrays;
  18790. private _vectors4Arrays;
  18791. private _cachedWorldViewMatrix;
  18792. private _cachedWorldViewProjectionMatrix;
  18793. private _renderId;
  18794. /**
  18795. * Instantiate a new shader material.
  18796. * 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.
  18797. * This returned material effects how the mesh will look based on the code in the shaders.
  18798. * @see http://doc.babylonjs.com/how_to/shader_material
  18799. * @param name Define the name of the material in the scene
  18800. * @param scene Define the scene the material belongs to
  18801. * @param shaderPath Defines the route to the shader code in one of three ways:
  18802. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  18803. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  18804. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  18805. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18806. * @param options Define the options used to create the shader
  18807. */
  18808. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18809. /**
  18810. * Gets the options used to compile the shader.
  18811. * They can be modified to trigger a new compilation
  18812. */
  18813. readonly options: IShaderMaterialOptions;
  18814. /**
  18815. * Gets the current class name of the material e.g. "ShaderMaterial"
  18816. * Mainly use in serialization.
  18817. * @returns the class name
  18818. */
  18819. getClassName(): string;
  18820. /**
  18821. * Specifies if the material will require alpha blending
  18822. * @returns a boolean specifying if alpha blending is needed
  18823. */
  18824. needAlphaBlending(): boolean;
  18825. /**
  18826. * Specifies if this material should be rendered in alpha test mode
  18827. * @returns a boolean specifying if an alpha test is needed.
  18828. */
  18829. needAlphaTesting(): boolean;
  18830. private _checkUniform;
  18831. /**
  18832. * Set a texture in the shader.
  18833. * @param name Define the name of the uniform samplers as defined in the shader
  18834. * @param texture Define the texture to bind to this sampler
  18835. * @return the material itself allowing "fluent" like uniform updates
  18836. */
  18837. setTexture(name: string, texture: Texture): ShaderMaterial;
  18838. /**
  18839. * Set a texture array in the shader.
  18840. * @param name Define the name of the uniform sampler array as defined in the shader
  18841. * @param textures Define the list of textures to bind to this sampler
  18842. * @return the material itself allowing "fluent" like uniform updates
  18843. */
  18844. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18845. /**
  18846. * Set a float in the shader.
  18847. * @param name Define the name of the uniform as defined in the shader
  18848. * @param value Define the value to give to the uniform
  18849. * @return the material itself allowing "fluent" like uniform updates
  18850. */
  18851. setFloat(name: string, value: number): ShaderMaterial;
  18852. /**
  18853. * Set a int in the shader.
  18854. * @param name Define the name of the uniform as defined in the shader
  18855. * @param value Define the value to give to the uniform
  18856. * @return the material itself allowing "fluent" like uniform updates
  18857. */
  18858. setInt(name: string, value: number): ShaderMaterial;
  18859. /**
  18860. * Set an array of floats in the shader.
  18861. * @param name Define the name of the uniform as defined in the shader
  18862. * @param value Define the value to give to the uniform
  18863. * @return the material itself allowing "fluent" like uniform updates
  18864. */
  18865. setFloats(name: string, value: number[]): ShaderMaterial;
  18866. /**
  18867. * Set a vec3 in the shader from a Color3.
  18868. * @param name Define the name of the uniform as defined in the shader
  18869. * @param value Define the value to give to the uniform
  18870. * @return the material itself allowing "fluent" like uniform updates
  18871. */
  18872. setColor3(name: string, value: Color3): ShaderMaterial;
  18873. /**
  18874. * Set a vec3 array in the shader from a Color3 array.
  18875. * @param name Define the name of the uniform as defined in the shader
  18876. * @param value Define the value to give to the uniform
  18877. * @return the material itself allowing "fluent" like uniform updates
  18878. */
  18879. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18880. /**
  18881. * Set a vec4 in the shader from a Color4.
  18882. * @param name Define the name of the uniform as defined in the shader
  18883. * @param value Define the value to give to the uniform
  18884. * @return the material itself allowing "fluent" like uniform updates
  18885. */
  18886. setColor4(name: string, value: Color4): ShaderMaterial;
  18887. /**
  18888. * Set a vec4 array in the shader from a Color4 array.
  18889. * @param name Define the name of the uniform as defined in the shader
  18890. * @param value Define the value to give to the uniform
  18891. * @return the material itself allowing "fluent" like uniform updates
  18892. */
  18893. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  18894. /**
  18895. * Set a vec2 in the shader from a Vector2.
  18896. * @param name Define the name of the uniform as defined in the shader
  18897. * @param value Define the value to give to the uniform
  18898. * @return the material itself allowing "fluent" like uniform updates
  18899. */
  18900. setVector2(name: string, value: Vector2): ShaderMaterial;
  18901. /**
  18902. * Set a vec3 in the shader from a Vector3.
  18903. * @param name Define the name of the uniform as defined in the shader
  18904. * @param value Define the value to give to the uniform
  18905. * @return the material itself allowing "fluent" like uniform updates
  18906. */
  18907. setVector3(name: string, value: Vector3): ShaderMaterial;
  18908. /**
  18909. * Set a vec4 in the shader from a Vector4.
  18910. * @param name Define the name of the uniform as defined in the shader
  18911. * @param value Define the value to give to the uniform
  18912. * @return the material itself allowing "fluent" like uniform updates
  18913. */
  18914. setVector4(name: string, value: Vector4): ShaderMaterial;
  18915. /**
  18916. * Set a mat4 in the shader from a Matrix.
  18917. * @param name Define the name of the uniform as defined in the shader
  18918. * @param value Define the value to give to the uniform
  18919. * @return the material itself allowing "fluent" like uniform updates
  18920. */
  18921. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18922. /**
  18923. * Set a mat3 in the shader from a Float32Array.
  18924. * @param name Define the name of the uniform as defined in the shader
  18925. * @param value Define the value to give to the uniform
  18926. * @return the material itself allowing "fluent" like uniform updates
  18927. */
  18928. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18929. /**
  18930. * Set a mat2 in the shader from a Float32Array.
  18931. * @param name Define the name of the uniform as defined in the shader
  18932. * @param value Define the value to give to the uniform
  18933. * @return the material itself allowing "fluent" like uniform updates
  18934. */
  18935. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18936. /**
  18937. * Set a vec2 array in the shader from a number array.
  18938. * @param name Define the name of the uniform as defined in the shader
  18939. * @param value Define the value to give to the uniform
  18940. * @return the material itself allowing "fluent" like uniform updates
  18941. */
  18942. setArray2(name: string, value: number[]): ShaderMaterial;
  18943. /**
  18944. * Set a vec3 array in the shader from a number array.
  18945. * @param name Define the name of the uniform as defined in the shader
  18946. * @param value Define the value to give to the uniform
  18947. * @return the material itself allowing "fluent" like uniform updates
  18948. */
  18949. setArray3(name: string, value: number[]): ShaderMaterial;
  18950. /**
  18951. * Set a vec4 array in the shader from a number array.
  18952. * @param name Define the name of the uniform as defined in the shader
  18953. * @param value Define the value to give to the uniform
  18954. * @return the material itself allowing "fluent" like uniform updates
  18955. */
  18956. setArray4(name: string, value: number[]): ShaderMaterial;
  18957. private _checkCache;
  18958. /**
  18959. * Specifies that the submesh is ready to be used
  18960. * @param mesh defines the mesh to check
  18961. * @param subMesh defines which submesh to check
  18962. * @param useInstances specifies that instances should be used
  18963. * @returns a boolean indicating that the submesh is ready or not
  18964. */
  18965. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18966. /**
  18967. * Checks if the material is ready to render the requested mesh
  18968. * @param mesh Define the mesh to render
  18969. * @param useInstances Define whether or not the material is used with instances
  18970. * @returns true if ready, otherwise false
  18971. */
  18972. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18973. /**
  18974. * Binds the world matrix to the material
  18975. * @param world defines the world transformation matrix
  18976. */
  18977. bindOnlyWorldMatrix(world: Matrix): void;
  18978. /**
  18979. * Binds the material to the mesh
  18980. * @param world defines the world transformation matrix
  18981. * @param mesh defines the mesh to bind the material to
  18982. */
  18983. bind(world: Matrix, mesh?: Mesh): void;
  18984. /**
  18985. * Gets the active textures from the material
  18986. * @returns an array of textures
  18987. */
  18988. getActiveTextures(): BaseTexture[];
  18989. /**
  18990. * Specifies if the material uses a texture
  18991. * @param texture defines the texture to check against the material
  18992. * @returns a boolean specifying if the material uses the texture
  18993. */
  18994. hasTexture(texture: BaseTexture): boolean;
  18995. /**
  18996. * Makes a duplicate of the material, and gives it a new name
  18997. * @param name defines the new name for the duplicated material
  18998. * @returns the cloned material
  18999. */
  19000. clone(name: string): ShaderMaterial;
  19001. /**
  19002. * Disposes the material
  19003. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19004. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19005. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19006. */
  19007. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19008. /**
  19009. * Serializes this material in a JSON representation
  19010. * @returns the serialized material object
  19011. */
  19012. serialize(): any;
  19013. /**
  19014. * Creates a shader material from parsed shader material data
  19015. * @param source defines the JSON represnetation of the material
  19016. * @param scene defines the hosting scene
  19017. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19018. * @returns a new material
  19019. */
  19020. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19021. }
  19022. }
  19023. declare module BABYLON {
  19024. /** @hidden */
  19025. export var colorPixelShader: {
  19026. name: string;
  19027. shader: string;
  19028. };
  19029. }
  19030. declare module BABYLON {
  19031. /** @hidden */
  19032. export var colorVertexShader: {
  19033. name: string;
  19034. shader: string;
  19035. };
  19036. }
  19037. declare module BABYLON {
  19038. /**
  19039. * Line mesh
  19040. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19041. */
  19042. export class LinesMesh extends Mesh {
  19043. /**
  19044. * If vertex color should be applied to the mesh
  19045. */
  19046. readonly useVertexColor?: boolean | undefined;
  19047. /**
  19048. * If vertex alpha should be applied to the mesh
  19049. */
  19050. readonly useVertexAlpha?: boolean | undefined;
  19051. /**
  19052. * Color of the line (Default: White)
  19053. */
  19054. color: Color3;
  19055. /**
  19056. * Alpha of the line (Default: 1)
  19057. */
  19058. alpha: number;
  19059. /**
  19060. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19061. * This margin is expressed in world space coordinates, so its value may vary.
  19062. * Default value is 0.1
  19063. */
  19064. intersectionThreshold: number;
  19065. private _colorShader;
  19066. private color4;
  19067. /**
  19068. * Creates a new LinesMesh
  19069. * @param name defines the name
  19070. * @param scene defines the hosting scene
  19071. * @param parent defines the parent mesh if any
  19072. * @param source defines the optional source LinesMesh used to clone data from
  19073. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19074. * When false, achieved by calling a clone(), also passing False.
  19075. * This will make creation of children, recursive.
  19076. * @param useVertexColor defines if this LinesMesh supports vertex color
  19077. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19078. */
  19079. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19080. /**
  19081. * If vertex color should be applied to the mesh
  19082. */
  19083. useVertexColor?: boolean | undefined,
  19084. /**
  19085. * If vertex alpha should be applied to the mesh
  19086. */
  19087. useVertexAlpha?: boolean | undefined);
  19088. private _addClipPlaneDefine;
  19089. private _removeClipPlaneDefine;
  19090. isReady(): boolean;
  19091. /**
  19092. * Returns the string "LineMesh"
  19093. */
  19094. getClassName(): string;
  19095. /**
  19096. * @hidden
  19097. */
  19098. /**
  19099. * @hidden
  19100. */
  19101. material: Material;
  19102. /**
  19103. * @hidden
  19104. */
  19105. readonly checkCollisions: boolean;
  19106. /** @hidden */ private _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19107. /** @hidden */ private _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19108. /**
  19109. * Disposes of the line mesh
  19110. * @param doNotRecurse If children should be disposed
  19111. */
  19112. dispose(doNotRecurse?: boolean): void;
  19113. /**
  19114. * Returns a new LineMesh object cloned from the current one.
  19115. */
  19116. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19117. /**
  19118. * Creates a new InstancedLinesMesh object from the mesh model.
  19119. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19120. * @param name defines the name of the new instance
  19121. * @returns a new InstancedLinesMesh
  19122. */
  19123. createInstance(name: string): InstancedLinesMesh;
  19124. }
  19125. /**
  19126. * Creates an instance based on a source LinesMesh
  19127. */
  19128. export class InstancedLinesMesh extends InstancedMesh {
  19129. /**
  19130. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19131. * This margin is expressed in world space coordinates, so its value may vary.
  19132. * Initilized with the intersectionThreshold value of the source LinesMesh
  19133. */
  19134. intersectionThreshold: number;
  19135. constructor(name: string, source: LinesMesh);
  19136. /**
  19137. * Returns the string "InstancedLinesMesh".
  19138. */
  19139. getClassName(): string;
  19140. }
  19141. }
  19142. declare module BABYLON {
  19143. /** @hidden */
  19144. export var linePixelShader: {
  19145. name: string;
  19146. shader: string;
  19147. };
  19148. }
  19149. declare module BABYLON {
  19150. /** @hidden */
  19151. export var lineVertexShader: {
  19152. name: string;
  19153. shader: string;
  19154. };
  19155. }
  19156. declare module BABYLON {
  19157. interface AbstractMesh {
  19158. /**
  19159. * Gets the edgesRenderer associated with the mesh
  19160. */
  19161. edgesRenderer: Nullable<EdgesRenderer>;
  19162. }
  19163. interface LinesMesh {
  19164. /**
  19165. * Enables the edge rendering mode on the mesh.
  19166. * This mode makes the mesh edges visible
  19167. * @param epsilon defines the maximal distance between two angles to detect a face
  19168. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19169. * @returns the currentAbstractMesh
  19170. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19171. */
  19172. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19173. }
  19174. interface InstancedLinesMesh {
  19175. /**
  19176. * Enables the edge rendering mode on the mesh.
  19177. * This mode makes the mesh edges visible
  19178. * @param epsilon defines the maximal distance between two angles to detect a face
  19179. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19180. * @returns the current InstancedLinesMesh
  19181. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19182. */
  19183. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19184. }
  19185. /**
  19186. * Defines the minimum contract an Edges renderer should follow.
  19187. */
  19188. export interface IEdgesRenderer extends IDisposable {
  19189. /**
  19190. * Gets or sets a boolean indicating if the edgesRenderer is active
  19191. */
  19192. isEnabled: boolean;
  19193. /**
  19194. * Renders the edges of the attached mesh,
  19195. */
  19196. render(): void;
  19197. /**
  19198. * Checks wether or not the edges renderer is ready to render.
  19199. * @return true if ready, otherwise false.
  19200. */
  19201. isReady(): boolean;
  19202. }
  19203. /**
  19204. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19205. */
  19206. export class EdgesRenderer implements IEdgesRenderer {
  19207. /**
  19208. * Define the size of the edges with an orthographic camera
  19209. */
  19210. edgesWidthScalerForOrthographic: number;
  19211. /**
  19212. * Define the size of the edges with a perspective camera
  19213. */
  19214. edgesWidthScalerForPerspective: number;
  19215. protected _source: AbstractMesh;
  19216. protected _linesPositions: number[];
  19217. protected _linesNormals: number[];
  19218. protected _linesIndices: number[];
  19219. protected _epsilon: number;
  19220. protected _indicesCount: number;
  19221. protected _lineShader: ShaderMaterial;
  19222. protected _ib: DataBuffer;
  19223. protected _buffers: {
  19224. [key: string]: Nullable<VertexBuffer>;
  19225. };
  19226. protected _checkVerticesInsteadOfIndices: boolean;
  19227. private _meshRebuildObserver;
  19228. private _meshDisposeObserver;
  19229. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19230. isEnabled: boolean;
  19231. /**
  19232. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19233. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19234. * @param source Mesh used to create edges
  19235. * @param epsilon sum of angles in adjacency to check for edge
  19236. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19237. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19238. */
  19239. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19240. protected _prepareRessources(): void;
  19241. /** @hidden */ private _rebuild(): void;
  19242. /**
  19243. * Releases the required resources for the edges renderer
  19244. */
  19245. dispose(): void;
  19246. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19247. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19248. /**
  19249. * Checks if the pair of p0 and p1 is en edge
  19250. * @param faceIndex
  19251. * @param edge
  19252. * @param faceNormals
  19253. * @param p0
  19254. * @param p1
  19255. * @private
  19256. */
  19257. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19258. /**
  19259. * push line into the position, normal and index buffer
  19260. * @protected
  19261. */
  19262. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19263. /**
  19264. * Generates lines edges from adjacencjes
  19265. * @private
  19266. */ private _generateEdgesLines(): void;
  19267. /**
  19268. * Checks wether or not the edges renderer is ready to render.
  19269. * @return true if ready, otherwise false.
  19270. */
  19271. isReady(): boolean;
  19272. /**
  19273. * Renders the edges of the attached mesh,
  19274. */
  19275. render(): void;
  19276. }
  19277. /**
  19278. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19279. */
  19280. export class LineEdgesRenderer extends EdgesRenderer {
  19281. /**
  19282. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19283. * @param source LineMesh used to generate edges
  19284. * @param epsilon not important (specified angle for edge detection)
  19285. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19286. */
  19287. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19288. /**
  19289. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19290. */ private _generateEdgesLines(): void;
  19291. }
  19292. }
  19293. declare module BABYLON {
  19294. /**
  19295. * This represents the object necessary to create a rendering group.
  19296. * This is exclusively used and created by the rendering manager.
  19297. * To modify the behavior, you use the available helpers in your scene or meshes.
  19298. * @hidden
  19299. */
  19300. export class RenderingGroup {
  19301. index: number;
  19302. private static _zeroVector;
  19303. private _scene;
  19304. private _opaqueSubMeshes;
  19305. private _transparentSubMeshes;
  19306. private _alphaTestSubMeshes;
  19307. private _depthOnlySubMeshes;
  19308. private _particleSystems;
  19309. private _spriteManagers;
  19310. private _opaqueSortCompareFn;
  19311. private _alphaTestSortCompareFn;
  19312. private _transparentSortCompareFn;
  19313. private _renderOpaque;
  19314. private _renderAlphaTest;
  19315. private _renderTransparent;
  19316. /** @hidden */ private _edgesRenderers: SmartArray<IEdgesRenderer>;
  19317. onBeforeTransparentRendering: () => void;
  19318. /**
  19319. * Set the opaque sort comparison function.
  19320. * If null the sub meshes will be render in the order they were created
  19321. */
  19322. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19323. /**
  19324. * Set the alpha test sort comparison function.
  19325. * If null the sub meshes will be render in the order they were created
  19326. */
  19327. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19328. /**
  19329. * Set the transparent sort comparison function.
  19330. * If null the sub meshes will be render in the order they were created
  19331. */
  19332. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19333. /**
  19334. * Creates a new rendering group.
  19335. * @param index The rendering group index
  19336. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19337. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19338. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19339. */
  19340. 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>);
  19341. /**
  19342. * Render all the sub meshes contained in the group.
  19343. * @param customRenderFunction Used to override the default render behaviour of the group.
  19344. * @returns true if rendered some submeshes.
  19345. */
  19346. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19347. /**
  19348. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19349. * @param subMeshes The submeshes to render
  19350. */
  19351. private renderOpaqueSorted;
  19352. /**
  19353. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19354. * @param subMeshes The submeshes to render
  19355. */
  19356. private renderAlphaTestSorted;
  19357. /**
  19358. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19359. * @param subMeshes The submeshes to render
  19360. */
  19361. private renderTransparentSorted;
  19362. /**
  19363. * Renders the submeshes in a specified order.
  19364. * @param subMeshes The submeshes to sort before render
  19365. * @param sortCompareFn The comparison function use to sort
  19366. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19367. * @param transparent Specifies to activate blending if true
  19368. */
  19369. private static renderSorted;
  19370. /**
  19371. * Renders the submeshes in the order they were dispatched (no sort applied).
  19372. * @param subMeshes The submeshes to render
  19373. */
  19374. private static renderUnsorted;
  19375. /**
  19376. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19377. * are rendered back to front if in the same alpha index.
  19378. *
  19379. * @param a The first submesh
  19380. * @param b The second submesh
  19381. * @returns The result of the comparison
  19382. */
  19383. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19384. /**
  19385. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19386. * are rendered back to front.
  19387. *
  19388. * @param a The first submesh
  19389. * @param b The second submesh
  19390. * @returns The result of the comparison
  19391. */
  19392. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19393. /**
  19394. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19395. * are rendered front to back (prevent overdraw).
  19396. *
  19397. * @param a The first submesh
  19398. * @param b The second submesh
  19399. * @returns The result of the comparison
  19400. */
  19401. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19402. /**
  19403. * Resets the different lists of submeshes to prepare a new frame.
  19404. */
  19405. prepare(): void;
  19406. dispose(): void;
  19407. /**
  19408. * Inserts the submesh in its correct queue depending on its material.
  19409. * @param subMesh The submesh to dispatch
  19410. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19411. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19412. */
  19413. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19414. dispatchSprites(spriteManager: ISpriteManager): void;
  19415. dispatchParticles(particleSystem: IParticleSystem): void;
  19416. private _renderParticles;
  19417. private _renderSprites;
  19418. }
  19419. }
  19420. declare module BABYLON {
  19421. /**
  19422. * Interface describing the different options available in the rendering manager
  19423. * regarding Auto Clear between groups.
  19424. */
  19425. export interface IRenderingManagerAutoClearSetup {
  19426. /**
  19427. * Defines whether or not autoclear is enable.
  19428. */
  19429. autoClear: boolean;
  19430. /**
  19431. * Defines whether or not to autoclear the depth buffer.
  19432. */
  19433. depth: boolean;
  19434. /**
  19435. * Defines whether or not to autoclear the stencil buffer.
  19436. */
  19437. stencil: boolean;
  19438. }
  19439. /**
  19440. * This class is used by the onRenderingGroupObservable
  19441. */
  19442. export class RenderingGroupInfo {
  19443. /**
  19444. * The Scene that being rendered
  19445. */
  19446. scene: Scene;
  19447. /**
  19448. * The camera currently used for the rendering pass
  19449. */
  19450. camera: Nullable<Camera>;
  19451. /**
  19452. * The ID of the renderingGroup being processed
  19453. */
  19454. renderingGroupId: number;
  19455. }
  19456. /**
  19457. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19458. * It is enable to manage the different groups as well as the different necessary sort functions.
  19459. * This should not be used directly aside of the few static configurations
  19460. */
  19461. export class RenderingManager {
  19462. /**
  19463. * The max id used for rendering groups (not included)
  19464. */
  19465. static MAX_RENDERINGGROUPS: number;
  19466. /**
  19467. * The min id used for rendering groups (included)
  19468. */
  19469. static MIN_RENDERINGGROUPS: number;
  19470. /**
  19471. * Used to globally prevent autoclearing scenes.
  19472. */
  19473. static AUTOCLEAR: boolean;
  19474. /**
  19475. * @hidden
  19476. */ private _useSceneAutoClearSetup: boolean;
  19477. private _scene;
  19478. private _renderingGroups;
  19479. private _depthStencilBufferAlreadyCleaned;
  19480. private _autoClearDepthStencil;
  19481. private _customOpaqueSortCompareFn;
  19482. private _customAlphaTestSortCompareFn;
  19483. private _customTransparentSortCompareFn;
  19484. private _renderingGroupInfo;
  19485. /**
  19486. * Instantiates a new rendering group for a particular scene
  19487. * @param scene Defines the scene the groups belongs to
  19488. */
  19489. constructor(scene: Scene);
  19490. private _clearDepthStencilBuffer;
  19491. /**
  19492. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19493. * @hidden
  19494. */
  19495. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19496. /**
  19497. * Resets the different information of the group to prepare a new frame
  19498. * @hidden
  19499. */
  19500. reset(): void;
  19501. /**
  19502. * Dispose and release the group and its associated resources.
  19503. * @hidden
  19504. */
  19505. dispose(): void;
  19506. /**
  19507. * Clear the info related to rendering groups preventing retention points during dispose.
  19508. */
  19509. freeRenderingGroups(): void;
  19510. private _prepareRenderingGroup;
  19511. /**
  19512. * Add a sprite manager to the rendering manager in order to render it this frame.
  19513. * @param spriteManager Define the sprite manager to render
  19514. */
  19515. dispatchSprites(spriteManager: ISpriteManager): void;
  19516. /**
  19517. * Add a particle system to the rendering manager in order to render it this frame.
  19518. * @param particleSystem Define the particle system to render
  19519. */
  19520. dispatchParticles(particleSystem: IParticleSystem): void;
  19521. /**
  19522. * Add a submesh to the manager in order to render it this frame
  19523. * @param subMesh The submesh to dispatch
  19524. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19525. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19526. */
  19527. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19528. /**
  19529. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19530. * This allowed control for front to back rendering or reversly depending of the special needs.
  19531. *
  19532. * @param renderingGroupId The rendering group id corresponding to its index
  19533. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19534. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19535. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19536. */
  19537. 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;
  19538. /**
  19539. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19540. *
  19541. * @param renderingGroupId The rendering group id corresponding to its index
  19542. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19543. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19544. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19545. */
  19546. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19547. /**
  19548. * Gets the current auto clear configuration for one rendering group of the rendering
  19549. * manager.
  19550. * @param index the rendering group index to get the information for
  19551. * @returns The auto clear setup for the requested rendering group
  19552. */
  19553. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19554. }
  19555. }
  19556. declare module BABYLON {
  19557. /**
  19558. * This Helps creating a texture that will be created from a camera in your scene.
  19559. * It is basically a dynamic texture that could be used to create special effects for instance.
  19560. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19561. */
  19562. export class RenderTargetTexture extends Texture {
  19563. isCube: boolean;
  19564. /**
  19565. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19566. */
  19567. static readonly REFRESHRATE_RENDER_ONCE: number;
  19568. /**
  19569. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19570. */
  19571. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19572. /**
  19573. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19574. * the central point of your effect and can save a lot of performances.
  19575. */
  19576. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19577. /**
  19578. * Use this predicate to dynamically define the list of mesh you want to render.
  19579. * If set, the renderList property will be overwritten.
  19580. */
  19581. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19582. private _renderList;
  19583. /**
  19584. * Use this list to define the list of mesh you want to render.
  19585. */
  19586. renderList: Nullable<Array<AbstractMesh>>;
  19587. private _hookArray;
  19588. /**
  19589. * Define if particles should be rendered in your texture.
  19590. */
  19591. renderParticles: boolean;
  19592. /**
  19593. * Define if sprites should be rendered in your texture.
  19594. */
  19595. renderSprites: boolean;
  19596. /**
  19597. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19598. */
  19599. coordinatesMode: number;
  19600. /**
  19601. * Define the camera used to render the texture.
  19602. */
  19603. activeCamera: Nullable<Camera>;
  19604. /**
  19605. * Override the render function of the texture with your own one.
  19606. */
  19607. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19608. /**
  19609. * Define if camera post processes should be use while rendering the texture.
  19610. */
  19611. useCameraPostProcesses: boolean;
  19612. /**
  19613. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19614. */
  19615. ignoreCameraViewport: boolean;
  19616. private _postProcessManager;
  19617. private _postProcesses;
  19618. private _resizeObserver;
  19619. /**
  19620. * An event triggered when the texture is unbind.
  19621. */
  19622. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19623. /**
  19624. * An event triggered when the texture is unbind.
  19625. */
  19626. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19627. private _onAfterUnbindObserver;
  19628. /**
  19629. * Set a after unbind callback in the texture.
  19630. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19631. */
  19632. onAfterUnbind: () => void;
  19633. /**
  19634. * An event triggered before rendering the texture
  19635. */
  19636. onBeforeRenderObservable: Observable<number>;
  19637. private _onBeforeRenderObserver;
  19638. /**
  19639. * Set a before render callback in the texture.
  19640. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19641. */
  19642. onBeforeRender: (faceIndex: number) => void;
  19643. /**
  19644. * An event triggered after rendering the texture
  19645. */
  19646. onAfterRenderObservable: Observable<number>;
  19647. private _onAfterRenderObserver;
  19648. /**
  19649. * Set a after render callback in the texture.
  19650. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19651. */
  19652. onAfterRender: (faceIndex: number) => void;
  19653. /**
  19654. * An event triggered after the texture clear
  19655. */
  19656. onClearObservable: Observable<Engine>;
  19657. private _onClearObserver;
  19658. /**
  19659. * Set a clear callback in the texture.
  19660. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19661. */
  19662. onClear: (Engine: Engine) => void;
  19663. /**
  19664. * An event triggered when the texture is resized.
  19665. */
  19666. onResizeObservable: Observable<RenderTargetTexture>;
  19667. /**
  19668. * Define the clear color of the Render Target if it should be different from the scene.
  19669. */
  19670. clearColor: Color4;
  19671. protected _size: number | {
  19672. width: number;
  19673. height: number;
  19674. };
  19675. protected _initialSizeParameter: number | {
  19676. width: number;
  19677. height: number;
  19678. } | {
  19679. ratio: number;
  19680. };
  19681. protected _sizeRatio: Nullable<number>;
  19682. /** @hidden */ private _generateMipMaps: boolean;
  19683. protected _renderingManager: RenderingManager;
  19684. /** @hidden */ private _waitingRenderList: string[];
  19685. protected _doNotChangeAspectRatio: boolean;
  19686. protected _currentRefreshId: number;
  19687. protected _refreshRate: number;
  19688. protected _textureMatrix: Matrix;
  19689. protected _samples: number;
  19690. protected _renderTargetOptions: RenderTargetCreationOptions;
  19691. /**
  19692. * Gets render target creation options that were used.
  19693. */
  19694. readonly renderTargetOptions: RenderTargetCreationOptions;
  19695. protected _engine: Engine;
  19696. protected _onRatioRescale(): void;
  19697. /**
  19698. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  19699. * It must define where the camera used to render the texture is set
  19700. */
  19701. boundingBoxPosition: Vector3;
  19702. private _boundingBoxSize;
  19703. /**
  19704. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  19705. * When defined, the cubemap will switch to local mode
  19706. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  19707. * @example https://www.babylonjs-playground.com/#RNASML
  19708. */
  19709. boundingBoxSize: Vector3;
  19710. /**
  19711. * In case the RTT has been created with a depth texture, get the associated
  19712. * depth texture.
  19713. * Otherwise, return null.
  19714. */
  19715. depthStencilTexture: Nullable<InternalTexture>;
  19716. /**
  19717. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  19718. * or used a shadow, depth texture...
  19719. * @param name The friendly name of the texture
  19720. * @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)
  19721. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  19722. * @param generateMipMaps True if mip maps need to be generated after render.
  19723. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  19724. * @param type The type of the buffer in the RTT (int, half float, float...)
  19725. * @param isCube True if a cube texture needs to be created
  19726. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  19727. * @param generateDepthBuffer True to generate a depth buffer
  19728. * @param generateStencilBuffer True to generate a stencil buffer
  19729. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  19730. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  19731. * @param delayAllocation if the texture allocation should be delayed (default: false)
  19732. */
  19733. constructor(name: string, size: number | {
  19734. width: number;
  19735. height: number;
  19736. } | {
  19737. ratio: number;
  19738. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  19739. /**
  19740. * Creates a depth stencil texture.
  19741. * This is only available in WebGL 2 or with the depth texture extension available.
  19742. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  19743. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  19744. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  19745. */
  19746. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  19747. private _processSizeParameter;
  19748. /**
  19749. * Define the number of samples to use in case of MSAA.
  19750. * It defaults to one meaning no MSAA has been enabled.
  19751. */
  19752. samples: number;
  19753. /**
  19754. * Resets the refresh counter of the texture and start bak from scratch.
  19755. * Could be useful to regenerate the texture if it is setup to render only once.
  19756. */
  19757. resetRefreshCounter(): void;
  19758. /**
  19759. * Define the refresh rate of the texture or the rendering frequency.
  19760. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19761. */
  19762. refreshRate: number;
  19763. /**
  19764. * Adds a post process to the render target rendering passes.
  19765. * @param postProcess define the post process to add
  19766. */
  19767. addPostProcess(postProcess: PostProcess): void;
  19768. /**
  19769. * Clear all the post processes attached to the render target
  19770. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  19771. */
  19772. clearPostProcesses(dispose?: boolean): void;
  19773. /**
  19774. * Remove one of the post process from the list of attached post processes to the texture
  19775. * @param postProcess define the post process to remove from the list
  19776. */
  19777. removePostProcess(postProcess: PostProcess): void;
  19778. /** @hidden */ private _shouldRender(): boolean;
  19779. /**
  19780. * Gets the actual render size of the texture.
  19781. * @returns the width of the render size
  19782. */
  19783. getRenderSize(): number;
  19784. /**
  19785. * Gets the actual render width of the texture.
  19786. * @returns the width of the render size
  19787. */
  19788. getRenderWidth(): number;
  19789. /**
  19790. * Gets the actual render height of the texture.
  19791. * @returns the height of the render size
  19792. */
  19793. getRenderHeight(): number;
  19794. /**
  19795. * Get if the texture can be rescaled or not.
  19796. */
  19797. readonly canRescale: boolean;
  19798. /**
  19799. * Resize the texture using a ratio.
  19800. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  19801. */
  19802. scale(ratio: number): void;
  19803. /**
  19804. * Get the texture reflection matrix used to rotate/transform the reflection.
  19805. * @returns the reflection matrix
  19806. */
  19807. getReflectionTextureMatrix(): Matrix;
  19808. /**
  19809. * Resize the texture to a new desired size.
  19810. * Be carrefull as it will recreate all the data in the new texture.
  19811. * @param size Define the new size. It can be:
  19812. * - a number for squared texture,
  19813. * - an object containing { width: number, height: number }
  19814. * - or an object containing a ratio { ratio: number }
  19815. */
  19816. resize(size: number | {
  19817. width: number;
  19818. height: number;
  19819. } | {
  19820. ratio: number;
  19821. }): void;
  19822. /**
  19823. * Renders all the objects from the render list into the texture.
  19824. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  19825. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  19826. */
  19827. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  19828. private _bestReflectionRenderTargetDimension;
  19829. /**
  19830. * @hidden
  19831. * @param faceIndex face index to bind to if this is a cubetexture
  19832. */ private _bindFrameBuffer(faceIndex?: number): void;
  19833. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  19834. private renderToTarget;
  19835. /**
  19836. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19837. * This allowed control for front to back rendering or reversly depending of the special needs.
  19838. *
  19839. * @param renderingGroupId The rendering group id corresponding to its index
  19840. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19841. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19842. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19843. */
  19844. 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;
  19845. /**
  19846. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19847. *
  19848. * @param renderingGroupId The rendering group id corresponding to its index
  19849. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19850. */
  19851. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  19852. /**
  19853. * Clones the texture.
  19854. * @returns the cloned texture
  19855. */
  19856. clone(): RenderTargetTexture;
  19857. /**
  19858. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  19859. * @returns The JSON representation of the texture
  19860. */
  19861. serialize(): any;
  19862. /**
  19863. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  19864. */
  19865. disposeFramebufferObjects(): void;
  19866. /**
  19867. * Dispose the texture and release its associated resources.
  19868. */
  19869. dispose(): void;
  19870. /** @hidden */ private _rebuild(): void;
  19871. /**
  19872. * Clear the info related to rendering groups preventing retention point in material dispose.
  19873. */
  19874. freeRenderingGroups(): void;
  19875. /**
  19876. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19877. * @returns the view count
  19878. */
  19879. getViewCount(): number;
  19880. }
  19881. }
  19882. declare module BABYLON {
  19883. /**
  19884. * Options for compiling materials.
  19885. */
  19886. export interface IMaterialCompilationOptions {
  19887. /**
  19888. * Defines whether clip planes are enabled.
  19889. */
  19890. clipPlane: boolean;
  19891. /**
  19892. * Defines whether instances are enabled.
  19893. */
  19894. useInstances: boolean;
  19895. }
  19896. /**
  19897. * Base class for the main features of a material in Babylon.js
  19898. */
  19899. export class Material implements IAnimatable {
  19900. /**
  19901. * Returns the triangle fill mode
  19902. */
  19903. static readonly TriangleFillMode: number;
  19904. /**
  19905. * Returns the wireframe mode
  19906. */
  19907. static readonly WireFrameFillMode: number;
  19908. /**
  19909. * Returns the point fill mode
  19910. */
  19911. static readonly PointFillMode: number;
  19912. /**
  19913. * Returns the point list draw mode
  19914. */
  19915. static readonly PointListDrawMode: number;
  19916. /**
  19917. * Returns the line list draw mode
  19918. */
  19919. static readonly LineListDrawMode: number;
  19920. /**
  19921. * Returns the line loop draw mode
  19922. */
  19923. static readonly LineLoopDrawMode: number;
  19924. /**
  19925. * Returns the line strip draw mode
  19926. */
  19927. static readonly LineStripDrawMode: number;
  19928. /**
  19929. * Returns the triangle strip draw mode
  19930. */
  19931. static readonly TriangleStripDrawMode: number;
  19932. /**
  19933. * Returns the triangle fan draw mode
  19934. */
  19935. static readonly TriangleFanDrawMode: number;
  19936. /**
  19937. * Stores the clock-wise side orientation
  19938. */
  19939. static readonly ClockWiseSideOrientation: number;
  19940. /**
  19941. * Stores the counter clock-wise side orientation
  19942. */
  19943. static readonly CounterClockWiseSideOrientation: number;
  19944. /**
  19945. * The dirty texture flag value
  19946. */
  19947. static readonly TextureDirtyFlag: number;
  19948. /**
  19949. * The dirty light flag value
  19950. */
  19951. static readonly LightDirtyFlag: number;
  19952. /**
  19953. * The dirty fresnel flag value
  19954. */
  19955. static readonly FresnelDirtyFlag: number;
  19956. /**
  19957. * The dirty attribute flag value
  19958. */
  19959. static readonly AttributesDirtyFlag: number;
  19960. /**
  19961. * The dirty misc flag value
  19962. */
  19963. static readonly MiscDirtyFlag: number;
  19964. /**
  19965. * The all dirty flag value
  19966. */
  19967. static readonly AllDirtyFlag: number;
  19968. /**
  19969. * The ID of the material
  19970. */
  19971. id: string;
  19972. /**
  19973. * Gets or sets the unique id of the material
  19974. */
  19975. uniqueId: number;
  19976. /**
  19977. * The name of the material
  19978. */
  19979. name: string;
  19980. /**
  19981. * Gets or sets user defined metadata
  19982. */
  19983. metadata: any;
  19984. /**
  19985. * For internal use only. Please do not use.
  19986. */
  19987. reservedDataStore: any;
  19988. /**
  19989. * Specifies if the ready state should be checked on each call
  19990. */
  19991. checkReadyOnEveryCall: boolean;
  19992. /**
  19993. * Specifies if the ready state should be checked once
  19994. */
  19995. checkReadyOnlyOnce: boolean;
  19996. /**
  19997. * The state of the material
  19998. */
  19999. state: string;
  20000. /**
  20001. * The alpha value of the material
  20002. */
  20003. protected _alpha: number;
  20004. /**
  20005. * List of inspectable custom properties (used by the Inspector)
  20006. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20007. */
  20008. inspectableCustomProperties: IInspectable[];
  20009. /**
  20010. * Sets the alpha value of the material
  20011. */
  20012. /**
  20013. * Gets the alpha value of the material
  20014. */
  20015. alpha: number;
  20016. /**
  20017. * Specifies if back face culling is enabled
  20018. */
  20019. protected _backFaceCulling: boolean;
  20020. /**
  20021. * Sets the back-face culling state
  20022. */
  20023. /**
  20024. * Gets the back-face culling state
  20025. */
  20026. backFaceCulling: boolean;
  20027. /**
  20028. * Stores the value for side orientation
  20029. */
  20030. sideOrientation: number;
  20031. /**
  20032. * Callback triggered when the material is compiled
  20033. */
  20034. onCompiled: Nullable<(effect: Effect) => void>;
  20035. /**
  20036. * Callback triggered when an error occurs
  20037. */
  20038. onError: Nullable<(effect: Effect, errors: string) => void>;
  20039. /**
  20040. * Callback triggered to get the render target textures
  20041. */
  20042. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20043. /**
  20044. * Gets a boolean indicating that current material needs to register RTT
  20045. */
  20046. readonly hasRenderTargetTextures: boolean;
  20047. /**
  20048. * Specifies if the material should be serialized
  20049. */
  20050. doNotSerialize: boolean;
  20051. /**
  20052. * @hidden
  20053. */ private _storeEffectOnSubMeshes: boolean;
  20054. /**
  20055. * Stores the animations for the material
  20056. */
  20057. animations: Nullable<Array<Animation>>;
  20058. /**
  20059. * An event triggered when the material is disposed
  20060. */
  20061. onDisposeObservable: Observable<Material>;
  20062. /**
  20063. * An observer which watches for dispose events
  20064. */
  20065. private _onDisposeObserver;
  20066. private _onUnBindObservable;
  20067. /**
  20068. * Called during a dispose event
  20069. */
  20070. onDispose: () => void;
  20071. private _onBindObservable;
  20072. /**
  20073. * An event triggered when the material is bound
  20074. */
  20075. readonly onBindObservable: Observable<AbstractMesh>;
  20076. /**
  20077. * An observer which watches for bind events
  20078. */
  20079. private _onBindObserver;
  20080. /**
  20081. * Called during a bind event
  20082. */
  20083. onBind: (Mesh: AbstractMesh) => void;
  20084. /**
  20085. * An event triggered when the material is unbound
  20086. */
  20087. readonly onUnBindObservable: Observable<Material>;
  20088. /**
  20089. * Stores the value of the alpha mode
  20090. */
  20091. private _alphaMode;
  20092. /**
  20093. * Sets the value of the alpha mode.
  20094. *
  20095. * | Value | Type | Description |
  20096. * | --- | --- | --- |
  20097. * | 0 | ALPHA_DISABLE | |
  20098. * | 1 | ALPHA_ADD | |
  20099. * | 2 | ALPHA_COMBINE | |
  20100. * | 3 | ALPHA_SUBTRACT | |
  20101. * | 4 | ALPHA_MULTIPLY | |
  20102. * | 5 | ALPHA_MAXIMIZED | |
  20103. * | 6 | ALPHA_ONEONE | |
  20104. * | 7 | ALPHA_PREMULTIPLIED | |
  20105. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20106. * | 9 | ALPHA_INTERPOLATE | |
  20107. * | 10 | ALPHA_SCREENMODE | |
  20108. *
  20109. */
  20110. /**
  20111. * Gets the value of the alpha mode
  20112. */
  20113. alphaMode: number;
  20114. /**
  20115. * Stores the state of the need depth pre-pass value
  20116. */
  20117. private _needDepthPrePass;
  20118. /**
  20119. * Sets the need depth pre-pass value
  20120. */
  20121. /**
  20122. * Gets the depth pre-pass value
  20123. */
  20124. needDepthPrePass: boolean;
  20125. /**
  20126. * Specifies if depth writing should be disabled
  20127. */
  20128. disableDepthWrite: boolean;
  20129. /**
  20130. * Specifies if depth writing should be forced
  20131. */
  20132. forceDepthWrite: boolean;
  20133. /**
  20134. * Specifies if there should be a separate pass for culling
  20135. */
  20136. separateCullingPass: boolean;
  20137. /**
  20138. * Stores the state specifing if fog should be enabled
  20139. */
  20140. private _fogEnabled;
  20141. /**
  20142. * Sets the state for enabling fog
  20143. */
  20144. /**
  20145. * Gets the value of the fog enabled state
  20146. */
  20147. fogEnabled: boolean;
  20148. /**
  20149. * Stores the size of points
  20150. */
  20151. pointSize: number;
  20152. /**
  20153. * Stores the z offset value
  20154. */
  20155. zOffset: number;
  20156. /**
  20157. * Gets a value specifying if wireframe mode is enabled
  20158. */
  20159. /**
  20160. * Sets the state of wireframe mode
  20161. */
  20162. wireframe: boolean;
  20163. /**
  20164. * Gets the value specifying if point clouds are enabled
  20165. */
  20166. /**
  20167. * Sets the state of point cloud mode
  20168. */
  20169. pointsCloud: boolean;
  20170. /**
  20171. * Gets the material fill mode
  20172. */
  20173. /**
  20174. * Sets the material fill mode
  20175. */
  20176. fillMode: number;
  20177. /**
  20178. * @hidden
  20179. * Stores the effects for the material
  20180. */ private _effect: Nullable<Effect>;
  20181. /**
  20182. * @hidden
  20183. * Specifies if the material was previously ready
  20184. */ private _wasPreviouslyReady: boolean;
  20185. /**
  20186. * Specifies if uniform buffers should be used
  20187. */
  20188. private _useUBO;
  20189. /**
  20190. * Stores a reference to the scene
  20191. */
  20192. private _scene;
  20193. /**
  20194. * Stores the fill mode state
  20195. */
  20196. private _fillMode;
  20197. /**
  20198. * Specifies if the depth write state should be cached
  20199. */
  20200. private _cachedDepthWriteState;
  20201. /**
  20202. * Stores the uniform buffer
  20203. */
  20204. protected _uniformBuffer: UniformBuffer;
  20205. /** @hidden */ private _indexInSceneMaterialArray: number;
  20206. /** @hidden */
  20207. meshMap: Nullable<{
  20208. [id: string]: AbstractMesh | undefined;
  20209. }>;
  20210. /**
  20211. * Creates a material instance
  20212. * @param name defines the name of the material
  20213. * @param scene defines the scene to reference
  20214. * @param doNotAdd specifies if the material should be added to the scene
  20215. */
  20216. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20217. /**
  20218. * Returns a string representation of the current material
  20219. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20220. * @returns a string with material information
  20221. */
  20222. toString(fullDetails?: boolean): string;
  20223. /**
  20224. * Gets the class name of the material
  20225. * @returns a string with the class name of the material
  20226. */
  20227. getClassName(): string;
  20228. /**
  20229. * Specifies if updates for the material been locked
  20230. */
  20231. readonly isFrozen: boolean;
  20232. /**
  20233. * Locks updates for the material
  20234. */
  20235. freeze(): void;
  20236. /**
  20237. * Unlocks updates for the material
  20238. */
  20239. unfreeze(): void;
  20240. /**
  20241. * Specifies if the material is ready to be used
  20242. * @param mesh defines the mesh to check
  20243. * @param useInstances specifies if instances should be used
  20244. * @returns a boolean indicating if the material is ready to be used
  20245. */
  20246. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20247. /**
  20248. * Specifies that the submesh is ready to be used
  20249. * @param mesh defines the mesh to check
  20250. * @param subMesh defines which submesh to check
  20251. * @param useInstances specifies that instances should be used
  20252. * @returns a boolean indicating that the submesh is ready or not
  20253. */
  20254. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20255. /**
  20256. * Returns the material effect
  20257. * @returns the effect associated with the material
  20258. */
  20259. getEffect(): Nullable<Effect>;
  20260. /**
  20261. * Returns the current scene
  20262. * @returns a Scene
  20263. */
  20264. getScene(): Scene;
  20265. /**
  20266. * Specifies if the material will require alpha blending
  20267. * @returns a boolean specifying if alpha blending is needed
  20268. */
  20269. needAlphaBlending(): boolean;
  20270. /**
  20271. * Specifies if the mesh will require alpha blending
  20272. * @param mesh defines the mesh to check
  20273. * @returns a boolean specifying if alpha blending is needed for the mesh
  20274. */
  20275. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20276. /**
  20277. * Specifies if this material should be rendered in alpha test mode
  20278. * @returns a boolean specifying if an alpha test is needed.
  20279. */
  20280. needAlphaTesting(): boolean;
  20281. /**
  20282. * Gets the texture used for the alpha test
  20283. * @returns the texture to use for alpha testing
  20284. */
  20285. getAlphaTestTexture(): Nullable<BaseTexture>;
  20286. /**
  20287. * Marks the material to indicate that it needs to be re-calculated
  20288. */
  20289. markDirty(): void;
  20290. /** @hidden */ private _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20291. /**
  20292. * Binds the material to the mesh
  20293. * @param world defines the world transformation matrix
  20294. * @param mesh defines the mesh to bind the material to
  20295. */
  20296. bind(world: Matrix, mesh?: Mesh): void;
  20297. /**
  20298. * Binds the submesh to the material
  20299. * @param world defines the world transformation matrix
  20300. * @param mesh defines the mesh containing the submesh
  20301. * @param subMesh defines the submesh to bind the material to
  20302. */
  20303. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20304. /**
  20305. * Binds the world matrix to the material
  20306. * @param world defines the world transformation matrix
  20307. */
  20308. bindOnlyWorldMatrix(world: Matrix): void;
  20309. /**
  20310. * Binds the scene's uniform buffer to the effect.
  20311. * @param effect defines the effect to bind to the scene uniform buffer
  20312. * @param sceneUbo defines the uniform buffer storing scene data
  20313. */
  20314. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20315. /**
  20316. * Binds the view matrix to the effect
  20317. * @param effect defines the effect to bind the view matrix to
  20318. */
  20319. bindView(effect: Effect): void;
  20320. /**
  20321. * Binds the view projection matrix to the effect
  20322. * @param effect defines the effect to bind the view projection matrix to
  20323. */
  20324. bindViewProjection(effect: Effect): void;
  20325. /**
  20326. * Specifies if material alpha testing should be turned on for the mesh
  20327. * @param mesh defines the mesh to check
  20328. */
  20329. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20330. /**
  20331. * Processes to execute after binding the material to a mesh
  20332. * @param mesh defines the rendered mesh
  20333. */
  20334. protected _afterBind(mesh?: Mesh): void;
  20335. /**
  20336. * Unbinds the material from the mesh
  20337. */
  20338. unbind(): void;
  20339. /**
  20340. * Gets the active textures from the material
  20341. * @returns an array of textures
  20342. */
  20343. getActiveTextures(): BaseTexture[];
  20344. /**
  20345. * Specifies if the material uses a texture
  20346. * @param texture defines the texture to check against the material
  20347. * @returns a boolean specifying if the material uses the texture
  20348. */
  20349. hasTexture(texture: BaseTexture): boolean;
  20350. /**
  20351. * Makes a duplicate of the material, and gives it a new name
  20352. * @param name defines the new name for the duplicated material
  20353. * @returns the cloned material
  20354. */
  20355. clone(name: string): Nullable<Material>;
  20356. /**
  20357. * Gets the meshes bound to the material
  20358. * @returns an array of meshes bound to the material
  20359. */
  20360. getBindedMeshes(): AbstractMesh[];
  20361. /**
  20362. * Force shader compilation
  20363. * @param mesh defines the mesh associated with this material
  20364. * @param onCompiled defines a function to execute once the material is compiled
  20365. * @param options defines the options to configure the compilation
  20366. * @param onError defines a function to execute if the material fails compiling
  20367. */
  20368. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  20369. /**
  20370. * Force shader compilation
  20371. * @param mesh defines the mesh that will use this material
  20372. * @param options defines additional options for compiling the shaders
  20373. * @returns a promise that resolves when the compilation completes
  20374. */
  20375. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  20376. private static readonly _AllDirtyCallBack;
  20377. private static readonly _ImageProcessingDirtyCallBack;
  20378. private static readonly _TextureDirtyCallBack;
  20379. private static readonly _FresnelDirtyCallBack;
  20380. private static readonly _MiscDirtyCallBack;
  20381. private static readonly _LightsDirtyCallBack;
  20382. private static readonly _AttributeDirtyCallBack;
  20383. private static _FresnelAndMiscDirtyCallBack;
  20384. private static _TextureAndMiscDirtyCallBack;
  20385. private static readonly _DirtyCallbackArray;
  20386. private static readonly _RunDirtyCallBacks;
  20387. /**
  20388. * Marks a define in the material to indicate that it needs to be re-computed
  20389. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20390. */
  20391. markAsDirty(flag: number): void;
  20392. /**
  20393. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20394. * @param func defines a function which checks material defines against the submeshes
  20395. */
  20396. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20397. /**
  20398. * Indicates that we need to re-calculated for all submeshes
  20399. */
  20400. protected _markAllSubMeshesAsAllDirty(): void;
  20401. /**
  20402. * Indicates that image processing needs to be re-calculated for all submeshes
  20403. */
  20404. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20405. /**
  20406. * Indicates that textures need to be re-calculated for all submeshes
  20407. */
  20408. protected _markAllSubMeshesAsTexturesDirty(): void;
  20409. /**
  20410. * Indicates that fresnel needs to be re-calculated for all submeshes
  20411. */
  20412. protected _markAllSubMeshesAsFresnelDirty(): void;
  20413. /**
  20414. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20415. */
  20416. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20417. /**
  20418. * Indicates that lights need to be re-calculated for all submeshes
  20419. */
  20420. protected _markAllSubMeshesAsLightsDirty(): void;
  20421. /**
  20422. * Indicates that attributes need to be re-calculated for all submeshes
  20423. */
  20424. protected _markAllSubMeshesAsAttributesDirty(): void;
  20425. /**
  20426. * Indicates that misc needs to be re-calculated for all submeshes
  20427. */
  20428. protected _markAllSubMeshesAsMiscDirty(): void;
  20429. /**
  20430. * Indicates that textures and misc need to be re-calculated for all submeshes
  20431. */
  20432. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20433. /**
  20434. * Disposes the material
  20435. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20436. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20437. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20438. */
  20439. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20440. /** @hidden */
  20441. private releaseVertexArrayObject;
  20442. /**
  20443. * Serializes this material
  20444. * @returns the serialized material object
  20445. */
  20446. serialize(): any;
  20447. /**
  20448. * Creates a material from parsed material data
  20449. * @param parsedMaterial defines parsed material data
  20450. * @param scene defines the hosting scene
  20451. * @param rootUrl defines the root URL to use to load textures
  20452. * @returns a new material
  20453. */
  20454. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20455. }
  20456. }
  20457. declare module BABYLON {
  20458. /**
  20459. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20460. * separate meshes. This can be use to improve performances.
  20461. * @see http://doc.babylonjs.com/how_to/multi_materials
  20462. */
  20463. export class MultiMaterial extends Material {
  20464. private _subMaterials;
  20465. /**
  20466. * Gets or Sets the list of Materials used within the multi material.
  20467. * They need to be ordered according to the submeshes order in the associated mesh
  20468. */
  20469. subMaterials: Nullable<Material>[];
  20470. /**
  20471. * Function used to align with Node.getChildren()
  20472. * @returns the list of Materials used within the multi material
  20473. */
  20474. getChildren(): Nullable<Material>[];
  20475. /**
  20476. * Instantiates a new Multi Material
  20477. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20478. * separate meshes. This can be use to improve performances.
  20479. * @see http://doc.babylonjs.com/how_to/multi_materials
  20480. * @param name Define the name in the scene
  20481. * @param scene Define the scene the material belongs to
  20482. */
  20483. constructor(name: string, scene: Scene);
  20484. private _hookArray;
  20485. /**
  20486. * Get one of the submaterial by its index in the submaterials array
  20487. * @param index The index to look the sub material at
  20488. * @returns The Material if the index has been defined
  20489. */
  20490. getSubMaterial(index: number): Nullable<Material>;
  20491. /**
  20492. * Get the list of active textures for the whole sub materials list.
  20493. * @returns All the textures that will be used during the rendering
  20494. */
  20495. getActiveTextures(): BaseTexture[];
  20496. /**
  20497. * Gets the current class name of the material e.g. "MultiMaterial"
  20498. * Mainly use in serialization.
  20499. * @returns the class name
  20500. */
  20501. getClassName(): string;
  20502. /**
  20503. * Checks if the material is ready to render the requested sub mesh
  20504. * @param mesh Define the mesh the submesh belongs to
  20505. * @param subMesh Define the sub mesh to look readyness for
  20506. * @param useInstances Define whether or not the material is used with instances
  20507. * @returns true if ready, otherwise false
  20508. */
  20509. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20510. /**
  20511. * Clones the current material and its related sub materials
  20512. * @param name Define the name of the newly cloned material
  20513. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20514. * @returns the cloned material
  20515. */
  20516. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20517. /**
  20518. * Serializes the materials into a JSON representation.
  20519. * @returns the JSON representation
  20520. */
  20521. serialize(): any;
  20522. /**
  20523. * Dispose the material and release its associated resources
  20524. * @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)
  20525. * @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)
  20526. * @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)
  20527. */
  20528. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20529. /**
  20530. * Creates a MultiMaterial from parsed MultiMaterial data.
  20531. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20532. * @param scene defines the hosting scene
  20533. * @returns a new MultiMaterial
  20534. */
  20535. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20536. }
  20537. }
  20538. declare module BABYLON {
  20539. /**
  20540. * Base class for submeshes
  20541. */
  20542. export class BaseSubMesh {
  20543. /** @hidden */ private _materialDefines: Nullable<MaterialDefines>;
  20544. /** @hidden */ private _materialEffect: Nullable<Effect>;
  20545. /**
  20546. * Gets associated effect
  20547. */
  20548. readonly effect: Nullable<Effect>;
  20549. /**
  20550. * Sets associated effect (effect used to render this submesh)
  20551. * @param effect defines the effect to associate with
  20552. * @param defines defines the set of defines used to compile this effect
  20553. */
  20554. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20555. }
  20556. /**
  20557. * Defines a subdivision inside a mesh
  20558. */
  20559. export class SubMesh extends BaseSubMesh implements ICullable {
  20560. /** the material index to use */
  20561. materialIndex: number;
  20562. /** vertex index start */
  20563. verticesStart: number;
  20564. /** vertices count */
  20565. verticesCount: number;
  20566. /** index start */
  20567. indexStart: number;
  20568. /** indices count */
  20569. indexCount: number;
  20570. /** @hidden */ private _linesIndexCount: number;
  20571. private _mesh;
  20572. private _renderingMesh;
  20573. private _boundingInfo;
  20574. private _linesIndexBuffer;
  20575. /** @hidden */ private _lastColliderWorldVertices: Nullable<Vector3[]>;
  20576. /** @hidden */ private _trianglePlanes: Plane[];
  20577. /** @hidden */ private _lastColliderTransformMatrix: Nullable<Matrix>;
  20578. /** @hidden */ private _renderId: number;
  20579. /** @hidden */ private _alphaIndex: number;
  20580. /** @hidden */ private _distanceToCamera: number;
  20581. /** @hidden */ private _id: number;
  20582. private _currentMaterial;
  20583. /**
  20584. * Add a new submesh to a mesh
  20585. * @param materialIndex defines the material index to use
  20586. * @param verticesStart defines vertex index start
  20587. * @param verticesCount defines vertices count
  20588. * @param indexStart defines index start
  20589. * @param indexCount defines indices count
  20590. * @param mesh defines the parent mesh
  20591. * @param renderingMesh defines an optional rendering mesh
  20592. * @param createBoundingBox defines if bounding box should be created for this submesh
  20593. * @returns the new submesh
  20594. */
  20595. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20596. /**
  20597. * Creates a new submesh
  20598. * @param materialIndex defines the material index to use
  20599. * @param verticesStart defines vertex index start
  20600. * @param verticesCount defines vertices count
  20601. * @param indexStart defines index start
  20602. * @param indexCount defines indices count
  20603. * @param mesh defines the parent mesh
  20604. * @param renderingMesh defines an optional rendering mesh
  20605. * @param createBoundingBox defines if bounding box should be created for this submesh
  20606. */
  20607. constructor(
  20608. /** the material index to use */
  20609. materialIndex: number,
  20610. /** vertex index start */
  20611. verticesStart: number,
  20612. /** vertices count */
  20613. verticesCount: number,
  20614. /** index start */
  20615. indexStart: number,
  20616. /** indices count */
  20617. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20618. /**
  20619. * Returns true if this submesh covers the entire parent mesh
  20620. * @ignorenaming
  20621. */
  20622. readonly IsGlobal: boolean;
  20623. /**
  20624. * Returns the submesh BoudingInfo object
  20625. * @returns current bounding info (or mesh's one if the submesh is global)
  20626. */
  20627. getBoundingInfo(): BoundingInfo;
  20628. /**
  20629. * Sets the submesh BoundingInfo
  20630. * @param boundingInfo defines the new bounding info to use
  20631. * @returns the SubMesh
  20632. */
  20633. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20634. /**
  20635. * Returns the mesh of the current submesh
  20636. * @return the parent mesh
  20637. */
  20638. getMesh(): AbstractMesh;
  20639. /**
  20640. * Returns the rendering mesh of the submesh
  20641. * @returns the rendering mesh (could be different from parent mesh)
  20642. */
  20643. getRenderingMesh(): Mesh;
  20644. /**
  20645. * Returns the submesh material
  20646. * @returns null or the current material
  20647. */
  20648. getMaterial(): Nullable<Material>;
  20649. /**
  20650. * Sets a new updated BoundingInfo object to the submesh
  20651. * @param data defines an optional position array to use to determine the bounding info
  20652. * @returns the SubMesh
  20653. */
  20654. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20655. /** @hidden */ private _checkCollision(collider: Collider): boolean;
  20656. /**
  20657. * Updates the submesh BoundingInfo
  20658. * @param world defines the world matrix to use to update the bounding info
  20659. * @returns the submesh
  20660. */
  20661. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20662. /**
  20663. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20664. * @param frustumPlanes defines the frustum planes
  20665. * @returns true if the submesh is intersecting with the frustum
  20666. */
  20667. isInFrustum(frustumPlanes: Plane[]): boolean;
  20668. /**
  20669. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20670. * @param frustumPlanes defines the frustum planes
  20671. * @returns true if the submesh is inside the frustum
  20672. */
  20673. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20674. /**
  20675. * Renders the submesh
  20676. * @param enableAlphaMode defines if alpha needs to be used
  20677. * @returns the submesh
  20678. */
  20679. render(enableAlphaMode: boolean): SubMesh;
  20680. /**
  20681. * @hidden
  20682. */ private _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  20683. /**
  20684. * Checks if the submesh intersects with a ray
  20685. * @param ray defines the ray to test
  20686. * @returns true is the passed ray intersects the submesh bounding box
  20687. */
  20688. canIntersects(ray: Ray): boolean;
  20689. /**
  20690. * Intersects current submesh with a ray
  20691. * @param ray defines the ray to test
  20692. * @param positions defines mesh's positions array
  20693. * @param indices defines mesh's indices array
  20694. * @param fastCheck defines if only bounding info should be used
  20695. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  20696. * @returns intersection info or null if no intersection
  20697. */
  20698. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  20699. /** @hidden */
  20700. private _intersectLines;
  20701. /** @hidden */
  20702. private _intersectUnIndexedLines;
  20703. /** @hidden */
  20704. private _intersectTriangles;
  20705. /** @hidden */
  20706. private _intersectUnIndexedTriangles;
  20707. /** @hidden */ private _rebuild(): void;
  20708. /**
  20709. * Creates a new submesh from the passed mesh
  20710. * @param newMesh defines the new hosting mesh
  20711. * @param newRenderingMesh defines an optional rendering mesh
  20712. * @returns the new submesh
  20713. */
  20714. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20715. /**
  20716. * Release associated resources
  20717. */
  20718. dispose(): void;
  20719. /**
  20720. * Gets the class name
  20721. * @returns the string "SubMesh".
  20722. */
  20723. getClassName(): string;
  20724. /**
  20725. * Creates a new submesh from indices data
  20726. * @param materialIndex the index of the main mesh material
  20727. * @param startIndex the index where to start the copy in the mesh indices array
  20728. * @param indexCount the number of indices to copy then from the startIndex
  20729. * @param mesh the main mesh to create the submesh from
  20730. * @param renderingMesh the optional rendering mesh
  20731. * @returns a new submesh
  20732. */
  20733. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20734. }
  20735. }
  20736. declare module BABYLON {
  20737. /**
  20738. * Class used to represent data loading progression
  20739. */
  20740. export class SceneLoaderFlags {
  20741. private static _ForceFullSceneLoadingForIncremental;
  20742. private static _ShowLoadingScreen;
  20743. private static _CleanBoneMatrixWeights;
  20744. private static _loggingLevel;
  20745. /**
  20746. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  20747. */
  20748. static ForceFullSceneLoadingForIncremental: boolean;
  20749. /**
  20750. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  20751. */
  20752. static ShowLoadingScreen: boolean;
  20753. /**
  20754. * Defines the current logging level (while loading the scene)
  20755. * @ignorenaming
  20756. */
  20757. static loggingLevel: number;
  20758. /**
  20759. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  20760. */
  20761. static CleanBoneMatrixWeights: boolean;
  20762. }
  20763. }
  20764. declare module BABYLON {
  20765. /**
  20766. * Class used to store geometry data (vertex buffers + index buffer)
  20767. */
  20768. export class Geometry implements IGetSetVerticesData {
  20769. /**
  20770. * Gets or sets the ID of the geometry
  20771. */
  20772. id: string;
  20773. /**
  20774. * Gets or sets the unique ID of the geometry
  20775. */
  20776. uniqueId: number;
  20777. /**
  20778. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20779. */
  20780. delayLoadState: number;
  20781. /**
  20782. * Gets the file containing the data to load when running in delay load state
  20783. */
  20784. delayLoadingFile: Nullable<string>;
  20785. /**
  20786. * Callback called when the geometry is updated
  20787. */
  20788. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20789. private _scene;
  20790. private _engine;
  20791. private _meshes;
  20792. private _totalVertices;
  20793. /** @hidden */ private _indices: IndicesArray;
  20794. /** @hidden */ private _vertexBuffers: {
  20795. [key: string]: VertexBuffer;
  20796. };
  20797. private _isDisposed;
  20798. private _extend;
  20799. private _boundingBias;
  20800. /** @hidden */ private _delayInfo: Array<string>;
  20801. private _indexBuffer;
  20802. private _indexBufferIsUpdatable;
  20803. /** @hidden */ private _boundingInfo: Nullable<BoundingInfo>;
  20804. /** @hidden */ private _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20805. /** @hidden */ private _softwareSkinningFrameId: number;
  20806. private _vertexArrayObjects;
  20807. private _updatable;
  20808. /** @hidden */ private _positions: Nullable<Vector3[]>;
  20809. /**
  20810. * 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
  20811. */
  20812. /**
  20813. * 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
  20814. */
  20815. boundingBias: Vector2;
  20816. /**
  20817. * Static function used to attach a new empty geometry to a mesh
  20818. * @param mesh defines the mesh to attach the geometry to
  20819. * @returns the new Geometry
  20820. */
  20821. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20822. /**
  20823. * Creates a new geometry
  20824. * @param id defines the unique ID
  20825. * @param scene defines the hosting scene
  20826. * @param vertexData defines the VertexData used to get geometry data
  20827. * @param updatable defines if geometry must be updatable (false by default)
  20828. * @param mesh defines the mesh that will be associated with the geometry
  20829. */
  20830. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20831. /**
  20832. * Gets the current extend of the geometry
  20833. */
  20834. readonly extend: {
  20835. minimum: Vector3;
  20836. maximum: Vector3;
  20837. };
  20838. /**
  20839. * Gets the hosting scene
  20840. * @returns the hosting Scene
  20841. */
  20842. getScene(): Scene;
  20843. /**
  20844. * Gets the hosting engine
  20845. * @returns the hosting Engine
  20846. */
  20847. getEngine(): Engine;
  20848. /**
  20849. * Defines if the geometry is ready to use
  20850. * @returns true if the geometry is ready to be used
  20851. */
  20852. isReady(): boolean;
  20853. /**
  20854. * Gets a value indicating that the geometry should not be serialized
  20855. */
  20856. readonly doNotSerialize: boolean;
  20857. /** @hidden */ private _rebuild(): void;
  20858. /**
  20859. * Affects all geometry data in one call
  20860. * @param vertexData defines the geometry data
  20861. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20862. */
  20863. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20864. /**
  20865. * Set specific vertex data
  20866. * @param kind defines the data kind (Position, normal, etc...)
  20867. * @param data defines the vertex data to use
  20868. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20869. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20870. */
  20871. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20872. /**
  20873. * Removes a specific vertex data
  20874. * @param kind defines the data kind (Position, normal, etc...)
  20875. */
  20876. removeVerticesData(kind: string): void;
  20877. /**
  20878. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20879. * @param buffer defines the vertex buffer to use
  20880. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20881. */
  20882. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20883. /**
  20884. * Update a specific vertex buffer
  20885. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  20886. * It will do nothing if the buffer is not updatable
  20887. * @param kind defines the data kind (Position, normal, etc...)
  20888. * @param data defines the data to use
  20889. * @param offset defines the offset in the target buffer where to store the data
  20890. * @param useBytes set to true if the offset is in bytes
  20891. */
  20892. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20893. /**
  20894. * Update a specific vertex buffer
  20895. * This function will create a new buffer if the current one is not updatable
  20896. * @param kind defines the data kind (Position, normal, etc...)
  20897. * @param data defines the data to use
  20898. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20899. */
  20900. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20901. private _updateBoundingInfo;
  20902. /** @hidden */ private _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  20903. /**
  20904. * Gets total number of vertices
  20905. * @returns the total number of vertices
  20906. */
  20907. getTotalVertices(): number;
  20908. /**
  20909. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20910. * @param kind defines the data kind (Position, normal, etc...)
  20911. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20912. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20913. * @returns a float array containing vertex data
  20914. */
  20915. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20916. /**
  20917. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20918. * @param kind defines the data kind (Position, normal, etc...)
  20919. * @returns true if the vertex buffer with the specified kind is updatable
  20920. */
  20921. isVertexBufferUpdatable(kind: string): boolean;
  20922. /**
  20923. * Gets a specific vertex buffer
  20924. * @param kind defines the data kind (Position, normal, etc...)
  20925. * @returns a VertexBuffer
  20926. */
  20927. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20928. /**
  20929. * Returns all vertex buffers
  20930. * @return an object holding all vertex buffers indexed by kind
  20931. */
  20932. getVertexBuffers(): Nullable<{
  20933. [key: string]: VertexBuffer;
  20934. }>;
  20935. /**
  20936. * Gets a boolean indicating if specific vertex buffer is present
  20937. * @param kind defines the data kind (Position, normal, etc...)
  20938. * @returns true if data is present
  20939. */
  20940. isVerticesDataPresent(kind: string): boolean;
  20941. /**
  20942. * Gets a list of all attached data kinds (Position, normal, etc...)
  20943. * @returns a list of string containing all kinds
  20944. */
  20945. getVerticesDataKinds(): string[];
  20946. /**
  20947. * Update index buffer
  20948. * @param indices defines the indices to store in the index buffer
  20949. * @param offset defines the offset in the target buffer where to store the data
  20950. * @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)
  20951. */
  20952. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  20953. /**
  20954. * Creates a new index buffer
  20955. * @param indices defines the indices to store in the index buffer
  20956. * @param totalVertices defines the total number of vertices (could be null)
  20957. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  20958. */
  20959. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  20960. /**
  20961. * Return the total number of indices
  20962. * @returns the total number of indices
  20963. */
  20964. getTotalIndices(): number;
  20965. /**
  20966. * Gets the index buffer array
  20967. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20968. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20969. * @returns the index buffer array
  20970. */
  20971. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20972. /**
  20973. * Gets the index buffer
  20974. * @return the index buffer
  20975. */
  20976. getIndexBuffer(): Nullable<DataBuffer>;
  20977. /** @hidden */ private _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  20978. /**
  20979. * Release the associated resources for a specific mesh
  20980. * @param mesh defines the source mesh
  20981. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  20982. */
  20983. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  20984. /**
  20985. * Apply current geometry to a given mesh
  20986. * @param mesh defines the mesh to apply geometry to
  20987. */
  20988. applyToMesh(mesh: Mesh): void;
  20989. private _updateExtend;
  20990. private _applyToMesh;
  20991. private notifyUpdate;
  20992. /**
  20993. * Load the geometry if it was flagged as delay loaded
  20994. * @param scene defines the hosting scene
  20995. * @param onLoaded defines a callback called when the geometry is loaded
  20996. */
  20997. load(scene: Scene, onLoaded?: () => void): void;
  20998. private _queueLoad;
  20999. /**
  21000. * Invert the geometry to move from a right handed system to a left handed one.
  21001. */
  21002. toLeftHanded(): void;
  21003. /** @hidden */ private _resetPointsArrayCache(): void;
  21004. /** @hidden */ private _generatePointsArray(): boolean;
  21005. /**
  21006. * Gets a value indicating if the geometry is disposed
  21007. * @returns true if the geometry was disposed
  21008. */
  21009. isDisposed(): boolean;
  21010. private _disposeVertexArrayObjects;
  21011. /**
  21012. * Free all associated resources
  21013. */
  21014. dispose(): void;
  21015. /**
  21016. * Clone the current geometry into a new geometry
  21017. * @param id defines the unique ID of the new geometry
  21018. * @returns a new geometry object
  21019. */
  21020. copy(id: string): Geometry;
  21021. /**
  21022. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21023. * @return a JSON representation of the current geometry data (without the vertices data)
  21024. */
  21025. serialize(): any;
  21026. private toNumberArray;
  21027. /**
  21028. * Serialize all vertices data into a JSON oject
  21029. * @returns a JSON representation of the current geometry data
  21030. */
  21031. serializeVerticeData(): any;
  21032. /**
  21033. * Extracts a clone of a mesh geometry
  21034. * @param mesh defines the source mesh
  21035. * @param id defines the unique ID of the new geometry object
  21036. * @returns the new geometry object
  21037. */
  21038. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21039. /**
  21040. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21041. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21042. * Be aware Math.random() could cause collisions, but:
  21043. * "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"
  21044. * @returns a string containing a new GUID
  21045. */
  21046. static RandomId(): string;
  21047. /** @hidden */ private static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21048. private static _CleanMatricesWeights;
  21049. /**
  21050. * Create a new geometry from persisted data (Using .babylon file format)
  21051. * @param parsedVertexData defines the persisted data
  21052. * @param scene defines the hosting scene
  21053. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21054. * @returns the new geometry object
  21055. */
  21056. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21057. }
  21058. }
  21059. declare module BABYLON {
  21060. /**
  21061. * Define an interface for all classes that will get and set the data on vertices
  21062. */
  21063. export interface IGetSetVerticesData {
  21064. /**
  21065. * Gets a boolean indicating if specific vertex data is present
  21066. * @param kind defines the vertex data kind to use
  21067. * @returns true is data kind is present
  21068. */
  21069. isVerticesDataPresent(kind: string): boolean;
  21070. /**
  21071. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21072. * @param kind defines the data kind (Position, normal, etc...)
  21073. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21074. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21075. * @returns a float array containing vertex data
  21076. */
  21077. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21078. /**
  21079. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21080. * @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.
  21081. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21082. * @returns the indices array or an empty array if the mesh has no geometry
  21083. */
  21084. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21085. /**
  21086. * Set specific vertex data
  21087. * @param kind defines the data kind (Position, normal, etc...)
  21088. * @param data defines the vertex data to use
  21089. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21090. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21091. */
  21092. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21093. /**
  21094. * Update a specific associated vertex buffer
  21095. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21096. * - VertexBuffer.PositionKind
  21097. * - VertexBuffer.UVKind
  21098. * - VertexBuffer.UV2Kind
  21099. * - VertexBuffer.UV3Kind
  21100. * - VertexBuffer.UV4Kind
  21101. * - VertexBuffer.UV5Kind
  21102. * - VertexBuffer.UV6Kind
  21103. * - VertexBuffer.ColorKind
  21104. * - VertexBuffer.MatricesIndicesKind
  21105. * - VertexBuffer.MatricesIndicesExtraKind
  21106. * - VertexBuffer.MatricesWeightsKind
  21107. * - VertexBuffer.MatricesWeightsExtraKind
  21108. * @param data defines the data source
  21109. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21110. * @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)
  21111. */
  21112. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21113. /**
  21114. * Creates a new index buffer
  21115. * @param indices defines the indices to store in the index buffer
  21116. * @param totalVertices defines the total number of vertices (could be null)
  21117. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21118. */
  21119. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21120. }
  21121. /**
  21122. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21123. */
  21124. export class VertexData {
  21125. /**
  21126. * Mesh side orientation : usually the external or front surface
  21127. */
  21128. static readonly FRONTSIDE: number;
  21129. /**
  21130. * Mesh side orientation : usually the internal or back surface
  21131. */
  21132. static readonly BACKSIDE: number;
  21133. /**
  21134. * Mesh side orientation : both internal and external or front and back surfaces
  21135. */
  21136. static readonly DOUBLESIDE: number;
  21137. /**
  21138. * Mesh side orientation : by default, `FRONTSIDE`
  21139. */
  21140. static readonly DEFAULTSIDE: number;
  21141. /**
  21142. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21143. */
  21144. positions: Nullable<FloatArray>;
  21145. /**
  21146. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21147. */
  21148. normals: Nullable<FloatArray>;
  21149. /**
  21150. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21151. */
  21152. tangents: Nullable<FloatArray>;
  21153. /**
  21154. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21155. */
  21156. uvs: Nullable<FloatArray>;
  21157. /**
  21158. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21159. */
  21160. uvs2: Nullable<FloatArray>;
  21161. /**
  21162. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21163. */
  21164. uvs3: Nullable<FloatArray>;
  21165. /**
  21166. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21167. */
  21168. uvs4: Nullable<FloatArray>;
  21169. /**
  21170. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21171. */
  21172. uvs5: Nullable<FloatArray>;
  21173. /**
  21174. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21175. */
  21176. uvs6: Nullable<FloatArray>;
  21177. /**
  21178. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21179. */
  21180. colors: Nullable<FloatArray>;
  21181. /**
  21182. * 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).
  21183. */
  21184. matricesIndices: Nullable<FloatArray>;
  21185. /**
  21186. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21187. */
  21188. matricesWeights: Nullable<FloatArray>;
  21189. /**
  21190. * An array extending the number of possible indices
  21191. */
  21192. matricesIndicesExtra: Nullable<FloatArray>;
  21193. /**
  21194. * An array extending the number of possible weights when the number of indices is extended
  21195. */
  21196. matricesWeightsExtra: Nullable<FloatArray>;
  21197. /**
  21198. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21199. */
  21200. indices: Nullable<IndicesArray>;
  21201. /**
  21202. * Uses the passed data array to set the set the values for the specified kind of data
  21203. * @param data a linear array of floating numbers
  21204. * @param kind the type of data that is being set, eg positions, colors etc
  21205. */
  21206. set(data: FloatArray, kind: string): void;
  21207. /**
  21208. * Associates the vertexData to the passed Mesh.
  21209. * Sets it as updatable or not (default `false`)
  21210. * @param mesh the mesh the vertexData is applied to
  21211. * @param updatable when used and having the value true allows new data to update the vertexData
  21212. * @returns the VertexData
  21213. */
  21214. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21215. /**
  21216. * Associates the vertexData to the passed Geometry.
  21217. * Sets it as updatable or not (default `false`)
  21218. * @param geometry the geometry the vertexData is applied to
  21219. * @param updatable when used and having the value true allows new data to update the vertexData
  21220. * @returns VertexData
  21221. */
  21222. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21223. /**
  21224. * Updates the associated mesh
  21225. * @param mesh the mesh to be updated
  21226. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21227. * @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
  21228. * @returns VertexData
  21229. */
  21230. updateMesh(mesh: Mesh): VertexData;
  21231. /**
  21232. * Updates the associated geometry
  21233. * @param geometry the geometry to be updated
  21234. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21235. * @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
  21236. * @returns VertexData.
  21237. */
  21238. updateGeometry(geometry: Geometry): VertexData;
  21239. private _applyTo;
  21240. private _update;
  21241. /**
  21242. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21243. * @param matrix the transforming matrix
  21244. * @returns the VertexData
  21245. */
  21246. transform(matrix: Matrix): VertexData;
  21247. /**
  21248. * Merges the passed VertexData into the current one
  21249. * @param other the VertexData to be merged into the current one
  21250. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21251. * @returns the modified VertexData
  21252. */
  21253. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21254. private _mergeElement;
  21255. private _validate;
  21256. /**
  21257. * Serializes the VertexData
  21258. * @returns a serialized object
  21259. */
  21260. serialize(): any;
  21261. /**
  21262. * Extracts the vertexData from a mesh
  21263. * @param mesh the mesh from which to extract the VertexData
  21264. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21265. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21266. * @returns the object VertexData associated to the passed mesh
  21267. */
  21268. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21269. /**
  21270. * Extracts the vertexData from the geometry
  21271. * @param geometry the geometry from which to extract the VertexData
  21272. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21273. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21274. * @returns the object VertexData associated to the passed mesh
  21275. */
  21276. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21277. private static _ExtractFrom;
  21278. /**
  21279. * Creates the VertexData for a Ribbon
  21280. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21281. * * pathArray array of paths, each of which an array of successive Vector3
  21282. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21283. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21284. * * 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
  21285. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21286. * * 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)
  21287. * * 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)
  21288. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21289. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21290. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21291. * @returns the VertexData of the ribbon
  21292. */
  21293. static CreateRibbon(options: {
  21294. pathArray: Vector3[][];
  21295. closeArray?: boolean;
  21296. closePath?: boolean;
  21297. offset?: number;
  21298. sideOrientation?: number;
  21299. frontUVs?: Vector4;
  21300. backUVs?: Vector4;
  21301. invertUV?: boolean;
  21302. uvs?: Vector2[];
  21303. colors?: Color4[];
  21304. }): VertexData;
  21305. /**
  21306. * Creates the VertexData for a box
  21307. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21308. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21309. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21310. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21311. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21312. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21313. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21314. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21315. * * 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)
  21316. * * 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)
  21317. * @returns the VertexData of the box
  21318. */
  21319. static CreateBox(options: {
  21320. size?: number;
  21321. width?: number;
  21322. height?: number;
  21323. depth?: number;
  21324. faceUV?: Vector4[];
  21325. faceColors?: Color4[];
  21326. sideOrientation?: number;
  21327. frontUVs?: Vector4;
  21328. backUVs?: Vector4;
  21329. }): VertexData;
  21330. /**
  21331. * Creates the VertexData for a tiled box
  21332. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21333. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21334. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21335. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21336. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21337. * @returns the VertexData of the box
  21338. */
  21339. static CreateTiledBox(options: {
  21340. pattern?: number;
  21341. width?: number;
  21342. height?: number;
  21343. depth?: number;
  21344. tileSize?: number;
  21345. tileWidth?: number;
  21346. tileHeight?: number;
  21347. alignHorizontal?: number;
  21348. alignVertical?: number;
  21349. faceUV?: Vector4[];
  21350. faceColors?: Color4[];
  21351. sideOrientation?: number;
  21352. }): VertexData;
  21353. /**
  21354. * Creates the VertexData for a tiled plane
  21355. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21356. * * pattern a limited pattern arrangement depending on the number
  21357. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21358. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21359. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21360. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21361. * * 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)
  21362. * * 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)
  21363. * @returns the VertexData of the tiled plane
  21364. */
  21365. static CreateTiledPlane(options: {
  21366. pattern?: number;
  21367. tileSize?: number;
  21368. tileWidth?: number;
  21369. tileHeight?: number;
  21370. size?: number;
  21371. width?: number;
  21372. height?: number;
  21373. alignHorizontal?: number;
  21374. alignVertical?: number;
  21375. sideOrientation?: number;
  21376. frontUVs?: Vector4;
  21377. backUVs?: Vector4;
  21378. }): VertexData;
  21379. /**
  21380. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21381. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21382. * * segments sets the number of horizontal strips optional, default 32
  21383. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21384. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21385. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21386. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21387. * * 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
  21388. * * 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
  21389. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21390. * * 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)
  21391. * * 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)
  21392. * @returns the VertexData of the ellipsoid
  21393. */
  21394. static CreateSphere(options: {
  21395. segments?: number;
  21396. diameter?: number;
  21397. diameterX?: number;
  21398. diameterY?: number;
  21399. diameterZ?: number;
  21400. arc?: number;
  21401. slice?: number;
  21402. sideOrientation?: number;
  21403. frontUVs?: Vector4;
  21404. backUVs?: Vector4;
  21405. }): VertexData;
  21406. /**
  21407. * Creates the VertexData for a cylinder, cone or prism
  21408. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21409. * * height sets the height (y direction) of the cylinder, optional, default 2
  21410. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21411. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21412. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21413. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21414. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21415. * * 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
  21416. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21417. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21418. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21419. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21420. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21421. * * 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)
  21422. * * 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)
  21423. * @returns the VertexData of the cylinder, cone or prism
  21424. */
  21425. static CreateCylinder(options: {
  21426. height?: number;
  21427. diameterTop?: number;
  21428. diameterBottom?: number;
  21429. diameter?: number;
  21430. tessellation?: number;
  21431. subdivisions?: number;
  21432. arc?: number;
  21433. faceColors?: Color4[];
  21434. faceUV?: Vector4[];
  21435. hasRings?: boolean;
  21436. enclose?: boolean;
  21437. sideOrientation?: number;
  21438. frontUVs?: Vector4;
  21439. backUVs?: Vector4;
  21440. }): VertexData;
  21441. /**
  21442. * Creates the VertexData for a torus
  21443. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21444. * * diameter the diameter of the torus, optional default 1
  21445. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21446. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21447. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21448. * * 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)
  21449. * * 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)
  21450. * @returns the VertexData of the torus
  21451. */
  21452. static CreateTorus(options: {
  21453. diameter?: number;
  21454. thickness?: number;
  21455. tessellation?: number;
  21456. sideOrientation?: number;
  21457. frontUVs?: Vector4;
  21458. backUVs?: Vector4;
  21459. }): VertexData;
  21460. /**
  21461. * Creates the VertexData of the LineSystem
  21462. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21463. * - lines an array of lines, each line being an array of successive Vector3
  21464. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21465. * @returns the VertexData of the LineSystem
  21466. */
  21467. static CreateLineSystem(options: {
  21468. lines: Vector3[][];
  21469. colors?: Nullable<Color4[][]>;
  21470. }): VertexData;
  21471. /**
  21472. * Create the VertexData for a DashedLines
  21473. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21474. * - points an array successive Vector3
  21475. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21476. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21477. * - dashNb the intended total number of dashes, optional, default 200
  21478. * @returns the VertexData for the DashedLines
  21479. */
  21480. static CreateDashedLines(options: {
  21481. points: Vector3[];
  21482. dashSize?: number;
  21483. gapSize?: number;
  21484. dashNb?: number;
  21485. }): VertexData;
  21486. /**
  21487. * Creates the VertexData for a Ground
  21488. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21489. * - width the width (x direction) of the ground, optional, default 1
  21490. * - height the height (z direction) of the ground, optional, default 1
  21491. * - subdivisions the number of subdivisions per side, optional, default 1
  21492. * @returns the VertexData of the Ground
  21493. */
  21494. static CreateGround(options: {
  21495. width?: number;
  21496. height?: number;
  21497. subdivisions?: number;
  21498. subdivisionsX?: number;
  21499. subdivisionsY?: number;
  21500. }): VertexData;
  21501. /**
  21502. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21503. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21504. * * xmin the ground minimum X coordinate, optional, default -1
  21505. * * zmin the ground minimum Z coordinate, optional, default -1
  21506. * * xmax the ground maximum X coordinate, optional, default 1
  21507. * * zmax the ground maximum Z coordinate, optional, default 1
  21508. * * 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}
  21509. * * 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}
  21510. * @returns the VertexData of the TiledGround
  21511. */
  21512. static CreateTiledGround(options: {
  21513. xmin: number;
  21514. zmin: number;
  21515. xmax: number;
  21516. zmax: number;
  21517. subdivisions?: {
  21518. w: number;
  21519. h: number;
  21520. };
  21521. precision?: {
  21522. w: number;
  21523. h: number;
  21524. };
  21525. }): VertexData;
  21526. /**
  21527. * Creates the VertexData of the Ground designed from a heightmap
  21528. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21529. * * width the width (x direction) of the ground
  21530. * * height the height (z direction) of the ground
  21531. * * subdivisions the number of subdivisions per side
  21532. * * minHeight the minimum altitude on the ground, optional, default 0
  21533. * * maxHeight the maximum altitude on the ground, optional default 1
  21534. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21535. * * buffer the array holding the image color data
  21536. * * bufferWidth the width of image
  21537. * * bufferHeight the height of image
  21538. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21539. * @returns the VertexData of the Ground designed from a heightmap
  21540. */
  21541. static CreateGroundFromHeightMap(options: {
  21542. width: number;
  21543. height: number;
  21544. subdivisions: number;
  21545. minHeight: number;
  21546. maxHeight: number;
  21547. colorFilter: Color3;
  21548. buffer: Uint8Array;
  21549. bufferWidth: number;
  21550. bufferHeight: number;
  21551. alphaFilter: number;
  21552. }): VertexData;
  21553. /**
  21554. * Creates the VertexData for a Plane
  21555. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21556. * * size sets the width and height of the plane to the value of size, optional default 1
  21557. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21558. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21559. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21560. * * 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)
  21561. * * 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)
  21562. * @returns the VertexData of the box
  21563. */
  21564. static CreatePlane(options: {
  21565. size?: number;
  21566. width?: number;
  21567. height?: number;
  21568. sideOrientation?: number;
  21569. frontUVs?: Vector4;
  21570. backUVs?: Vector4;
  21571. }): VertexData;
  21572. /**
  21573. * Creates the VertexData of the Disc or regular Polygon
  21574. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21575. * * radius the radius of the disc, optional default 0.5
  21576. * * tessellation the number of polygon sides, optional, default 64
  21577. * * 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
  21578. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21579. * * 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)
  21580. * * 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)
  21581. * @returns the VertexData of the box
  21582. */
  21583. static CreateDisc(options: {
  21584. radius?: number;
  21585. tessellation?: number;
  21586. arc?: number;
  21587. sideOrientation?: number;
  21588. frontUVs?: Vector4;
  21589. backUVs?: Vector4;
  21590. }): VertexData;
  21591. /**
  21592. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21593. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21594. * @param polygon a mesh built from polygonTriangulation.build()
  21595. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21596. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21597. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21598. * @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)
  21599. * @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)
  21600. * @returns the VertexData of the Polygon
  21601. */
  21602. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21603. /**
  21604. * Creates the VertexData of the IcoSphere
  21605. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21606. * * radius the radius of the IcoSphere, optional default 1
  21607. * * radiusX allows stretching in the x direction, optional, default radius
  21608. * * radiusY allows stretching in the y direction, optional, default radius
  21609. * * radiusZ allows stretching in the z direction, optional, default radius
  21610. * * flat when true creates a flat shaded mesh, optional, default true
  21611. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21612. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21613. * * 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)
  21614. * * 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)
  21615. * @returns the VertexData of the IcoSphere
  21616. */
  21617. static CreateIcoSphere(options: {
  21618. radius?: number;
  21619. radiusX?: number;
  21620. radiusY?: number;
  21621. radiusZ?: number;
  21622. flat?: boolean;
  21623. subdivisions?: number;
  21624. sideOrientation?: number;
  21625. frontUVs?: Vector4;
  21626. backUVs?: Vector4;
  21627. }): VertexData;
  21628. /**
  21629. * Creates the VertexData for a Polyhedron
  21630. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21631. * * type provided types are:
  21632. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21633. * * 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)
  21634. * * size the size of the IcoSphere, optional default 1
  21635. * * sizeX allows stretching in the x direction, optional, default size
  21636. * * sizeY allows stretching in the y direction, optional, default size
  21637. * * sizeZ allows stretching in the z direction, optional, default size
  21638. * * 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
  21639. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21640. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21641. * * flat when true creates a flat shaded mesh, optional, default true
  21642. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21643. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21644. * * 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)
  21645. * * 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)
  21646. * @returns the VertexData of the Polyhedron
  21647. */
  21648. static CreatePolyhedron(options: {
  21649. type?: number;
  21650. size?: number;
  21651. sizeX?: number;
  21652. sizeY?: number;
  21653. sizeZ?: number;
  21654. custom?: any;
  21655. faceUV?: Vector4[];
  21656. faceColors?: Color4[];
  21657. flat?: boolean;
  21658. sideOrientation?: number;
  21659. frontUVs?: Vector4;
  21660. backUVs?: Vector4;
  21661. }): VertexData;
  21662. /**
  21663. * Creates the VertexData for a TorusKnot
  21664. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21665. * * radius the radius of the torus knot, optional, default 2
  21666. * * tube the thickness of the tube, optional, default 0.5
  21667. * * radialSegments the number of sides on each tube segments, optional, default 32
  21668. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21669. * * p the number of windings around the z axis, optional, default 2
  21670. * * q the number of windings around the x axis, optional, default 3
  21671. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21672. * * 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)
  21673. * * 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)
  21674. * @returns the VertexData of the Torus Knot
  21675. */
  21676. static CreateTorusKnot(options: {
  21677. radius?: number;
  21678. tube?: number;
  21679. radialSegments?: number;
  21680. tubularSegments?: number;
  21681. p?: number;
  21682. q?: number;
  21683. sideOrientation?: number;
  21684. frontUVs?: Vector4;
  21685. backUVs?: Vector4;
  21686. }): VertexData;
  21687. /**
  21688. * Compute normals for given positions and indices
  21689. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21690. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21691. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21692. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21693. * * facetNormals : optional array of facet normals (vector3)
  21694. * * facetPositions : optional array of facet positions (vector3)
  21695. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21696. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21697. * * bInfo : optional bounding info, required for facetPartitioning computation
  21698. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21699. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21700. * * useRightHandedSystem: optional boolean to for right handed system computation
  21701. * * depthSort : optional boolean to enable the facet depth sort computation
  21702. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21703. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21704. */
  21705. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21706. facetNormals?: any;
  21707. facetPositions?: any;
  21708. facetPartitioning?: any;
  21709. ratio?: number;
  21710. bInfo?: any;
  21711. bbSize?: Vector3;
  21712. subDiv?: any;
  21713. useRightHandedSystem?: boolean;
  21714. depthSort?: boolean;
  21715. distanceTo?: Vector3;
  21716. depthSortedFacets?: any;
  21717. }): void;
  21718. /** @hidden */ private static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21719. /**
  21720. * Applies VertexData created from the imported parameters to the geometry
  21721. * @param parsedVertexData the parsed data from an imported file
  21722. * @param geometry the geometry to apply the VertexData to
  21723. */
  21724. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21725. }
  21726. }
  21727. declare module BABYLON {
  21728. /**
  21729. * Defines a target to use with MorphTargetManager
  21730. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21731. */
  21732. export class MorphTarget implements IAnimatable {
  21733. /** defines the name of the target */
  21734. name: string;
  21735. /**
  21736. * Gets or sets the list of animations
  21737. */
  21738. animations: Animation[];
  21739. private _scene;
  21740. private _positions;
  21741. private _normals;
  21742. private _tangents;
  21743. private _uvs;
  21744. private _influence;
  21745. /**
  21746. * Observable raised when the influence changes
  21747. */
  21748. onInfluenceChanged: Observable<boolean>;
  21749. /** @hidden */ private _onDataLayoutChanged: Observable<void>;
  21750. /**
  21751. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  21752. */
  21753. influence: number;
  21754. /**
  21755. * Gets or sets the id of the morph Target
  21756. */
  21757. id: string;
  21758. private _animationPropertiesOverride;
  21759. /**
  21760. * Gets or sets the animation properties override
  21761. */
  21762. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  21763. /**
  21764. * Creates a new MorphTarget
  21765. * @param name defines the name of the target
  21766. * @param influence defines the influence to use
  21767. * @param scene defines the scene the morphtarget belongs to
  21768. */
  21769. constructor(
  21770. /** defines the name of the target */
  21771. name: string, influence?: number, scene?: Nullable<Scene>);
  21772. /**
  21773. * Gets a boolean defining if the target contains position data
  21774. */
  21775. readonly hasPositions: boolean;
  21776. /**
  21777. * Gets a boolean defining if the target contains normal data
  21778. */
  21779. readonly hasNormals: boolean;
  21780. /**
  21781. * Gets a boolean defining if the target contains tangent data
  21782. */
  21783. readonly hasTangents: boolean;
  21784. /**
  21785. * Gets a boolean defining if the target contains texture coordinates data
  21786. */
  21787. readonly hasUVs: boolean;
  21788. /**
  21789. * Affects position data to this target
  21790. * @param data defines the position data to use
  21791. */
  21792. setPositions(data: Nullable<FloatArray>): void;
  21793. /**
  21794. * Gets the position data stored in this target
  21795. * @returns a FloatArray containing the position data (or null if not present)
  21796. */
  21797. getPositions(): Nullable<FloatArray>;
  21798. /**
  21799. * Affects normal data to this target
  21800. * @param data defines the normal data to use
  21801. */
  21802. setNormals(data: Nullable<FloatArray>): void;
  21803. /**
  21804. * Gets the normal data stored in this target
  21805. * @returns a FloatArray containing the normal data (or null if not present)
  21806. */
  21807. getNormals(): Nullable<FloatArray>;
  21808. /**
  21809. * Affects tangent data to this target
  21810. * @param data defines the tangent data to use
  21811. */
  21812. setTangents(data: Nullable<FloatArray>): void;
  21813. /**
  21814. * Gets the tangent data stored in this target
  21815. * @returns a FloatArray containing the tangent data (or null if not present)
  21816. */
  21817. getTangents(): Nullable<FloatArray>;
  21818. /**
  21819. * Affects texture coordinates data to this target
  21820. * @param data defines the texture coordinates data to use
  21821. */
  21822. setUVs(data: Nullable<FloatArray>): void;
  21823. /**
  21824. * Gets the texture coordinates data stored in this target
  21825. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  21826. */
  21827. getUVs(): Nullable<FloatArray>;
  21828. /**
  21829. * Serializes the current target into a Serialization object
  21830. * @returns the serialized object
  21831. */
  21832. serialize(): any;
  21833. /**
  21834. * Returns the string "MorphTarget"
  21835. * @returns "MorphTarget"
  21836. */
  21837. getClassName(): string;
  21838. /**
  21839. * Creates a new target from serialized data
  21840. * @param serializationObject defines the serialized data to use
  21841. * @returns a new MorphTarget
  21842. */
  21843. static Parse(serializationObject: any): MorphTarget;
  21844. /**
  21845. * Creates a MorphTarget from mesh data
  21846. * @param mesh defines the source mesh
  21847. * @param name defines the name to use for the new target
  21848. * @param influence defines the influence to attach to the target
  21849. * @returns a new MorphTarget
  21850. */
  21851. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  21852. }
  21853. }
  21854. declare module BABYLON {
  21855. /**
  21856. * This class is used to deform meshes using morphing between different targets
  21857. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21858. */
  21859. export class MorphTargetManager {
  21860. private _targets;
  21861. private _targetInfluenceChangedObservers;
  21862. private _targetDataLayoutChangedObservers;
  21863. private _activeTargets;
  21864. private _scene;
  21865. private _influences;
  21866. private _supportsNormals;
  21867. private _supportsTangents;
  21868. private _supportsUVs;
  21869. private _vertexCount;
  21870. private _uniqueId;
  21871. private _tempInfluences;
  21872. /**
  21873. * Gets or sets a boolean indicating if normals must be morphed
  21874. */
  21875. enableNormalMorphing: boolean;
  21876. /**
  21877. * Gets or sets a boolean indicating if tangents must be morphed
  21878. */
  21879. enableTangentMorphing: boolean;
  21880. /**
  21881. * Gets or sets a boolean indicating if UV must be morphed
  21882. */
  21883. enableUVMorphing: boolean;
  21884. /**
  21885. * Creates a new MorphTargetManager
  21886. * @param scene defines the current scene
  21887. */
  21888. constructor(scene?: Nullable<Scene>);
  21889. /**
  21890. * Gets the unique ID of this manager
  21891. */
  21892. readonly uniqueId: number;
  21893. /**
  21894. * Gets the number of vertices handled by this manager
  21895. */
  21896. readonly vertexCount: number;
  21897. /**
  21898. * Gets a boolean indicating if this manager supports morphing of normals
  21899. */
  21900. readonly supportsNormals: boolean;
  21901. /**
  21902. * Gets a boolean indicating if this manager supports morphing of tangents
  21903. */
  21904. readonly supportsTangents: boolean;
  21905. /**
  21906. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  21907. */
  21908. readonly supportsUVs: boolean;
  21909. /**
  21910. * Gets the number of targets stored in this manager
  21911. */
  21912. readonly numTargets: number;
  21913. /**
  21914. * Gets the number of influencers (ie. the number of targets with influences > 0)
  21915. */
  21916. readonly numInfluencers: number;
  21917. /**
  21918. * Gets the list of influences (one per target)
  21919. */
  21920. readonly influences: Float32Array;
  21921. /**
  21922. * Gets the active target at specified index. An active target is a target with an influence > 0
  21923. * @param index defines the index to check
  21924. * @returns the requested target
  21925. */
  21926. getActiveTarget(index: number): MorphTarget;
  21927. /**
  21928. * Gets the target at specified index
  21929. * @param index defines the index to check
  21930. * @returns the requested target
  21931. */
  21932. getTarget(index: number): MorphTarget;
  21933. /**
  21934. * Add a new target to this manager
  21935. * @param target defines the target to add
  21936. */
  21937. addTarget(target: MorphTarget): void;
  21938. /**
  21939. * Removes a target from the manager
  21940. * @param target defines the target to remove
  21941. */
  21942. removeTarget(target: MorphTarget): void;
  21943. /**
  21944. * Serializes the current manager into a Serialization object
  21945. * @returns the serialized object
  21946. */
  21947. serialize(): any;
  21948. private _syncActiveTargets;
  21949. /**
  21950. * Syncrhonize the targets with all the meshes using this morph target manager
  21951. */
  21952. synchronize(): void;
  21953. /**
  21954. * Creates a new MorphTargetManager from serialized data
  21955. * @param serializationObject defines the serialized data
  21956. * @param scene defines the hosting scene
  21957. * @returns the new MorphTargetManager
  21958. */
  21959. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  21960. }
  21961. }
  21962. declare module BABYLON {
  21963. /**
  21964. * Class used to represent a specific level of detail of a mesh
  21965. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21966. */
  21967. export class MeshLODLevel {
  21968. /** Defines the distance where this level should start being displayed */
  21969. distance: number;
  21970. /** Defines the mesh to use to render this level */
  21971. mesh: Nullable<Mesh>;
  21972. /**
  21973. * Creates a new LOD level
  21974. * @param distance defines the distance where this level should star being displayed
  21975. * @param mesh defines the mesh to use to render this level
  21976. */
  21977. constructor(
  21978. /** Defines the distance where this level should start being displayed */
  21979. distance: number,
  21980. /** Defines the mesh to use to render this level */
  21981. mesh: Nullable<Mesh>);
  21982. }
  21983. }
  21984. declare module BABYLON {
  21985. /**
  21986. * Mesh representing the gorund
  21987. */
  21988. export class GroundMesh extends Mesh {
  21989. /** If octree should be generated */
  21990. generateOctree: boolean;
  21991. private _heightQuads;
  21992. /** @hidden */ private _subdivisionsX: number;
  21993. /** @hidden */ private _subdivisionsY: number;
  21994. /** @hidden */ private _width: number;
  21995. /** @hidden */ private _height: number;
  21996. /** @hidden */ private _minX: number;
  21997. /** @hidden */ private _maxX: number;
  21998. /** @hidden */ private _minZ: number;
  21999. /** @hidden */ private _maxZ: number;
  22000. constructor(name: string, scene: Scene);
  22001. /**
  22002. * "GroundMesh"
  22003. * @returns "GroundMesh"
  22004. */
  22005. getClassName(): string;
  22006. /**
  22007. * The minimum of x and y subdivisions
  22008. */
  22009. readonly subdivisions: number;
  22010. /**
  22011. * X subdivisions
  22012. */
  22013. readonly subdivisionsX: number;
  22014. /**
  22015. * Y subdivisions
  22016. */
  22017. readonly subdivisionsY: number;
  22018. /**
  22019. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22020. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22021. * @param chunksCount the number of subdivisions for x and y
  22022. * @param octreeBlocksSize (Default: 32)
  22023. */
  22024. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22025. /**
  22026. * Returns a height (y) value in the Worl system :
  22027. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22028. * @param x x coordinate
  22029. * @param z z coordinate
  22030. * @returns the ground y position if (x, z) are outside the ground surface.
  22031. */
  22032. getHeightAtCoordinates(x: number, z: number): number;
  22033. /**
  22034. * Returns a normalized vector (Vector3) orthogonal to the ground
  22035. * at the ground coordinates (x, z) expressed in the World system.
  22036. * @param x x coordinate
  22037. * @param z z coordinate
  22038. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22039. */
  22040. getNormalAtCoordinates(x: number, z: number): Vector3;
  22041. /**
  22042. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22043. * at the ground coordinates (x, z) expressed in the World system.
  22044. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22045. * @param x x coordinate
  22046. * @param z z coordinate
  22047. * @param ref vector to store the result
  22048. * @returns the GroundMesh.
  22049. */
  22050. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22051. /**
  22052. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22053. * if the ground has been updated.
  22054. * This can be used in the render loop.
  22055. * @returns the GroundMesh.
  22056. */
  22057. updateCoordinateHeights(): GroundMesh;
  22058. private _getFacetAt;
  22059. private _initHeightQuads;
  22060. private _computeHeightQuads;
  22061. /**
  22062. * Serializes this ground mesh
  22063. * @param serializationObject object to write serialization to
  22064. */
  22065. serialize(serializationObject: any): void;
  22066. /**
  22067. * Parses a serialized ground mesh
  22068. * @param parsedMesh the serialized mesh
  22069. * @param scene the scene to create the ground mesh in
  22070. * @returns the created ground mesh
  22071. */
  22072. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22073. }
  22074. }
  22075. declare module BABYLON {
  22076. /**
  22077. * Interface for Physics-Joint data
  22078. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22079. */
  22080. export interface PhysicsJointData {
  22081. /**
  22082. * The main pivot of the joint
  22083. */
  22084. mainPivot?: Vector3;
  22085. /**
  22086. * The connected pivot of the joint
  22087. */
  22088. connectedPivot?: Vector3;
  22089. /**
  22090. * The main axis of the joint
  22091. */
  22092. mainAxis?: Vector3;
  22093. /**
  22094. * The connected axis of the joint
  22095. */
  22096. connectedAxis?: Vector3;
  22097. /**
  22098. * The collision of the joint
  22099. */
  22100. collision?: boolean;
  22101. /**
  22102. * Native Oimo/Cannon/Energy data
  22103. */
  22104. nativeParams?: any;
  22105. }
  22106. /**
  22107. * This is a holder class for the physics joint created by the physics plugin
  22108. * It holds a set of functions to control the underlying joint
  22109. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22110. */
  22111. export class PhysicsJoint {
  22112. /**
  22113. * The type of the physics joint
  22114. */
  22115. type: number;
  22116. /**
  22117. * The data for the physics joint
  22118. */
  22119. jointData: PhysicsJointData;
  22120. private _physicsJoint;
  22121. protected _physicsPlugin: IPhysicsEnginePlugin;
  22122. /**
  22123. * Initializes the physics joint
  22124. * @param type The type of the physics joint
  22125. * @param jointData The data for the physics joint
  22126. */
  22127. constructor(
  22128. /**
  22129. * The type of the physics joint
  22130. */
  22131. type: number,
  22132. /**
  22133. * The data for the physics joint
  22134. */
  22135. jointData: PhysicsJointData);
  22136. /**
  22137. * Gets the physics joint
  22138. */
  22139. /**
  22140. * Sets the physics joint
  22141. */
  22142. physicsJoint: any;
  22143. /**
  22144. * Sets the physics plugin
  22145. */
  22146. physicsPlugin: IPhysicsEnginePlugin;
  22147. /**
  22148. * Execute a function that is physics-plugin specific.
  22149. * @param {Function} func the function that will be executed.
  22150. * It accepts two parameters: the physics world and the physics joint
  22151. */
  22152. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22153. /**
  22154. * Distance-Joint type
  22155. */
  22156. static DistanceJoint: number;
  22157. /**
  22158. * Hinge-Joint type
  22159. */
  22160. static HingeJoint: number;
  22161. /**
  22162. * Ball-and-Socket joint type
  22163. */
  22164. static BallAndSocketJoint: number;
  22165. /**
  22166. * Wheel-Joint type
  22167. */
  22168. static WheelJoint: number;
  22169. /**
  22170. * Slider-Joint type
  22171. */
  22172. static SliderJoint: number;
  22173. /**
  22174. * Prismatic-Joint type
  22175. */
  22176. static PrismaticJoint: number;
  22177. /**
  22178. * Universal-Joint type
  22179. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22180. */
  22181. static UniversalJoint: number;
  22182. /**
  22183. * Hinge-Joint 2 type
  22184. */
  22185. static Hinge2Joint: number;
  22186. /**
  22187. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22188. */
  22189. static PointToPointJoint: number;
  22190. /**
  22191. * Spring-Joint type
  22192. */
  22193. static SpringJoint: number;
  22194. /**
  22195. * Lock-Joint type
  22196. */
  22197. static LockJoint: number;
  22198. }
  22199. /**
  22200. * A class representing a physics distance joint
  22201. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22202. */
  22203. export class DistanceJoint extends PhysicsJoint {
  22204. /**
  22205. *
  22206. * @param jointData The data for the Distance-Joint
  22207. */
  22208. constructor(jointData: DistanceJointData);
  22209. /**
  22210. * Update the predefined distance.
  22211. * @param maxDistance The maximum preferred distance
  22212. * @param minDistance The minimum preferred distance
  22213. */
  22214. updateDistance(maxDistance: number, minDistance?: number): void;
  22215. }
  22216. /**
  22217. * Represents a Motor-Enabled Joint
  22218. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22219. */
  22220. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22221. /**
  22222. * Initializes the Motor-Enabled Joint
  22223. * @param type The type of the joint
  22224. * @param jointData The physica joint data for the joint
  22225. */
  22226. constructor(type: number, jointData: PhysicsJointData);
  22227. /**
  22228. * Set the motor values.
  22229. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22230. * @param force the force to apply
  22231. * @param maxForce max force for this motor.
  22232. */
  22233. setMotor(force?: number, maxForce?: number): void;
  22234. /**
  22235. * Set the motor's limits.
  22236. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22237. * @param upperLimit The upper limit of the motor
  22238. * @param lowerLimit The lower limit of the motor
  22239. */
  22240. setLimit(upperLimit: number, lowerLimit?: number): void;
  22241. }
  22242. /**
  22243. * This class represents a single physics Hinge-Joint
  22244. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22245. */
  22246. export class HingeJoint extends MotorEnabledJoint {
  22247. /**
  22248. * Initializes the Hinge-Joint
  22249. * @param jointData The joint data for the Hinge-Joint
  22250. */
  22251. constructor(jointData: PhysicsJointData);
  22252. /**
  22253. * Set the motor values.
  22254. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22255. * @param {number} force the force to apply
  22256. * @param {number} maxForce max force for this motor.
  22257. */
  22258. setMotor(force?: number, maxForce?: number): void;
  22259. /**
  22260. * Set the motor's limits.
  22261. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22262. * @param upperLimit The upper limit of the motor
  22263. * @param lowerLimit The lower limit of the motor
  22264. */
  22265. setLimit(upperLimit: number, lowerLimit?: number): void;
  22266. }
  22267. /**
  22268. * This class represents a dual hinge physics joint (same as wheel joint)
  22269. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22270. */
  22271. export class Hinge2Joint extends MotorEnabledJoint {
  22272. /**
  22273. * Initializes the Hinge2-Joint
  22274. * @param jointData The joint data for the Hinge2-Joint
  22275. */
  22276. constructor(jointData: PhysicsJointData);
  22277. /**
  22278. * Set the motor values.
  22279. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22280. * @param {number} targetSpeed the speed the motor is to reach
  22281. * @param {number} maxForce max force for this motor.
  22282. * @param {motorIndex} the motor's index, 0 or 1.
  22283. */
  22284. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22285. /**
  22286. * Set the motor limits.
  22287. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22288. * @param {number} upperLimit the upper limit
  22289. * @param {number} lowerLimit lower limit
  22290. * @param {motorIndex} the motor's index, 0 or 1.
  22291. */
  22292. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22293. }
  22294. /**
  22295. * Interface for a motor enabled joint
  22296. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22297. */
  22298. export interface IMotorEnabledJoint {
  22299. /**
  22300. * Physics joint
  22301. */
  22302. physicsJoint: any;
  22303. /**
  22304. * Sets the motor of the motor-enabled joint
  22305. * @param force The force of the motor
  22306. * @param maxForce The maximum force of the motor
  22307. * @param motorIndex The index of the motor
  22308. */
  22309. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22310. /**
  22311. * Sets the limit of the motor
  22312. * @param upperLimit The upper limit of the motor
  22313. * @param lowerLimit The lower limit of the motor
  22314. * @param motorIndex The index of the motor
  22315. */
  22316. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22317. }
  22318. /**
  22319. * Joint data for a Distance-Joint
  22320. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22321. */
  22322. export interface DistanceJointData extends PhysicsJointData {
  22323. /**
  22324. * Max distance the 2 joint objects can be apart
  22325. */
  22326. maxDistance: number;
  22327. }
  22328. /**
  22329. * Joint data from a spring joint
  22330. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22331. */
  22332. export interface SpringJointData extends PhysicsJointData {
  22333. /**
  22334. * Length of the spring
  22335. */
  22336. length: number;
  22337. /**
  22338. * Stiffness of the spring
  22339. */
  22340. stiffness: number;
  22341. /**
  22342. * Damping of the spring
  22343. */
  22344. damping: number;
  22345. /** this callback will be called when applying the force to the impostors. */
  22346. forceApplicationCallback: () => void;
  22347. }
  22348. }
  22349. declare module BABYLON {
  22350. /**
  22351. * Holds the data for the raycast result
  22352. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22353. */
  22354. export class PhysicsRaycastResult {
  22355. private _hasHit;
  22356. private _hitDistance;
  22357. private _hitNormalWorld;
  22358. private _hitPointWorld;
  22359. private _rayFromWorld;
  22360. private _rayToWorld;
  22361. /**
  22362. * Gets if there was a hit
  22363. */
  22364. readonly hasHit: boolean;
  22365. /**
  22366. * Gets the distance from the hit
  22367. */
  22368. readonly hitDistance: number;
  22369. /**
  22370. * Gets the hit normal/direction in the world
  22371. */
  22372. readonly hitNormalWorld: Vector3;
  22373. /**
  22374. * Gets the hit point in the world
  22375. */
  22376. readonly hitPointWorld: Vector3;
  22377. /**
  22378. * Gets the ray "start point" of the ray in the world
  22379. */
  22380. readonly rayFromWorld: Vector3;
  22381. /**
  22382. * Gets the ray "end point" of the ray in the world
  22383. */
  22384. readonly rayToWorld: Vector3;
  22385. /**
  22386. * Sets the hit data (normal & point in world space)
  22387. * @param hitNormalWorld defines the normal in world space
  22388. * @param hitPointWorld defines the point in world space
  22389. */
  22390. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22391. /**
  22392. * Sets the distance from the start point to the hit point
  22393. * @param distance
  22394. */
  22395. setHitDistance(distance: number): void;
  22396. /**
  22397. * Calculates the distance manually
  22398. */
  22399. calculateHitDistance(): void;
  22400. /**
  22401. * Resets all the values to default
  22402. * @param from The from point on world space
  22403. * @param to The to point on world space
  22404. */
  22405. reset(from?: Vector3, to?: Vector3): void;
  22406. }
  22407. /**
  22408. * Interface for the size containing width and height
  22409. */
  22410. interface IXYZ {
  22411. /**
  22412. * X
  22413. */
  22414. x: number;
  22415. /**
  22416. * Y
  22417. */
  22418. y: number;
  22419. /**
  22420. * Z
  22421. */
  22422. z: number;
  22423. }
  22424. }
  22425. declare module BABYLON {
  22426. /**
  22427. * Interface used to describe a physics joint
  22428. */
  22429. export interface PhysicsImpostorJoint {
  22430. /** Defines the main impostor to which the joint is linked */
  22431. mainImpostor: PhysicsImpostor;
  22432. /** Defines the impostor that is connected to the main impostor using this joint */
  22433. connectedImpostor: PhysicsImpostor;
  22434. /** Defines the joint itself */
  22435. joint: PhysicsJoint;
  22436. }
  22437. /** @hidden */
  22438. export interface IPhysicsEnginePlugin {
  22439. world: any;
  22440. name: string;
  22441. setGravity(gravity: Vector3): void;
  22442. setTimeStep(timeStep: number): void;
  22443. getTimeStep(): number;
  22444. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22445. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22446. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22447. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22448. removePhysicsBody(impostor: PhysicsImpostor): void;
  22449. generateJoint(joint: PhysicsImpostorJoint): void;
  22450. removeJoint(joint: PhysicsImpostorJoint): void;
  22451. isSupported(): boolean;
  22452. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22453. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22454. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22455. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22456. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22457. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22458. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22459. getBodyMass(impostor: PhysicsImpostor): number;
  22460. getBodyFriction(impostor: PhysicsImpostor): number;
  22461. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22462. getBodyRestitution(impostor: PhysicsImpostor): number;
  22463. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22464. getBodyPressure?(impostor: PhysicsImpostor): number;
  22465. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22466. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22467. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22468. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22469. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22470. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22471. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22472. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22473. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22474. sleepBody(impostor: PhysicsImpostor): void;
  22475. wakeUpBody(impostor: PhysicsImpostor): void;
  22476. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22477. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22478. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22479. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22480. getRadius(impostor: PhysicsImpostor): number;
  22481. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22482. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22483. dispose(): void;
  22484. }
  22485. /**
  22486. * Interface used to define a physics engine
  22487. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22488. */
  22489. export interface IPhysicsEngine {
  22490. /**
  22491. * Gets the gravity vector used by the simulation
  22492. */
  22493. gravity: Vector3;
  22494. /**
  22495. * Sets the gravity vector used by the simulation
  22496. * @param gravity defines the gravity vector to use
  22497. */
  22498. setGravity(gravity: Vector3): void;
  22499. /**
  22500. * Set the time step of the physics engine.
  22501. * Default is 1/60.
  22502. * To slow it down, enter 1/600 for example.
  22503. * To speed it up, 1/30
  22504. * @param newTimeStep the new timestep to apply to this world.
  22505. */
  22506. setTimeStep(newTimeStep: number): void;
  22507. /**
  22508. * Get the time step of the physics engine.
  22509. * @returns the current time step
  22510. */
  22511. getTimeStep(): number;
  22512. /**
  22513. * Release all resources
  22514. */
  22515. dispose(): void;
  22516. /**
  22517. * Gets the name of the current physics plugin
  22518. * @returns the name of the plugin
  22519. */
  22520. getPhysicsPluginName(): string;
  22521. /**
  22522. * Adding a new impostor for the impostor tracking.
  22523. * This will be done by the impostor itself.
  22524. * @param impostor the impostor to add
  22525. */
  22526. addImpostor(impostor: PhysicsImpostor): void;
  22527. /**
  22528. * Remove an impostor from the engine.
  22529. * This impostor and its mesh will not longer be updated by the physics engine.
  22530. * @param impostor the impostor to remove
  22531. */
  22532. removeImpostor(impostor: PhysicsImpostor): void;
  22533. /**
  22534. * Add a joint to the physics engine
  22535. * @param mainImpostor defines the main impostor to which the joint is added.
  22536. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22537. * @param joint defines the joint that will connect both impostors.
  22538. */
  22539. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22540. /**
  22541. * Removes a joint from the simulation
  22542. * @param mainImpostor defines the impostor used with the joint
  22543. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22544. * @param joint defines the joint to remove
  22545. */
  22546. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22547. /**
  22548. * Gets the current plugin used to run the simulation
  22549. * @returns current plugin
  22550. */
  22551. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22552. /**
  22553. * Gets the list of physic impostors
  22554. * @returns an array of PhysicsImpostor
  22555. */
  22556. getImpostors(): Array<PhysicsImpostor>;
  22557. /**
  22558. * Gets the impostor for a physics enabled object
  22559. * @param object defines the object impersonated by the impostor
  22560. * @returns the PhysicsImpostor or null if not found
  22561. */
  22562. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22563. /**
  22564. * Gets the impostor for a physics body object
  22565. * @param body defines physics body used by the impostor
  22566. * @returns the PhysicsImpostor or null if not found
  22567. */
  22568. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22569. /**
  22570. * Does a raycast in the physics world
  22571. * @param from when should the ray start?
  22572. * @param to when should the ray end?
  22573. * @returns PhysicsRaycastResult
  22574. */
  22575. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22576. /**
  22577. * Called by the scene. No need to call it.
  22578. * @param delta defines the timespam between frames
  22579. */ private _step(delta: number): void;
  22580. }
  22581. }
  22582. declare module BABYLON {
  22583. /**
  22584. * The interface for the physics imposter parameters
  22585. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22586. */
  22587. export interface PhysicsImpostorParameters {
  22588. /**
  22589. * The mass of the physics imposter
  22590. */
  22591. mass: number;
  22592. /**
  22593. * The friction of the physics imposter
  22594. */
  22595. friction?: number;
  22596. /**
  22597. * The coefficient of restitution of the physics imposter
  22598. */
  22599. restitution?: number;
  22600. /**
  22601. * The native options of the physics imposter
  22602. */
  22603. nativeOptions?: any;
  22604. /**
  22605. * Specifies if the parent should be ignored
  22606. */
  22607. ignoreParent?: boolean;
  22608. /**
  22609. * Specifies if bi-directional transformations should be disabled
  22610. */
  22611. disableBidirectionalTransformation?: boolean;
  22612. /**
  22613. * The pressure inside the physics imposter, soft object only
  22614. */
  22615. pressure?: number;
  22616. /**
  22617. * The stiffness the physics imposter, soft object only
  22618. */
  22619. stiffness?: number;
  22620. /**
  22621. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22622. */
  22623. velocityIterations?: number;
  22624. /**
  22625. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22626. */
  22627. positionIterations?: number;
  22628. /**
  22629. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22630. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22631. * Add to fix multiple points
  22632. */
  22633. fixedPoints?: number;
  22634. /**
  22635. * The collision margin around a soft object
  22636. */
  22637. margin?: number;
  22638. /**
  22639. * The collision margin around a soft object
  22640. */
  22641. damping?: number;
  22642. /**
  22643. * The path for a rope based on an extrusion
  22644. */
  22645. path?: any;
  22646. /**
  22647. * The shape of an extrusion used for a rope based on an extrusion
  22648. */
  22649. shape?: any;
  22650. }
  22651. /**
  22652. * Interface for a physics-enabled object
  22653. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22654. */
  22655. export interface IPhysicsEnabledObject {
  22656. /**
  22657. * The position of the physics-enabled object
  22658. */
  22659. position: Vector3;
  22660. /**
  22661. * The rotation of the physics-enabled object
  22662. */
  22663. rotationQuaternion: Nullable<Quaternion>;
  22664. /**
  22665. * The scale of the physics-enabled object
  22666. */
  22667. scaling: Vector3;
  22668. /**
  22669. * The rotation of the physics-enabled object
  22670. */
  22671. rotation?: Vector3;
  22672. /**
  22673. * The parent of the physics-enabled object
  22674. */
  22675. parent?: any;
  22676. /**
  22677. * The bounding info of the physics-enabled object
  22678. * @returns The bounding info of the physics-enabled object
  22679. */
  22680. getBoundingInfo(): BoundingInfo;
  22681. /**
  22682. * Computes the world matrix
  22683. * @param force Specifies if the world matrix should be computed by force
  22684. * @returns A world matrix
  22685. */
  22686. computeWorldMatrix(force: boolean): Matrix;
  22687. /**
  22688. * Gets the world matrix
  22689. * @returns A world matrix
  22690. */
  22691. getWorldMatrix?(): Matrix;
  22692. /**
  22693. * Gets the child meshes
  22694. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  22695. * @returns An array of abstract meshes
  22696. */
  22697. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  22698. /**
  22699. * Gets the vertex data
  22700. * @param kind The type of vertex data
  22701. * @returns A nullable array of numbers, or a float32 array
  22702. */
  22703. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  22704. /**
  22705. * Gets the indices from the mesh
  22706. * @returns A nullable array of index arrays
  22707. */
  22708. getIndices?(): Nullable<IndicesArray>;
  22709. /**
  22710. * Gets the scene from the mesh
  22711. * @returns the indices array or null
  22712. */
  22713. getScene?(): Scene;
  22714. /**
  22715. * Gets the absolute position from the mesh
  22716. * @returns the absolute position
  22717. */
  22718. getAbsolutePosition(): Vector3;
  22719. /**
  22720. * Gets the absolute pivot point from the mesh
  22721. * @returns the absolute pivot point
  22722. */
  22723. getAbsolutePivotPoint(): Vector3;
  22724. /**
  22725. * Rotates the mesh
  22726. * @param axis The axis of rotation
  22727. * @param amount The amount of rotation
  22728. * @param space The space of the rotation
  22729. * @returns The rotation transform node
  22730. */
  22731. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  22732. /**
  22733. * Translates the mesh
  22734. * @param axis The axis of translation
  22735. * @param distance The distance of translation
  22736. * @param space The space of the translation
  22737. * @returns The transform node
  22738. */
  22739. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  22740. /**
  22741. * Sets the absolute position of the mesh
  22742. * @param absolutePosition The absolute position of the mesh
  22743. * @returns The transform node
  22744. */
  22745. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  22746. /**
  22747. * Gets the class name of the mesh
  22748. * @returns The class name
  22749. */
  22750. getClassName(): string;
  22751. }
  22752. /**
  22753. * Represents a physics imposter
  22754. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22755. */
  22756. export class PhysicsImpostor {
  22757. /**
  22758. * The physics-enabled object used as the physics imposter
  22759. */
  22760. object: IPhysicsEnabledObject;
  22761. /**
  22762. * The type of the physics imposter
  22763. */
  22764. type: number;
  22765. private _options;
  22766. private _scene?;
  22767. /**
  22768. * The default object size of the imposter
  22769. */
  22770. static DEFAULT_OBJECT_SIZE: Vector3;
  22771. /**
  22772. * The identity quaternion of the imposter
  22773. */
  22774. static IDENTITY_QUATERNION: Quaternion;
  22775. /** @hidden */ private _pluginData: any;
  22776. private _physicsEngine;
  22777. private _physicsBody;
  22778. private _bodyUpdateRequired;
  22779. private _onBeforePhysicsStepCallbacks;
  22780. private _onAfterPhysicsStepCallbacks;
  22781. /** @hidden */ private _onPhysicsCollideCallbacks: Array<{
  22782. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  22783. otherImpostors: Array<PhysicsImpostor>;
  22784. }>;
  22785. private _deltaPosition;
  22786. private _deltaRotation;
  22787. private _deltaRotationConjugated;
  22788. /** @hidden */ private _isFromLine: boolean;
  22789. private _parent;
  22790. private _isDisposed;
  22791. private static _tmpVecs;
  22792. private static _tmpQuat;
  22793. /**
  22794. * Specifies if the physics imposter is disposed
  22795. */
  22796. readonly isDisposed: boolean;
  22797. /**
  22798. * Gets the mass of the physics imposter
  22799. */
  22800. mass: number;
  22801. /**
  22802. * Gets the coefficient of friction
  22803. */
  22804. /**
  22805. * Sets the coefficient of friction
  22806. */
  22807. friction: number;
  22808. /**
  22809. * Gets the coefficient of restitution
  22810. */
  22811. /**
  22812. * Sets the coefficient of restitution
  22813. */
  22814. restitution: number;
  22815. /**
  22816. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  22817. */
  22818. /**
  22819. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  22820. */
  22821. pressure: number;
  22822. /**
  22823. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22824. */
  22825. /**
  22826. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22827. */
  22828. stiffness: number;
  22829. /**
  22830. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22831. */
  22832. /**
  22833. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22834. */
  22835. velocityIterations: number;
  22836. /**
  22837. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22838. */
  22839. /**
  22840. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22841. */
  22842. positionIterations: number;
  22843. /**
  22844. * The unique id of the physics imposter
  22845. * set by the physics engine when adding this impostor to the array
  22846. */
  22847. uniqueId: number;
  22848. /**
  22849. * @hidden
  22850. */
  22851. soft: boolean;
  22852. /**
  22853. * @hidden
  22854. */
  22855. segments: number;
  22856. private _joints;
  22857. /**
  22858. * Initializes the physics imposter
  22859. * @param object The physics-enabled object used as the physics imposter
  22860. * @param type The type of the physics imposter
  22861. * @param _options The options for the physics imposter
  22862. * @param _scene The Babylon scene
  22863. */
  22864. constructor(
  22865. /**
  22866. * The physics-enabled object used as the physics imposter
  22867. */
  22868. object: IPhysicsEnabledObject,
  22869. /**
  22870. * The type of the physics imposter
  22871. */
  22872. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  22873. /**
  22874. * This function will completly initialize this impostor.
  22875. * It will create a new body - but only if this mesh has no parent.
  22876. * If it has, this impostor will not be used other than to define the impostor
  22877. * of the child mesh.
  22878. * @hidden
  22879. */ private _init(): void;
  22880. private _getPhysicsParent;
  22881. /**
  22882. * Should a new body be generated.
  22883. * @returns boolean specifying if body initialization is required
  22884. */
  22885. isBodyInitRequired(): boolean;
  22886. /**
  22887. * Sets the updated scaling
  22888. * @param updated Specifies if the scaling is updated
  22889. */
  22890. setScalingUpdated(): void;
  22891. /**
  22892. * Force a regeneration of this or the parent's impostor's body.
  22893. * Use under cautious - This will remove all joints already implemented.
  22894. */
  22895. forceUpdate(): void;
  22896. /**
  22897. * Gets the body that holds this impostor. Either its own, or its parent.
  22898. */
  22899. /**
  22900. * Set the physics body. Used mainly by the physics engine/plugin
  22901. */
  22902. physicsBody: any;
  22903. /**
  22904. * Get the parent of the physics imposter
  22905. * @returns Physics imposter or null
  22906. */
  22907. /**
  22908. * Sets the parent of the physics imposter
  22909. */
  22910. parent: Nullable<PhysicsImpostor>;
  22911. /**
  22912. * Resets the update flags
  22913. */
  22914. resetUpdateFlags(): void;
  22915. /**
  22916. * Gets the object extend size
  22917. * @returns the object extend size
  22918. */
  22919. getObjectExtendSize(): Vector3;
  22920. /**
  22921. * Gets the object center
  22922. * @returns The object center
  22923. */
  22924. getObjectCenter(): Vector3;
  22925. /**
  22926. * Get a specific parametes from the options parameter
  22927. * @param paramName The object parameter name
  22928. * @returns The object parameter
  22929. */
  22930. getParam(paramName: string): any;
  22931. /**
  22932. * Sets a specific parameter in the options given to the physics plugin
  22933. * @param paramName The parameter name
  22934. * @param value The value of the parameter
  22935. */
  22936. setParam(paramName: string, value: number): void;
  22937. /**
  22938. * Specifically change the body's mass option. Won't recreate the physics body object
  22939. * @param mass The mass of the physics imposter
  22940. */
  22941. setMass(mass: number): void;
  22942. /**
  22943. * Gets the linear velocity
  22944. * @returns linear velocity or null
  22945. */
  22946. getLinearVelocity(): Nullable<Vector3>;
  22947. /**
  22948. * Sets the linear velocity
  22949. * @param velocity linear velocity or null
  22950. */
  22951. setLinearVelocity(velocity: Nullable<Vector3>): void;
  22952. /**
  22953. * Gets the angular velocity
  22954. * @returns angular velocity or null
  22955. */
  22956. getAngularVelocity(): Nullable<Vector3>;
  22957. /**
  22958. * Sets the angular velocity
  22959. * @param velocity The velocity or null
  22960. */
  22961. setAngularVelocity(velocity: Nullable<Vector3>): void;
  22962. /**
  22963. * Execute a function with the physics plugin native code
  22964. * Provide a function the will have two variables - the world object and the physics body object
  22965. * @param func The function to execute with the physics plugin native code
  22966. */
  22967. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  22968. /**
  22969. * Register a function that will be executed before the physics world is stepping forward
  22970. * @param func The function to execute before the physics world is stepped forward
  22971. */
  22972. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22973. /**
  22974. * Unregister a function that will be executed before the physics world is stepping forward
  22975. * @param func The function to execute before the physics world is stepped forward
  22976. */
  22977. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22978. /**
  22979. * Register a function that will be executed after the physics step
  22980. * @param func The function to execute after physics step
  22981. */
  22982. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22983. /**
  22984. * Unregisters a function that will be executed after the physics step
  22985. * @param func The function to execute after physics step
  22986. */
  22987. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22988. /**
  22989. * register a function that will be executed when this impostor collides against a different body
  22990. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  22991. * @param func Callback that is executed on collision
  22992. */
  22993. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  22994. /**
  22995. * Unregisters the physics imposter on contact
  22996. * @param collideAgainst The physics object to collide against
  22997. * @param func Callback to execute on collision
  22998. */
  22999. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23000. private _tmpQuat;
  23001. private _tmpQuat2;
  23002. /**
  23003. * Get the parent rotation
  23004. * @returns The parent rotation
  23005. */
  23006. getParentsRotation(): Quaternion;
  23007. /**
  23008. * this function is executed by the physics engine.
  23009. */
  23010. beforeStep: () => void;
  23011. /**
  23012. * this function is executed by the physics engine
  23013. */
  23014. afterStep: () => void;
  23015. /**
  23016. * Legacy collision detection event support
  23017. */
  23018. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23019. /**
  23020. * event and body object due to cannon's event-based architecture.
  23021. */
  23022. onCollide: (e: {
  23023. body: any;
  23024. }) => void;
  23025. /**
  23026. * Apply a force
  23027. * @param force The force to apply
  23028. * @param contactPoint The contact point for the force
  23029. * @returns The physics imposter
  23030. */
  23031. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23032. /**
  23033. * Apply an impulse
  23034. * @param force The impulse force
  23035. * @param contactPoint The contact point for the impulse force
  23036. * @returns The physics imposter
  23037. */
  23038. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23039. /**
  23040. * A help function to create a joint
  23041. * @param otherImpostor A physics imposter used to create a joint
  23042. * @param jointType The type of joint
  23043. * @param jointData The data for the joint
  23044. * @returns The physics imposter
  23045. */
  23046. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23047. /**
  23048. * Add a joint to this impostor with a different impostor
  23049. * @param otherImpostor A physics imposter used to add a joint
  23050. * @param joint The joint to add
  23051. * @returns The physics imposter
  23052. */
  23053. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23054. /**
  23055. * Add an anchor to a cloth impostor
  23056. * @param otherImpostor rigid impostor to anchor to
  23057. * @param width ratio across width from 0 to 1
  23058. * @param height ratio up height from 0 to 1
  23059. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23060. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23061. * @returns impostor the soft imposter
  23062. */
  23063. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23064. /**
  23065. * Add a hook to a rope impostor
  23066. * @param otherImpostor rigid impostor to anchor to
  23067. * @param length ratio across rope from 0 to 1
  23068. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23069. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23070. * @returns impostor the rope imposter
  23071. */
  23072. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23073. /**
  23074. * Will keep this body still, in a sleep mode.
  23075. * @returns the physics imposter
  23076. */
  23077. sleep(): PhysicsImpostor;
  23078. /**
  23079. * Wake the body up.
  23080. * @returns The physics imposter
  23081. */
  23082. wakeUp(): PhysicsImpostor;
  23083. /**
  23084. * Clones the physics imposter
  23085. * @param newObject The physics imposter clones to this physics-enabled object
  23086. * @returns A nullable physics imposter
  23087. */
  23088. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23089. /**
  23090. * Disposes the physics imposter
  23091. */
  23092. dispose(): void;
  23093. /**
  23094. * Sets the delta position
  23095. * @param position The delta position amount
  23096. */
  23097. setDeltaPosition(position: Vector3): void;
  23098. /**
  23099. * Sets the delta rotation
  23100. * @param rotation The delta rotation amount
  23101. */
  23102. setDeltaRotation(rotation: Quaternion): void;
  23103. /**
  23104. * Gets the box size of the physics imposter and stores the result in the input parameter
  23105. * @param result Stores the box size
  23106. * @returns The physics imposter
  23107. */
  23108. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23109. /**
  23110. * Gets the radius of the physics imposter
  23111. * @returns Radius of the physics imposter
  23112. */
  23113. getRadius(): number;
  23114. /**
  23115. * Sync a bone with this impostor
  23116. * @param bone The bone to sync to the impostor.
  23117. * @param boneMesh The mesh that the bone is influencing.
  23118. * @param jointPivot The pivot of the joint / bone in local space.
  23119. * @param distToJoint Optional distance from the impostor to the joint.
  23120. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23121. */
  23122. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23123. /**
  23124. * Sync impostor to a bone
  23125. * @param bone The bone that the impostor will be synced to.
  23126. * @param boneMesh The mesh that the bone is influencing.
  23127. * @param jointPivot The pivot of the joint / bone in local space.
  23128. * @param distToJoint Optional distance from the impostor to the joint.
  23129. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23130. * @param boneAxis Optional vector3 axis the bone is aligned with
  23131. */
  23132. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23133. /**
  23134. * No-Imposter type
  23135. */
  23136. static NoImpostor: number;
  23137. /**
  23138. * Sphere-Imposter type
  23139. */
  23140. static SphereImpostor: number;
  23141. /**
  23142. * Box-Imposter type
  23143. */
  23144. static BoxImpostor: number;
  23145. /**
  23146. * Plane-Imposter type
  23147. */
  23148. static PlaneImpostor: number;
  23149. /**
  23150. * Mesh-imposter type
  23151. */
  23152. static MeshImpostor: number;
  23153. /**
  23154. * Capsule-Impostor type (Ammo.js plugin only)
  23155. */
  23156. static CapsuleImpostor: number;
  23157. /**
  23158. * Cylinder-Imposter type
  23159. */
  23160. static CylinderImpostor: number;
  23161. /**
  23162. * Particle-Imposter type
  23163. */
  23164. static ParticleImpostor: number;
  23165. /**
  23166. * Heightmap-Imposter type
  23167. */
  23168. static HeightmapImpostor: number;
  23169. /**
  23170. * ConvexHull-Impostor type (Ammo.js plugin only)
  23171. */
  23172. static ConvexHullImpostor: number;
  23173. /**
  23174. * Rope-Imposter type
  23175. */
  23176. static RopeImpostor: number;
  23177. /**
  23178. * Cloth-Imposter type
  23179. */
  23180. static ClothImpostor: number;
  23181. /**
  23182. * Softbody-Imposter type
  23183. */
  23184. static SoftbodyImpostor: number;
  23185. }
  23186. }
  23187. declare module BABYLON {
  23188. /**
  23189. * @hidden
  23190. **/
  23191. export class _CreationDataStorage {
  23192. closePath?: boolean;
  23193. closeArray?: boolean;
  23194. idx: number[];
  23195. dashSize: number;
  23196. gapSize: number;
  23197. path3D: Path3D;
  23198. pathArray: Vector3[][];
  23199. arc: number;
  23200. radius: number;
  23201. cap: number;
  23202. tessellation: number;
  23203. }
  23204. /**
  23205. * @hidden
  23206. **/ private class _InstanceDataStorage {
  23207. visibleInstances: any;
  23208. batchCache: _InstancesBatch;
  23209. instancesBufferSize: number;
  23210. instancesBuffer: Nullable<Buffer>;
  23211. instancesData: Float32Array;
  23212. overridenInstanceCount: number;
  23213. isFrozen: boolean;
  23214. previousBatch: Nullable<_InstancesBatch>;
  23215. hardwareInstancedRendering: boolean;
  23216. sideOrientation: number;
  23217. }
  23218. /**
  23219. * @hidden
  23220. **/
  23221. export class _InstancesBatch {
  23222. mustReturn: boolean;
  23223. visibleInstances: Nullable<InstancedMesh[]>[];
  23224. renderSelf: boolean[];
  23225. hardwareInstancedRendering: boolean[];
  23226. }
  23227. /**
  23228. * Class used to represent renderable models
  23229. */
  23230. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23231. /**
  23232. * Mesh side orientation : usually the external or front surface
  23233. */
  23234. static readonly FRONTSIDE: number;
  23235. /**
  23236. * Mesh side orientation : usually the internal or back surface
  23237. */
  23238. static readonly BACKSIDE: number;
  23239. /**
  23240. * Mesh side orientation : both internal and external or front and back surfaces
  23241. */
  23242. static readonly DOUBLESIDE: number;
  23243. /**
  23244. * Mesh side orientation : by default, `FRONTSIDE`
  23245. */
  23246. static readonly DEFAULTSIDE: number;
  23247. /**
  23248. * Mesh cap setting : no cap
  23249. */
  23250. static readonly NO_CAP: number;
  23251. /**
  23252. * Mesh cap setting : one cap at the beginning of the mesh
  23253. */
  23254. static readonly CAP_START: number;
  23255. /**
  23256. * Mesh cap setting : one cap at the end of the mesh
  23257. */
  23258. static readonly CAP_END: number;
  23259. /**
  23260. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23261. */
  23262. static readonly CAP_ALL: number;
  23263. /**
  23264. * Mesh pattern setting : no flip or rotate
  23265. */
  23266. static readonly NO_FLIP: number;
  23267. /**
  23268. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23269. */
  23270. static readonly FLIP_TILE: number;
  23271. /**
  23272. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23273. */
  23274. static readonly ROTATE_TILE: number;
  23275. /**
  23276. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23277. */
  23278. static readonly FLIP_ROW: number;
  23279. /**
  23280. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23281. */
  23282. static readonly ROTATE_ROW: number;
  23283. /**
  23284. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23285. */
  23286. static readonly FLIP_N_ROTATE_TILE: number;
  23287. /**
  23288. * Mesh pattern setting : rotate pattern and rotate
  23289. */
  23290. static readonly FLIP_N_ROTATE_ROW: number;
  23291. /**
  23292. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23293. */
  23294. static readonly CENTER: number;
  23295. /**
  23296. * Mesh tile positioning : part tiles on left
  23297. */
  23298. static readonly LEFT: number;
  23299. /**
  23300. * Mesh tile positioning : part tiles on right
  23301. */
  23302. static readonly RIGHT: number;
  23303. /**
  23304. * Mesh tile positioning : part tiles on top
  23305. */
  23306. static readonly TOP: number;
  23307. /**
  23308. * Mesh tile positioning : part tiles on bottom
  23309. */
  23310. static readonly BOTTOM: number;
  23311. /**
  23312. * Gets the default side orientation.
  23313. * @param orientation the orientation to value to attempt to get
  23314. * @returns the default orientation
  23315. * @hidden
  23316. */ private static _GetDefaultSideOrientation(orientation?: number): number;
  23317. private _internalMeshDataInfo;
  23318. /**
  23319. * An event triggered before rendering the mesh
  23320. */
  23321. readonly onBeforeRenderObservable: Observable<Mesh>;
  23322. /**
  23323. * An event triggered before binding the mesh
  23324. */
  23325. readonly onBeforeBindObservable: Observable<Mesh>;
  23326. /**
  23327. * An event triggered after rendering the mesh
  23328. */
  23329. readonly onAfterRenderObservable: Observable<Mesh>;
  23330. /**
  23331. * An event triggered before drawing the mesh
  23332. */
  23333. readonly onBeforeDrawObservable: Observable<Mesh>;
  23334. private _onBeforeDrawObserver;
  23335. /**
  23336. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23337. */
  23338. onBeforeDraw: () => void;
  23339. readonly hasInstances: boolean;
  23340. /**
  23341. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23342. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23343. */
  23344. delayLoadState: number;
  23345. /**
  23346. * Gets the list of instances created from this mesh
  23347. * it is not supposed to be modified manually.
  23348. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23349. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23350. */
  23351. instances: InstancedMesh[];
  23352. /**
  23353. * Gets the file containing delay loading data for this mesh
  23354. */
  23355. delayLoadingFile: string;
  23356. /** @hidden */ private _binaryInfo: any;
  23357. /**
  23358. * User defined function used to change how LOD level selection is done
  23359. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23360. */
  23361. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23362. /**
  23363. * Gets or sets the morph target manager
  23364. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23365. */
  23366. morphTargetManager: Nullable<MorphTargetManager>;
  23367. /** @hidden */ private _creationDataStorage: Nullable<_CreationDataStorage>;
  23368. /** @hidden */ private _geometry: Nullable<Geometry>;
  23369. /** @hidden */ private _delayInfo: Array<string>;
  23370. /** @hidden */ private _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23371. /** @hidden */ private _instanceDataStorage: _InstanceDataStorage;
  23372. private _effectiveMaterial;
  23373. /** @hidden */ private _shouldGenerateFlatShading: boolean;
  23374. /** @hidden */ private _originalBuilderSideOrientation: number;
  23375. /**
  23376. * Use this property to change the original side orientation defined at construction time
  23377. */
  23378. overrideMaterialSideOrientation: Nullable<number>;
  23379. /**
  23380. * Gets the source mesh (the one used to clone this one from)
  23381. */
  23382. readonly source: Nullable<Mesh>;
  23383. /**
  23384. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23385. */
  23386. isUnIndexed: boolean;
  23387. /**
  23388. * @constructor
  23389. * @param name The value used by scene.getMeshByName() to do a lookup.
  23390. * @param scene The scene to add this mesh to.
  23391. * @param parent The parent of this mesh, if it has one
  23392. * @param source An optional Mesh from which geometry is shared, cloned.
  23393. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23394. * When false, achieved by calling a clone(), also passing False.
  23395. * This will make creation of children, recursive.
  23396. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23397. */
  23398. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23399. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  23400. /**
  23401. * Gets the class name
  23402. * @returns the string "Mesh".
  23403. */
  23404. getClassName(): string;
  23405. /** @hidden */ protected readonly _isMesh: boolean;
  23406. /**
  23407. * Returns a description of this mesh
  23408. * @param fullDetails define if full details about this mesh must be used
  23409. * @returns a descriptive string representing this mesh
  23410. */
  23411. toString(fullDetails?: boolean): string;
  23412. /** @hidden */ private _unBindEffect(): void;
  23413. /**
  23414. * Gets a boolean indicating if this mesh has LOD
  23415. */
  23416. readonly hasLODLevels: boolean;
  23417. /**
  23418. * Gets the list of MeshLODLevel associated with the current mesh
  23419. * @returns an array of MeshLODLevel
  23420. */
  23421. getLODLevels(): MeshLODLevel[];
  23422. private _sortLODLevels;
  23423. /**
  23424. * Add a mesh as LOD level triggered at the given distance.
  23425. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23426. * @param distance The distance from the center of the object to show this level
  23427. * @param mesh The mesh to be added as LOD level (can be null)
  23428. * @return This mesh (for chaining)
  23429. */
  23430. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23431. /**
  23432. * Returns the LOD level mesh at the passed distance or null if not found.
  23433. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23434. * @param distance The distance from the center of the object to show this level
  23435. * @returns a Mesh or `null`
  23436. */
  23437. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23438. /**
  23439. * Remove a mesh from the LOD array
  23440. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23441. * @param mesh defines the mesh to be removed
  23442. * @return This mesh (for chaining)
  23443. */
  23444. removeLODLevel(mesh: Mesh): Mesh;
  23445. /**
  23446. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23447. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23448. * @param camera defines the camera to use to compute distance
  23449. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23450. * @return This mesh (for chaining)
  23451. */
  23452. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23453. /**
  23454. * Gets the mesh internal Geometry object
  23455. */
  23456. readonly geometry: Nullable<Geometry>;
  23457. /**
  23458. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23459. * @returns the total number of vertices
  23460. */
  23461. getTotalVertices(): number;
  23462. /**
  23463. * Returns the content of an associated vertex buffer
  23464. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23465. * - VertexBuffer.PositionKind
  23466. * - VertexBuffer.UVKind
  23467. * - VertexBuffer.UV2Kind
  23468. * - VertexBuffer.UV3Kind
  23469. * - VertexBuffer.UV4Kind
  23470. * - VertexBuffer.UV5Kind
  23471. * - VertexBuffer.UV6Kind
  23472. * - VertexBuffer.ColorKind
  23473. * - VertexBuffer.MatricesIndicesKind
  23474. * - VertexBuffer.MatricesIndicesExtraKind
  23475. * - VertexBuffer.MatricesWeightsKind
  23476. * - VertexBuffer.MatricesWeightsExtraKind
  23477. * @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
  23478. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23479. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23480. */
  23481. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23482. /**
  23483. * Returns the mesh VertexBuffer object from the requested `kind`
  23484. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23485. * - VertexBuffer.PositionKind
  23486. * - VertexBuffer.NormalKind
  23487. * - VertexBuffer.UVKind
  23488. * - VertexBuffer.UV2Kind
  23489. * - VertexBuffer.UV3Kind
  23490. * - VertexBuffer.UV4Kind
  23491. * - VertexBuffer.UV5Kind
  23492. * - VertexBuffer.UV6Kind
  23493. * - VertexBuffer.ColorKind
  23494. * - VertexBuffer.MatricesIndicesKind
  23495. * - VertexBuffer.MatricesIndicesExtraKind
  23496. * - VertexBuffer.MatricesWeightsKind
  23497. * - VertexBuffer.MatricesWeightsExtraKind
  23498. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23499. */
  23500. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23501. /**
  23502. * Tests if a specific vertex buffer is associated with this mesh
  23503. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23504. * - VertexBuffer.PositionKind
  23505. * - VertexBuffer.NormalKind
  23506. * - VertexBuffer.UVKind
  23507. * - VertexBuffer.UV2Kind
  23508. * - VertexBuffer.UV3Kind
  23509. * - VertexBuffer.UV4Kind
  23510. * - VertexBuffer.UV5Kind
  23511. * - VertexBuffer.UV6Kind
  23512. * - VertexBuffer.ColorKind
  23513. * - VertexBuffer.MatricesIndicesKind
  23514. * - VertexBuffer.MatricesIndicesExtraKind
  23515. * - VertexBuffer.MatricesWeightsKind
  23516. * - VertexBuffer.MatricesWeightsExtraKind
  23517. * @returns a boolean
  23518. */
  23519. isVerticesDataPresent(kind: string): boolean;
  23520. /**
  23521. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23522. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23523. * - VertexBuffer.PositionKind
  23524. * - VertexBuffer.UVKind
  23525. * - VertexBuffer.UV2Kind
  23526. * - VertexBuffer.UV3Kind
  23527. * - VertexBuffer.UV4Kind
  23528. * - VertexBuffer.UV5Kind
  23529. * - VertexBuffer.UV6Kind
  23530. * - VertexBuffer.ColorKind
  23531. * - VertexBuffer.MatricesIndicesKind
  23532. * - VertexBuffer.MatricesIndicesExtraKind
  23533. * - VertexBuffer.MatricesWeightsKind
  23534. * - VertexBuffer.MatricesWeightsExtraKind
  23535. * @returns a boolean
  23536. */
  23537. isVertexBufferUpdatable(kind: string): boolean;
  23538. /**
  23539. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23540. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23541. * - VertexBuffer.PositionKind
  23542. * - VertexBuffer.NormalKind
  23543. * - VertexBuffer.UVKind
  23544. * - VertexBuffer.UV2Kind
  23545. * - VertexBuffer.UV3Kind
  23546. * - VertexBuffer.UV4Kind
  23547. * - VertexBuffer.UV5Kind
  23548. * - VertexBuffer.UV6Kind
  23549. * - VertexBuffer.ColorKind
  23550. * - VertexBuffer.MatricesIndicesKind
  23551. * - VertexBuffer.MatricesIndicesExtraKind
  23552. * - VertexBuffer.MatricesWeightsKind
  23553. * - VertexBuffer.MatricesWeightsExtraKind
  23554. * @returns an array of strings
  23555. */
  23556. getVerticesDataKinds(): string[];
  23557. /**
  23558. * Returns a positive integer : the total number of indices in this mesh geometry.
  23559. * @returns the numner of indices or zero if the mesh has no geometry.
  23560. */
  23561. getTotalIndices(): number;
  23562. /**
  23563. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23564. * @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.
  23565. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23566. * @returns the indices array or an empty array if the mesh has no geometry
  23567. */
  23568. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23569. readonly isBlocked: boolean;
  23570. /**
  23571. * Determine if the current mesh is ready to be rendered
  23572. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23573. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23574. * @returns true if all associated assets are ready (material, textures, shaders)
  23575. */
  23576. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23577. /**
  23578. * 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.
  23579. */
  23580. readonly areNormalsFrozen: boolean;
  23581. /**
  23582. * 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.
  23583. * @returns the current mesh
  23584. */
  23585. freezeNormals(): Mesh;
  23586. /**
  23587. * 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
  23588. * @returns the current mesh
  23589. */
  23590. unfreezeNormals(): Mesh;
  23591. /**
  23592. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23593. */
  23594. overridenInstanceCount: number;
  23595. /** @hidden */ private _preActivate(): Mesh;
  23596. /** @hidden */ private _preActivateForIntermediateRendering(renderId: number): Mesh;
  23597. /** @hidden */ private _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23598. /**
  23599. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23600. * This means the mesh underlying bounding box and sphere are recomputed.
  23601. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23602. * @returns the current mesh
  23603. */
  23604. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23605. /** @hidden */ private _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23606. /**
  23607. * This function will subdivide the mesh into multiple submeshes
  23608. * @param count defines the expected number of submeshes
  23609. */
  23610. subdivide(count: number): void;
  23611. /**
  23612. * Copy a FloatArray into a specific associated vertex buffer
  23613. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23614. * - VertexBuffer.PositionKind
  23615. * - VertexBuffer.UVKind
  23616. * - VertexBuffer.UV2Kind
  23617. * - VertexBuffer.UV3Kind
  23618. * - VertexBuffer.UV4Kind
  23619. * - VertexBuffer.UV5Kind
  23620. * - VertexBuffer.UV6Kind
  23621. * - VertexBuffer.ColorKind
  23622. * - VertexBuffer.MatricesIndicesKind
  23623. * - VertexBuffer.MatricesIndicesExtraKind
  23624. * - VertexBuffer.MatricesWeightsKind
  23625. * - VertexBuffer.MatricesWeightsExtraKind
  23626. * @param data defines the data source
  23627. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23628. * @param stride defines the data stride size (can be null)
  23629. * @returns the current mesh
  23630. */
  23631. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23632. /**
  23633. * Delete a vertex buffer associated with this mesh
  23634. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  23635. * - VertexBuffer.PositionKind
  23636. * - VertexBuffer.UVKind
  23637. * - VertexBuffer.UV2Kind
  23638. * - VertexBuffer.UV3Kind
  23639. * - VertexBuffer.UV4Kind
  23640. * - VertexBuffer.UV5Kind
  23641. * - VertexBuffer.UV6Kind
  23642. * - VertexBuffer.ColorKind
  23643. * - VertexBuffer.MatricesIndicesKind
  23644. * - VertexBuffer.MatricesIndicesExtraKind
  23645. * - VertexBuffer.MatricesWeightsKind
  23646. * - VertexBuffer.MatricesWeightsExtraKind
  23647. */
  23648. removeVerticesData(kind: string): void;
  23649. /**
  23650. * Flags an associated vertex buffer as updatable
  23651. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  23652. * - VertexBuffer.PositionKind
  23653. * - VertexBuffer.UVKind
  23654. * - VertexBuffer.UV2Kind
  23655. * - VertexBuffer.UV3Kind
  23656. * - VertexBuffer.UV4Kind
  23657. * - VertexBuffer.UV5Kind
  23658. * - VertexBuffer.UV6Kind
  23659. * - VertexBuffer.ColorKind
  23660. * - VertexBuffer.MatricesIndicesKind
  23661. * - VertexBuffer.MatricesIndicesExtraKind
  23662. * - VertexBuffer.MatricesWeightsKind
  23663. * - VertexBuffer.MatricesWeightsExtraKind
  23664. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23665. */
  23666. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  23667. /**
  23668. * Sets the mesh global Vertex Buffer
  23669. * @param buffer defines the buffer to use
  23670. * @returns the current mesh
  23671. */
  23672. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  23673. /**
  23674. * Update a specific associated vertex buffer
  23675. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23676. * - VertexBuffer.PositionKind
  23677. * - VertexBuffer.UVKind
  23678. * - VertexBuffer.UV2Kind
  23679. * - VertexBuffer.UV3Kind
  23680. * - VertexBuffer.UV4Kind
  23681. * - VertexBuffer.UV5Kind
  23682. * - VertexBuffer.UV6Kind
  23683. * - VertexBuffer.ColorKind
  23684. * - VertexBuffer.MatricesIndicesKind
  23685. * - VertexBuffer.MatricesIndicesExtraKind
  23686. * - VertexBuffer.MatricesWeightsKind
  23687. * - VertexBuffer.MatricesWeightsExtraKind
  23688. * @param data defines the data source
  23689. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23690. * @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)
  23691. * @returns the current mesh
  23692. */
  23693. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23694. /**
  23695. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  23696. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  23697. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  23698. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  23699. * @returns the current mesh
  23700. */
  23701. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  23702. /**
  23703. * Creates a un-shared specific occurence of the geometry for the mesh.
  23704. * @returns the current mesh
  23705. */
  23706. makeGeometryUnique(): Mesh;
  23707. /**
  23708. * Set the index buffer of this mesh
  23709. * @param indices defines the source data
  23710. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  23711. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  23712. * @returns the current mesh
  23713. */
  23714. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  23715. /**
  23716. * Update the current index buffer
  23717. * @param indices defines the source data
  23718. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  23719. * @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)
  23720. * @returns the current mesh
  23721. */
  23722. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  23723. /**
  23724. * Invert the geometry to move from a right handed system to a left handed one.
  23725. * @returns the current mesh
  23726. */
  23727. toLeftHanded(): Mesh;
  23728. /** @hidden */ private _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  23729. /** @hidden */ private _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  23730. /**
  23731. * Registers for this mesh a javascript function called just before the rendering process
  23732. * @param func defines the function to call before rendering this mesh
  23733. * @returns the current mesh
  23734. */
  23735. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23736. /**
  23737. * Disposes a previously registered javascript function called before the rendering
  23738. * @param func defines the function to remove
  23739. * @returns the current mesh
  23740. */
  23741. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23742. /**
  23743. * Registers for this mesh a javascript function called just after the rendering is complete
  23744. * @param func defines the function to call after rendering this mesh
  23745. * @returns the current mesh
  23746. */
  23747. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23748. /**
  23749. * Disposes a previously registered javascript function called after the rendering.
  23750. * @param func defines the function to remove
  23751. * @returns the current mesh
  23752. */
  23753. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23754. /** @hidden */ private _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  23755. /** @hidden */ private _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  23756. /** @hidden */ private _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  23757. /** @hidden */ private _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  23758. /** @hidden */ private _rebuild(): void;
  23759. /** @hidden */ private _freeze(): void;
  23760. /** @hidden */ private _unFreeze(): void;
  23761. /**
  23762. * 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
  23763. * @param subMesh defines the subMesh to render
  23764. * @param enableAlphaMode defines if alpha mode can be changed
  23765. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  23766. * @returns the current mesh
  23767. */
  23768. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  23769. private _onBeforeDraw;
  23770. /**
  23771. * Renormalize the mesh and patch it up if there are no weights
  23772. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  23773. * However in the case of zero weights then we set just a single influence to 1.
  23774. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  23775. */
  23776. cleanMatrixWeights(): void;
  23777. private normalizeSkinFourWeights;
  23778. private normalizeSkinWeightsAndExtra;
  23779. /**
  23780. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  23781. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  23782. * the user know there was an issue with importing the mesh
  23783. * @returns a validation object with skinned, valid and report string
  23784. */
  23785. validateSkinning(): {
  23786. skinned: boolean;
  23787. valid: boolean;
  23788. report: string;
  23789. };
  23790. /** @hidden */ private _checkDelayState(): Mesh;
  23791. private _queueLoad;
  23792. /**
  23793. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23794. * A mesh is in the frustum if its bounding box intersects the frustum
  23795. * @param frustumPlanes defines the frustum to test
  23796. * @returns true if the mesh is in the frustum planes
  23797. */
  23798. isInFrustum(frustumPlanes: Plane[]): boolean;
  23799. /**
  23800. * Sets the mesh material by the material or multiMaterial `id` property
  23801. * @param id is a string identifying the material or the multiMaterial
  23802. * @returns the current mesh
  23803. */
  23804. setMaterialByID(id: string): Mesh;
  23805. /**
  23806. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  23807. * @returns an array of IAnimatable
  23808. */
  23809. getAnimatables(): IAnimatable[];
  23810. /**
  23811. * Modifies the mesh geometry according to the passed transformation matrix.
  23812. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  23813. * The mesh normals are modified using the same transformation.
  23814. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23815. * @param transform defines the transform matrix to use
  23816. * @see http://doc.babylonjs.com/resources/baking_transformations
  23817. * @returns the current mesh
  23818. */
  23819. bakeTransformIntoVertices(transform: Matrix): Mesh;
  23820. /**
  23821. * Modifies the mesh geometry according to its own current World Matrix.
  23822. * The mesh World Matrix is then reset.
  23823. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  23824. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23825. * @see http://doc.babylonjs.com/resources/baking_transformations
  23826. * @returns the current mesh
  23827. */
  23828. bakeCurrentTransformIntoVertices(): Mesh;
  23829. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  23830. /** @hidden */ private _resetPointsArrayCache(): Mesh;
  23831. /** @hidden */ private _generatePointsArray(): boolean;
  23832. /**
  23833. * Returns a new Mesh object generated from the current mesh properties.
  23834. * This method must not get confused with createInstance()
  23835. * @param name is a string, the name given to the new mesh
  23836. * @param newParent can be any Node object (default `null`)
  23837. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  23838. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  23839. * @returns a new mesh
  23840. */
  23841. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  23842. /**
  23843. * Releases resources associated with this mesh.
  23844. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23845. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23846. */
  23847. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23848. /** @hidden */ private _disposeInstanceSpecificData(): void;
  23849. /**
  23850. * Modifies the mesh geometry according to a displacement map.
  23851. * 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.
  23852. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23853. * @param url is a string, the URL from the image file is to be downloaded.
  23854. * @param minHeight is the lower limit of the displacement.
  23855. * @param maxHeight is the upper limit of the displacement.
  23856. * @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.
  23857. * @param uvOffset is an optional vector2 used to offset UV.
  23858. * @param uvScale is an optional vector2 used to scale UV.
  23859. * @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.
  23860. * @returns the Mesh.
  23861. */
  23862. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23863. /**
  23864. * Modifies the mesh geometry according to a displacementMap buffer.
  23865. * 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.
  23866. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23867. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  23868. * @param heightMapWidth is the width of the buffer image.
  23869. * @param heightMapHeight is the height of the buffer image.
  23870. * @param minHeight is the lower limit of the displacement.
  23871. * @param maxHeight is the upper limit of the displacement.
  23872. * @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.
  23873. * @param uvOffset is an optional vector2 used to offset UV.
  23874. * @param uvScale is an optional vector2 used to scale UV.
  23875. * @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.
  23876. * @returns the Mesh.
  23877. */
  23878. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23879. /**
  23880. * Modify the mesh to get a flat shading rendering.
  23881. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  23882. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  23883. * @returns current mesh
  23884. */
  23885. convertToFlatShadedMesh(): Mesh;
  23886. /**
  23887. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  23888. * In other words, more vertices, no more indices and a single bigger VBO.
  23889. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  23890. * @returns current mesh
  23891. */
  23892. convertToUnIndexedMesh(): Mesh;
  23893. /**
  23894. * Inverses facet orientations.
  23895. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23896. * @param flipNormals will also inverts the normals
  23897. * @returns current mesh
  23898. */
  23899. flipFaces(flipNormals?: boolean): Mesh;
  23900. /**
  23901. * Increase the number of facets and hence vertices in a mesh
  23902. * Vertex normals are interpolated from existing vertex normals
  23903. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23904. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  23905. */
  23906. increaseVertices(numberPerEdge: number): void;
  23907. /**
  23908. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  23909. * This will undo any application of covertToFlatShadedMesh
  23910. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23911. */
  23912. forceSharedVertices(): void;
  23913. /** @hidden */ private static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  23914. /** @hidden */ private static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  23915. /**
  23916. * Creates a new InstancedMesh object from the mesh model.
  23917. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23918. * @param name defines the name of the new instance
  23919. * @returns a new InstancedMesh
  23920. */
  23921. createInstance(name: string): InstancedMesh;
  23922. /**
  23923. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  23924. * After this call, all the mesh instances have the same submeshes than the current mesh.
  23925. * @returns the current mesh
  23926. */
  23927. synchronizeInstances(): Mesh;
  23928. /**
  23929. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  23930. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  23931. * This should be used together with the simplification to avoid disappearing triangles.
  23932. * @param successCallback an optional success callback to be called after the optimization finished.
  23933. * @returns the current mesh
  23934. */
  23935. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  23936. /**
  23937. * Serialize current mesh
  23938. * @param serializationObject defines the object which will receive the serialization data
  23939. */
  23940. serialize(serializationObject: any): void;
  23941. /** @hidden */ private _syncGeometryWithMorphTargetManager(): void;
  23942. /** @hidden */ private static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  23943. /**
  23944. * Returns a new Mesh object parsed from the source provided.
  23945. * @param parsedMesh is the source
  23946. * @param scene defines the hosting scene
  23947. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  23948. * @returns a new Mesh
  23949. */
  23950. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  23951. /**
  23952. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  23953. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  23954. * @param name defines the name of the mesh to create
  23955. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  23956. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  23957. * @param closePath creates a seam between the first and the last points of each path of the path array
  23958. * @param offset is taken in account only if the `pathArray` is containing a single path
  23959. * @param scene defines the hosting scene
  23960. * @param updatable defines if the mesh must be flagged as updatable
  23961. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23962. * @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)
  23963. * @returns a new Mesh
  23964. */
  23965. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  23966. /**
  23967. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  23968. * @param name defines the name of the mesh to create
  23969. * @param radius sets the radius size (float) of the polygon (default 0.5)
  23970. * @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
  23971. * @param scene defines the hosting scene
  23972. * @param updatable defines if the mesh must be flagged as updatable
  23973. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23974. * @returns a new Mesh
  23975. */
  23976. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  23977. /**
  23978. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  23979. * @param name defines the name of the mesh to create
  23980. * @param size sets the size (float) of each box side (default 1)
  23981. * @param scene defines the hosting scene
  23982. * @param updatable defines if the mesh must be flagged as updatable
  23983. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23984. * @returns a new Mesh
  23985. */
  23986. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  23987. /**
  23988. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  23989. * @param name defines the name of the mesh to create
  23990. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  23991. * @param diameter sets the diameter size (float) of the sphere (default 1)
  23992. * @param scene defines the hosting scene
  23993. * @param updatable defines if the mesh must be flagged as updatable
  23994. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23995. * @returns a new Mesh
  23996. */
  23997. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23998. /**
  23999. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24000. * @param name defines the name of the mesh to create
  24001. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24002. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24003. * @param scene defines the hosting scene
  24004. * @returns a new Mesh
  24005. */
  24006. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24007. /**
  24008. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24009. * @param name defines the name of the mesh to create
  24010. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24011. * @param diameterTop set the top cap diameter (floats, default 1)
  24012. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24013. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24014. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24015. * @param scene defines the hosting scene
  24016. * @param updatable defines if the mesh must be flagged as updatable
  24017. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24018. * @returns a new Mesh
  24019. */
  24020. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24021. /**
  24022. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24023. * @param name defines the name of the mesh to create
  24024. * @param diameter sets the diameter size (float) of the torus (default 1)
  24025. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24026. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24027. * @param scene defines the hosting scene
  24028. * @param updatable defines if the mesh must be flagged as updatable
  24029. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24030. * @returns a new Mesh
  24031. */
  24032. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24033. /**
  24034. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24035. * @param name defines the name of the mesh to create
  24036. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24037. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24038. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24039. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24040. * @param p the number of windings on X axis (positive integers, default 2)
  24041. * @param q the number of windings on Y axis (positive integers, default 3)
  24042. * @param scene defines the hosting scene
  24043. * @param updatable defines if the mesh must be flagged as updatable
  24044. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24045. * @returns a new Mesh
  24046. */
  24047. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24048. /**
  24049. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24050. * @param name defines the name of the mesh to create
  24051. * @param points is an array successive Vector3
  24052. * @param scene defines the hosting scene
  24053. * @param updatable defines if the mesh must be flagged as updatable
  24054. * @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).
  24055. * @returns a new Mesh
  24056. */
  24057. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24058. /**
  24059. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24060. * @param name defines the name of the mesh to create
  24061. * @param points is an array successive Vector3
  24062. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24063. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24064. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24065. * @param scene defines the hosting scene
  24066. * @param updatable defines if the mesh must be flagged as updatable
  24067. * @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)
  24068. * @returns a new Mesh
  24069. */
  24070. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24071. /**
  24072. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24073. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24074. * 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.
  24075. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24076. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24077. * Remember you can only change the shape positions, not their number when updating a polygon.
  24078. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24079. * @param name defines the name of the mesh to create
  24080. * @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
  24081. * @param scene defines the hosting scene
  24082. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24083. * @param updatable defines if the mesh must be flagged as updatable
  24084. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24085. * @param earcutInjection can be used to inject your own earcut reference
  24086. * @returns a new Mesh
  24087. */
  24088. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24089. /**
  24090. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24091. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24092. * @param name defines the name of the mesh to create
  24093. * @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
  24094. * @param depth defines the height of extrusion
  24095. * @param scene defines the hosting scene
  24096. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24097. * @param updatable defines if the mesh must be flagged as updatable
  24098. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24099. * @param earcutInjection can be used to inject your own earcut reference
  24100. * @returns a new Mesh
  24101. */
  24102. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24103. /**
  24104. * Creates an extruded shape mesh.
  24105. * 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
  24106. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24107. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24108. * @param name defines the name of the mesh to create
  24109. * @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
  24110. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24111. * @param scale is the value to scale the shape
  24112. * @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
  24113. * @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
  24114. * @param scene defines the hosting scene
  24115. * @param updatable defines if the mesh must be flagged as updatable
  24116. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24117. * @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)
  24118. * @returns a new Mesh
  24119. */
  24120. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24121. /**
  24122. * Creates an custom extruded shape mesh.
  24123. * The custom extrusion is a parametric shape.
  24124. * It has no predefined shape. Its final shape will depend on the input parameters.
  24125. * Please consider using the same method from the MeshBuilder class instead
  24126. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24127. * @param name defines the name of the mesh to create
  24128. * @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
  24129. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24130. * @param scaleFunction is a custom Javascript function called on each path point
  24131. * @param rotationFunction is a custom Javascript function called on each path point
  24132. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24133. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24134. * @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
  24135. * @param scene defines the hosting scene
  24136. * @param updatable defines if the mesh must be flagged as updatable
  24137. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24138. * @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)
  24139. * @returns a new Mesh
  24140. */
  24141. 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;
  24142. /**
  24143. * Creates lathe mesh.
  24144. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24145. * Please consider using the same method from the MeshBuilder class instead
  24146. * @param name defines the name of the mesh to create
  24147. * @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
  24148. * @param radius is the radius value of the lathe
  24149. * @param tessellation is the side number of the lathe.
  24150. * @param scene defines the hosting scene
  24151. * @param updatable defines if the mesh must be flagged as updatable
  24152. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24153. * @returns a new Mesh
  24154. */
  24155. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24156. /**
  24157. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24158. * @param name defines the name of the mesh to create
  24159. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24160. * @param scene defines the hosting scene
  24161. * @param updatable defines if the mesh must be flagged as updatable
  24162. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24163. * @returns a new Mesh
  24164. */
  24165. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24166. /**
  24167. * Creates a ground mesh.
  24168. * Please consider using the same method from the MeshBuilder class instead
  24169. * @param name defines the name of the mesh to create
  24170. * @param width set the width of the ground
  24171. * @param height set the height of the ground
  24172. * @param subdivisions sets the number of subdivisions per side
  24173. * @param scene defines the hosting scene
  24174. * @param updatable defines if the mesh must be flagged as updatable
  24175. * @returns a new Mesh
  24176. */
  24177. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24178. /**
  24179. * Creates a tiled ground mesh.
  24180. * Please consider using the same method from the MeshBuilder class instead
  24181. * @param name defines the name of the mesh to create
  24182. * @param xmin set the ground minimum X coordinate
  24183. * @param zmin set the ground minimum Y coordinate
  24184. * @param xmax set the ground maximum X coordinate
  24185. * @param zmax set the ground maximum Z coordinate
  24186. * @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
  24187. * @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
  24188. * @param scene defines the hosting scene
  24189. * @param updatable defines if the mesh must be flagged as updatable
  24190. * @returns a new Mesh
  24191. */
  24192. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24193. w: number;
  24194. h: number;
  24195. }, precision: {
  24196. w: number;
  24197. h: number;
  24198. }, scene: Scene, updatable?: boolean): Mesh;
  24199. /**
  24200. * Creates a ground mesh from a height map.
  24201. * Please consider using the same method from the MeshBuilder class instead
  24202. * @see http://doc.babylonjs.com/babylon101/height_map
  24203. * @param name defines the name of the mesh to create
  24204. * @param url sets the URL of the height map image resource
  24205. * @param width set the ground width size
  24206. * @param height set the ground height size
  24207. * @param subdivisions sets the number of subdivision per side
  24208. * @param minHeight is the minimum altitude on the ground
  24209. * @param maxHeight is the maximum altitude on the ground
  24210. * @param scene defines the hosting scene
  24211. * @param updatable defines if the mesh must be flagged as updatable
  24212. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24213. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24214. * @returns a new Mesh
  24215. */
  24216. 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;
  24217. /**
  24218. * Creates a tube mesh.
  24219. * The tube is a parametric shape.
  24220. * It has no predefined shape. Its final shape will depend on the input parameters.
  24221. * Please consider using the same method from the MeshBuilder class instead
  24222. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24223. * @param name defines the name of the mesh to create
  24224. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24225. * @param radius sets the tube radius size
  24226. * @param tessellation is the number of sides on the tubular surface
  24227. * @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
  24228. * @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
  24229. * @param scene defines the hosting scene
  24230. * @param updatable defines if the mesh must be flagged as updatable
  24231. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24232. * @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)
  24233. * @returns a new Mesh
  24234. */
  24235. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24236. (i: number, distance: number): number;
  24237. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24238. /**
  24239. * Creates a polyhedron mesh.
  24240. * Please consider using the same method from the MeshBuilder class instead.
  24241. * * 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
  24242. * * The parameter `size` (positive float, default 1) sets the polygon size
  24243. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24244. * * 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`
  24245. * * 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
  24246. * * 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)`)
  24247. * * 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
  24248. * * 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
  24249. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24250. * * 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
  24251. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24252. * @param name defines the name of the mesh to create
  24253. * @param options defines the options used to create the mesh
  24254. * @param scene defines the hosting scene
  24255. * @returns a new Mesh
  24256. */
  24257. static CreatePolyhedron(name: string, options: {
  24258. type?: number;
  24259. size?: number;
  24260. sizeX?: number;
  24261. sizeY?: number;
  24262. sizeZ?: number;
  24263. custom?: any;
  24264. faceUV?: Vector4[];
  24265. faceColors?: Color4[];
  24266. updatable?: boolean;
  24267. sideOrientation?: number;
  24268. }, scene: Scene): Mesh;
  24269. /**
  24270. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24271. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24272. * * 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`)
  24273. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24274. * * 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
  24275. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24276. * * 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
  24277. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24278. * @param name defines the name of the mesh
  24279. * @param options defines the options used to create the mesh
  24280. * @param scene defines the hosting scene
  24281. * @returns a new Mesh
  24282. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24283. */
  24284. static CreateIcoSphere(name: string, options: {
  24285. radius?: number;
  24286. flat?: boolean;
  24287. subdivisions?: number;
  24288. sideOrientation?: number;
  24289. updatable?: boolean;
  24290. }, scene: Scene): Mesh;
  24291. /**
  24292. * Creates a decal mesh.
  24293. * Please consider using the same method from the MeshBuilder class instead.
  24294. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24295. * @param name defines the name of the mesh
  24296. * @param sourceMesh defines the mesh receiving the decal
  24297. * @param position sets the position of the decal in world coordinates
  24298. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24299. * @param size sets the decal scaling
  24300. * @param angle sets the angle to rotate the decal
  24301. * @returns a new Mesh
  24302. */
  24303. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24304. /**
  24305. * Prepare internal position array for software CPU skinning
  24306. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24307. */
  24308. setPositionsForCPUSkinning(): Float32Array;
  24309. /**
  24310. * Prepare internal normal array for software CPU skinning
  24311. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24312. */
  24313. setNormalsForCPUSkinning(): Float32Array;
  24314. /**
  24315. * Updates the vertex buffer by applying transformation from the bones
  24316. * @param skeleton defines the skeleton to apply to current mesh
  24317. * @returns the current mesh
  24318. */
  24319. applySkeleton(skeleton: Skeleton): Mesh;
  24320. /**
  24321. * 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
  24322. * @param meshes defines the list of meshes to scan
  24323. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24324. */
  24325. static MinMax(meshes: AbstractMesh[]): {
  24326. min: Vector3;
  24327. max: Vector3;
  24328. };
  24329. /**
  24330. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24331. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24332. * @returns a vector3
  24333. */
  24334. static Center(meshesOrMinMaxVector: {
  24335. min: Vector3;
  24336. max: Vector3;
  24337. } | AbstractMesh[]): Vector3;
  24338. /**
  24339. * Merge the array of meshes into a single mesh for performance reasons.
  24340. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24341. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24342. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24343. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24344. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24345. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24346. * @returns a new mesh
  24347. */
  24348. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24349. /** @hidden */
  24350. addInstance(instance: InstancedMesh): void;
  24351. /** @hidden */
  24352. removeInstance(instance: InstancedMesh): void;
  24353. }
  24354. }
  24355. declare module BABYLON {
  24356. /**
  24357. * This is the base class of all the camera used in the application.
  24358. * @see http://doc.babylonjs.com/features/cameras
  24359. */
  24360. export class Camera extends Node {
  24361. /** @hidden */ private static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24362. /**
  24363. * This is the default projection mode used by the cameras.
  24364. * It helps recreating a feeling of perspective and better appreciate depth.
  24365. * This is the best way to simulate real life cameras.
  24366. */
  24367. static readonly PERSPECTIVE_CAMERA: number;
  24368. /**
  24369. * This helps creating camera with an orthographic mode.
  24370. * 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.
  24371. */
  24372. static readonly ORTHOGRAPHIC_CAMERA: number;
  24373. /**
  24374. * This is the default FOV mode for perspective cameras.
  24375. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24376. */
  24377. static readonly FOVMODE_VERTICAL_FIXED: number;
  24378. /**
  24379. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24380. */
  24381. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24382. /**
  24383. * This specifies ther is no need for a camera rig.
  24384. * Basically only one eye is rendered corresponding to the camera.
  24385. */
  24386. static readonly RIG_MODE_NONE: number;
  24387. /**
  24388. * Simulates a camera Rig with one blue eye and one red eye.
  24389. * This can be use with 3d blue and red glasses.
  24390. */
  24391. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24392. /**
  24393. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24394. */
  24395. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24396. /**
  24397. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24398. */
  24399. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24400. /**
  24401. * Defines that both eyes of the camera will be rendered over under each other.
  24402. */
  24403. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24404. /**
  24405. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24406. */
  24407. static readonly RIG_MODE_VR: number;
  24408. /**
  24409. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24410. */
  24411. static readonly RIG_MODE_WEBVR: number;
  24412. /**
  24413. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24414. */
  24415. static readonly RIG_MODE_CUSTOM: number;
  24416. /**
  24417. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24418. */
  24419. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24420. /**
  24421. * Define the input manager associated with the camera.
  24422. */
  24423. inputs: CameraInputsManager<Camera>;
  24424. /** @hidden */ private _position: Vector3;
  24425. /**
  24426. * Define the current local position of the camera in the scene
  24427. */
  24428. position: Vector3;
  24429. /**
  24430. * The vector the camera should consider as up.
  24431. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24432. */
  24433. upVector: Vector3;
  24434. /**
  24435. * Define the current limit on the left side for an orthographic camera
  24436. * In scene unit
  24437. */
  24438. orthoLeft: Nullable<number>;
  24439. /**
  24440. * Define the current limit on the right side for an orthographic camera
  24441. * In scene unit
  24442. */
  24443. orthoRight: Nullable<number>;
  24444. /**
  24445. * Define the current limit on the bottom side for an orthographic camera
  24446. * In scene unit
  24447. */
  24448. orthoBottom: Nullable<number>;
  24449. /**
  24450. * Define the current limit on the top side for an orthographic camera
  24451. * In scene unit
  24452. */
  24453. orthoTop: Nullable<number>;
  24454. /**
  24455. * Field Of View is set in Radians. (default is 0.8)
  24456. */
  24457. fov: number;
  24458. /**
  24459. * Define the minimum distance the camera can see from.
  24460. * This is important to note that the depth buffer are not infinite and the closer it starts
  24461. * the more your scene might encounter depth fighting issue.
  24462. */
  24463. minZ: number;
  24464. /**
  24465. * Define the maximum distance the camera can see to.
  24466. * This is important to note that the depth buffer are not infinite and the further it end
  24467. * the more your scene might encounter depth fighting issue.
  24468. */
  24469. maxZ: number;
  24470. /**
  24471. * Define the default inertia of the camera.
  24472. * This helps giving a smooth feeling to the camera movement.
  24473. */
  24474. inertia: number;
  24475. /**
  24476. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24477. */
  24478. mode: number;
  24479. /**
  24480. * Define wether the camera is intermediate.
  24481. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24482. */
  24483. isIntermediate: boolean;
  24484. /**
  24485. * Define the viewport of the camera.
  24486. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24487. */
  24488. viewport: Viewport;
  24489. /**
  24490. * Restricts the camera to viewing objects with the same layerMask.
  24491. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24492. */
  24493. layerMask: number;
  24494. /**
  24495. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24496. */
  24497. fovMode: number;
  24498. /**
  24499. * Rig mode of the camera.
  24500. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24501. * This is normally controlled byt the camera themselves as internal use.
  24502. */
  24503. cameraRigMode: number;
  24504. /**
  24505. * Defines the distance between both "eyes" in case of a RIG
  24506. */
  24507. interaxialDistance: number;
  24508. /**
  24509. * Defines if stereoscopic rendering is done side by side or over under.
  24510. */
  24511. isStereoscopicSideBySide: boolean;
  24512. /**
  24513. * 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
  24514. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24515. * else in the scene. (Eg. security camera)
  24516. *
  24517. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  24518. */
  24519. customRenderTargets: RenderTargetTexture[];
  24520. /**
  24521. * When set, the camera will render to this render target instead of the default canvas
  24522. *
  24523. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24524. */
  24525. outputRenderTarget: Nullable<RenderTargetTexture>;
  24526. /**
  24527. * Observable triggered when the camera view matrix has changed.
  24528. */
  24529. onViewMatrixChangedObservable: Observable<Camera>;
  24530. /**
  24531. * Observable triggered when the camera Projection matrix has changed.
  24532. */
  24533. onProjectionMatrixChangedObservable: Observable<Camera>;
  24534. /**
  24535. * Observable triggered when the inputs have been processed.
  24536. */
  24537. onAfterCheckInputsObservable: Observable<Camera>;
  24538. /**
  24539. * Observable triggered when reset has been called and applied to the camera.
  24540. */
  24541. onRestoreStateObservable: Observable<Camera>;
  24542. /** @hidden */ private _cameraRigParams: any;
  24543. /** @hidden */ private _rigCameras: Camera[];
  24544. /** @hidden */ private _rigPostProcess: Nullable<PostProcess>;
  24545. protected _webvrViewMatrix: Matrix;
  24546. /** @hidden */ private _skipRendering: boolean;
  24547. /** @hidden */ private _projectionMatrix: Matrix;
  24548. /** @hidden */ private _postProcesses: Nullable<PostProcess>[];
  24549. /** @hidden */ private _activeMeshes: SmartArray<AbstractMesh>;
  24550. protected _globalPosition: Vector3;
  24551. /** @hidden */ private _computedViewMatrix: Matrix;
  24552. private _doNotComputeProjectionMatrix;
  24553. private _transformMatrix;
  24554. private _frustumPlanes;
  24555. private _refreshFrustumPlanes;
  24556. private _storedFov;
  24557. private _stateStored;
  24558. /**
  24559. * Instantiates a new camera object.
  24560. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24561. * @see http://doc.babylonjs.com/features/cameras
  24562. * @param name Defines the name of the camera in the scene
  24563. * @param position Defines the position of the camera
  24564. * @param scene Defines the scene the camera belongs too
  24565. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24566. */
  24567. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24568. /**
  24569. * Store current camera state (fov, position, etc..)
  24570. * @returns the camera
  24571. */
  24572. storeState(): Camera;
  24573. /**
  24574. * Restores the camera state values if it has been stored. You must call storeState() first
  24575. */
  24576. protected _restoreStateValues(): boolean;
  24577. /**
  24578. * Restored camera state. You must call storeState() first.
  24579. * @returns true if restored and false otherwise
  24580. */
  24581. restoreState(): boolean;
  24582. /**
  24583. * Gets the class name of the camera.
  24584. * @returns the class name
  24585. */
  24586. getClassName(): string;
  24587. /** @hidden */ protected readonly _isCamera: boolean;
  24588. /**
  24589. * Gets a string representation of the camera useful for debug purpose.
  24590. * @param fullDetails Defines that a more verboe level of logging is required
  24591. * @returns the string representation
  24592. */
  24593. toString(fullDetails?: boolean): string;
  24594. /**
  24595. * Gets the current world space position of the camera.
  24596. */
  24597. readonly globalPosition: Vector3;
  24598. /**
  24599. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24600. * @returns the active meshe list
  24601. */
  24602. getActiveMeshes(): SmartArray<AbstractMesh>;
  24603. /**
  24604. * Check wether a mesh is part of the current active mesh list of the camera
  24605. * @param mesh Defines the mesh to check
  24606. * @returns true if active, false otherwise
  24607. */
  24608. isActiveMesh(mesh: Mesh): boolean;
  24609. /**
  24610. * Is this camera ready to be used/rendered
  24611. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  24612. * @return true if the camera is ready
  24613. */
  24614. isReady(completeCheck?: boolean): boolean;
  24615. /** @hidden */ private _initCache(): void;
  24616. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  24617. /** @hidden */ private _isSynchronized(): boolean;
  24618. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  24619. /** @hidden */ private _isSynchronizedProjectionMatrix(): boolean;
  24620. /**
  24621. * Attach the input controls to a specific dom element to get the input from.
  24622. * @param element Defines the element the controls should be listened from
  24623. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24624. */
  24625. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24626. /**
  24627. * Detach the current controls from the specified dom element.
  24628. * @param element Defines the element to stop listening the inputs from
  24629. */
  24630. detachControl(element: HTMLElement): void;
  24631. /**
  24632. * Update the camera state according to the different inputs gathered during the frame.
  24633. */
  24634. update(): void;
  24635. /** @hidden */ private _checkInputs(): void;
  24636. /** @hidden */
  24637. readonly rigCameras: Camera[];
  24638. /**
  24639. * Gets the post process used by the rig cameras
  24640. */
  24641. readonly rigPostProcess: Nullable<PostProcess>;
  24642. /**
  24643. * Internal, gets the first post proces.
  24644. * @returns the first post process to be run on this camera.
  24645. */ private _getFirstPostProcess(): Nullable<PostProcess>;
  24646. private _cascadePostProcessesToRigCams;
  24647. /**
  24648. * Attach a post process to the camera.
  24649. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24650. * @param postProcess The post process to attach to the camera
  24651. * @param insertAt The position of the post process in case several of them are in use in the scene
  24652. * @returns the position the post process has been inserted at
  24653. */
  24654. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  24655. /**
  24656. * Detach a post process to the camera.
  24657. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24658. * @param postProcess The post process to detach from the camera
  24659. */
  24660. detachPostProcess(postProcess: PostProcess): void;
  24661. /**
  24662. * Gets the current world matrix of the camera
  24663. */
  24664. getWorldMatrix(): Matrix;
  24665. /** @hidden */ private _getViewMatrix(): Matrix;
  24666. /**
  24667. * Gets the current view matrix of the camera.
  24668. * @param force forces the camera to recompute the matrix without looking at the cached state
  24669. * @returns the view matrix
  24670. */
  24671. getViewMatrix(force?: boolean): Matrix;
  24672. /**
  24673. * Freeze the projection matrix.
  24674. * It will prevent the cache check of the camera projection compute and can speed up perf
  24675. * if no parameter of the camera are meant to change
  24676. * @param projection Defines manually a projection if necessary
  24677. */
  24678. freezeProjectionMatrix(projection?: Matrix): void;
  24679. /**
  24680. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  24681. */
  24682. unfreezeProjectionMatrix(): void;
  24683. /**
  24684. * Gets the current projection matrix of the camera.
  24685. * @param force forces the camera to recompute the matrix without looking at the cached state
  24686. * @returns the projection matrix
  24687. */
  24688. getProjectionMatrix(force?: boolean): Matrix;
  24689. /**
  24690. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  24691. * @returns a Matrix
  24692. */
  24693. getTransformationMatrix(): Matrix;
  24694. private _updateFrustumPlanes;
  24695. /**
  24696. * Checks if a cullable object (mesh...) is in the camera frustum
  24697. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  24698. * @param target The object to check
  24699. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  24700. * @returns true if the object is in frustum otherwise false
  24701. */
  24702. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  24703. /**
  24704. * Checks if a cullable object (mesh...) is in the camera frustum
  24705. * Unlike isInFrustum this cheks the full bounding box
  24706. * @param target The object to check
  24707. * @returns true if the object is in frustum otherwise false
  24708. */
  24709. isCompletelyInFrustum(target: ICullable): boolean;
  24710. /**
  24711. * Gets a ray in the forward direction from the camera.
  24712. * @param length Defines the length of the ray to create
  24713. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  24714. * @param origin Defines the start point of the ray which defaults to the camera position
  24715. * @returns the forward ray
  24716. */
  24717. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  24718. /**
  24719. * Releases resources associated with this node.
  24720. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24721. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24722. */
  24723. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24724. /** @hidden */ private _isLeftCamera: boolean;
  24725. /**
  24726. * Gets the left camera of a rig setup in case of Rigged Camera
  24727. */
  24728. readonly isLeftCamera: boolean;
  24729. /** @hidden */ private _isRightCamera: boolean;
  24730. /**
  24731. * Gets the right camera of a rig setup in case of Rigged Camera
  24732. */
  24733. readonly isRightCamera: boolean;
  24734. /**
  24735. * Gets the left camera of a rig setup in case of Rigged Camera
  24736. */
  24737. readonly leftCamera: Nullable<FreeCamera>;
  24738. /**
  24739. * Gets the right camera of a rig setup in case of Rigged Camera
  24740. */
  24741. readonly rightCamera: Nullable<FreeCamera>;
  24742. /**
  24743. * Gets the left camera target of a rig setup in case of Rigged Camera
  24744. * @returns the target position
  24745. */
  24746. getLeftTarget(): Nullable<Vector3>;
  24747. /**
  24748. * Gets the right camera target of a rig setup in case of Rigged Camera
  24749. * @returns the target position
  24750. */
  24751. getRightTarget(): Nullable<Vector3>;
  24752. /**
  24753. * @hidden
  24754. */
  24755. setCameraRigMode(mode: number, rigParams: any): void;
  24756. /** @hidden */ private static _setStereoscopicRigMode(camera: Camera): void;
  24757. /** @hidden */ private static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  24758. /** @hidden */ private static _setVRRigMode(camera: Camera, rigParams: any): void;
  24759. /** @hidden */ private static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  24760. /** @hidden */ private _getVRProjectionMatrix(): Matrix;
  24761. protected _updateCameraRotationMatrix(): void;
  24762. protected _updateWebVRCameraRotationMatrix(): void;
  24763. /**
  24764. * This function MUST be overwritten by the different WebVR cameras available.
  24765. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24766. * @hidden
  24767. */ private _getWebVRProjectionMatrix(): Matrix;
  24768. /**
  24769. * This function MUST be overwritten by the different WebVR cameras available.
  24770. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24771. * @hidden
  24772. */ private _getWebVRViewMatrix(): Matrix;
  24773. /** @hidden */
  24774. setCameraRigParameter(name: string, value: any): void;
  24775. /**
  24776. * needs to be overridden by children so sub has required properties to be copied
  24777. * @hidden
  24778. */
  24779. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  24780. /**
  24781. * May need to be overridden by children
  24782. * @hidden
  24783. */ private _updateRigCameras(): void;
  24784. /** @hidden */ private _setupInputs(): void;
  24785. /**
  24786. * Serialiaze the camera setup to a json represention
  24787. * @returns the JSON representation
  24788. */
  24789. serialize(): any;
  24790. /**
  24791. * Clones the current camera.
  24792. * @param name The cloned camera name
  24793. * @returns the cloned camera
  24794. */
  24795. clone(name: string): Camera;
  24796. /**
  24797. * Gets the direction of the camera relative to a given local axis.
  24798. * @param localAxis Defines the reference axis to provide a relative direction.
  24799. * @return the direction
  24800. */
  24801. getDirection(localAxis: Vector3): Vector3;
  24802. /**
  24803. * Returns the current camera absolute rotation
  24804. */
  24805. readonly absoluteRotation: Quaternion;
  24806. /**
  24807. * Gets the direction of the camera relative to a given local axis into a passed vector.
  24808. * @param localAxis Defines the reference axis to provide a relative direction.
  24809. * @param result Defines the vector to store the result in
  24810. */
  24811. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  24812. /**
  24813. * Gets a camera constructor for a given camera type
  24814. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  24815. * @param name The name of the camera the result will be able to instantiate
  24816. * @param scene The scene the result will construct the camera in
  24817. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  24818. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  24819. * @returns a factory method to construc the camera
  24820. */
  24821. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  24822. /**
  24823. * Compute the world matrix of the camera.
  24824. * @returns the camera workd matrix
  24825. */
  24826. computeWorldMatrix(): Matrix;
  24827. /**
  24828. * Parse a JSON and creates the camera from the parsed information
  24829. * @param parsedCamera The JSON to parse
  24830. * @param scene The scene to instantiate the camera in
  24831. * @returns the newly constructed camera
  24832. */
  24833. static Parse(parsedCamera: any, scene: Scene): Camera;
  24834. }
  24835. }
  24836. declare module BABYLON {
  24837. /**
  24838. * Class containing static functions to help procedurally build meshes
  24839. */
  24840. export class DiscBuilder {
  24841. /**
  24842. * Creates a plane polygonal mesh. By default, this is a disc
  24843. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24844. * * 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
  24845. * * 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
  24846. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24847. * * 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
  24848. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24849. * @param name defines the name of the mesh
  24850. * @param options defines the options used to create the mesh
  24851. * @param scene defines the hosting scene
  24852. * @returns the plane polygonal mesh
  24853. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24854. */
  24855. static CreateDisc(name: string, options: {
  24856. radius?: number;
  24857. tessellation?: number;
  24858. arc?: number;
  24859. updatable?: boolean;
  24860. sideOrientation?: number;
  24861. frontUVs?: Vector4;
  24862. backUVs?: Vector4;
  24863. }, scene?: Nullable<Scene>): Mesh;
  24864. }
  24865. }
  24866. declare module BABYLON {
  24867. /**
  24868. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24869. *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.
  24870. * The SPS is also a particle system. It provides some methods to manage the particles.
  24871. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24872. *
  24873. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  24874. */
  24875. export class SolidParticleSystem implements IDisposable {
  24876. /**
  24877. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24878. * Example : var p = SPS.particles[i];
  24879. */
  24880. particles: SolidParticle[];
  24881. /**
  24882. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24883. */
  24884. nbParticles: number;
  24885. /**
  24886. * If the particles must ever face the camera (default false). Useful for planar particles.
  24887. */
  24888. billboard: boolean;
  24889. /**
  24890. * Recompute normals when adding a shape
  24891. */
  24892. recomputeNormals: boolean;
  24893. /**
  24894. * This a counter ofr your own usage. It's not set by any SPS functions.
  24895. */
  24896. counter: number;
  24897. /**
  24898. * The SPS name. This name is also given to the underlying mesh.
  24899. */
  24900. name: string;
  24901. /**
  24902. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24903. */
  24904. mesh: Mesh;
  24905. /**
  24906. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24907. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  24908. */
  24909. vars: any;
  24910. /**
  24911. * This array is populated when the SPS is set as 'pickable'.
  24912. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24913. * Each element of this array is an object `{idx: int, faceId: int}`.
  24914. * `idx` is the picked particle index in the `SPS.particles` array
  24915. * `faceId` is the picked face index counted within this particle.
  24916. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  24917. */
  24918. pickedParticles: {
  24919. idx: number;
  24920. faceId: number;
  24921. }[];
  24922. /**
  24923. * This array is populated when `enableDepthSort` is set to true.
  24924. * Each element of this array is an instance of the class DepthSortedParticle.
  24925. */
  24926. depthSortedParticles: DepthSortedParticle[];
  24927. /**
  24928. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24929. * @hidden
  24930. */ private _bSphereOnly: boolean;
  24931. /**
  24932. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24933. * @hidden
  24934. */ private _bSphereRadiusFactor: number;
  24935. private _scene;
  24936. private _positions;
  24937. private _indices;
  24938. private _normals;
  24939. private _colors;
  24940. private _uvs;
  24941. private _indices32;
  24942. private _positions32;
  24943. private _normals32;
  24944. private _fixedNormal32;
  24945. private _colors32;
  24946. private _uvs32;
  24947. private _index;
  24948. private _updatable;
  24949. private _pickable;
  24950. private _isVisibilityBoxLocked;
  24951. private _alwaysVisible;
  24952. private _depthSort;
  24953. private _expandable;
  24954. private _shapeCounter;
  24955. private _copy;
  24956. private _color;
  24957. private _computeParticleColor;
  24958. private _computeParticleTexture;
  24959. private _computeParticleRotation;
  24960. private _computeParticleVertex;
  24961. private _computeBoundingBox;
  24962. private _depthSortParticles;
  24963. private _camera;
  24964. private _mustUnrotateFixedNormals;
  24965. private _particlesIntersect;
  24966. private _needs32Bits;
  24967. private _isNotBuilt;
  24968. /**
  24969. * Creates a SPS (Solid Particle System) object.
  24970. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24971. * @param scene (Scene) is the scene in which the SPS is added.
  24972. * @param options defines the options of the sps e.g.
  24973. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24974. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24975. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24976. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  24977. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24978. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24979. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24980. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24981. */
  24982. constructor(name: string, scene: Scene, options?: {
  24983. updatable?: boolean;
  24984. isPickable?: boolean;
  24985. enableDepthSort?: boolean;
  24986. particleIntersection?: boolean;
  24987. boundingSphereOnly?: boolean;
  24988. bSphereRadiusFactor?: number;
  24989. expandable?: boolean;
  24990. });
  24991. /**
  24992. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24993. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24994. * @returns the created mesh
  24995. */
  24996. buildMesh(): Mesh;
  24997. /**
  24998. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24999. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25000. * Thus the particles generated from `digest()` have their property `position` set yet.
  25001. * @param mesh ( Mesh ) is the mesh to be digested
  25002. * @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
  25003. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25004. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25005. * @returns the current SPS
  25006. */
  25007. digest(mesh: Mesh, options?: {
  25008. facetNb?: number;
  25009. number?: number;
  25010. delta?: number;
  25011. }): SolidParticleSystem;
  25012. private _unrotateFixedNormals;
  25013. private _resetCopy;
  25014. private _meshBuilder;
  25015. private _posToShape;
  25016. private _uvsToShapeUV;
  25017. private _addParticle;
  25018. /**
  25019. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25020. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25021. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25022. * @param nb (positive integer) the number of particles to be created from this model
  25023. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25024. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25025. * @returns the number of shapes in the system
  25026. */
  25027. addShape(mesh: Mesh, nb: number, options?: {
  25028. positionFunction?: any;
  25029. vertexFunction?: any;
  25030. }): number;
  25031. private _rebuildParticle;
  25032. /**
  25033. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25034. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  25035. * @returns the SPS.
  25036. */
  25037. rebuildMesh(reset?: boolean): SolidParticleSystem;
  25038. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  25039. * Returns an array with the removed particles.
  25040. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  25041. * The SPS can't be empty so at least one particle needs to remain in place.
  25042. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  25043. * @param start index of the first particle to remove
  25044. * @param end index of the last particle to remove (included)
  25045. * @returns an array populated with the removed particles
  25046. */
  25047. removeParticles(start: number, end: number): SolidParticle[];
  25048. /**
  25049. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25050. * This method calls `updateParticle()` for each particle of the SPS.
  25051. * For an animated SPS, it is usually called within the render loop.
  25052. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  25053. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25054. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25055. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25056. * @returns the SPS.
  25057. */
  25058. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25059. /**
  25060. * Disposes the SPS.
  25061. */
  25062. dispose(): void;
  25063. /**
  25064. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25065. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25066. * @returns the SPS.
  25067. */
  25068. refreshVisibleSize(): SolidParticleSystem;
  25069. /**
  25070. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25071. * @param size the size (float) of the visibility box
  25072. * note : this doesn't lock the SPS mesh bounding box.
  25073. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25074. */
  25075. setVisibilityBox(size: number): void;
  25076. /**
  25077. * Gets whether the SPS as always visible or not
  25078. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25079. */
  25080. /**
  25081. * Sets the SPS as always visible or not
  25082. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25083. */
  25084. isAlwaysVisible: boolean;
  25085. /**
  25086. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25087. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25088. */
  25089. /**
  25090. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25091. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25092. */
  25093. isVisibilityBoxLocked: boolean;
  25094. /**
  25095. * Tells to `setParticles()` to compute the particle rotations or not.
  25096. * Default value : true. The SPS is faster when it's set to false.
  25097. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25098. */
  25099. /**
  25100. * Gets if `setParticles()` computes the particle rotations or not.
  25101. * Default value : true. The SPS is faster when it's set to false.
  25102. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25103. */
  25104. computeParticleRotation: boolean;
  25105. /**
  25106. * Tells to `setParticles()` to compute the particle colors or not.
  25107. * Default value : true. The SPS is faster when it's set to false.
  25108. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25109. */
  25110. /**
  25111. * Gets if `setParticles()` computes the particle colors or not.
  25112. * Default value : true. The SPS is faster when it's set to false.
  25113. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25114. */
  25115. computeParticleColor: boolean;
  25116. /**
  25117. * Gets if `setParticles()` computes the particle textures or not.
  25118. * Default value : true. The SPS is faster when it's set to false.
  25119. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25120. */
  25121. computeParticleTexture: boolean;
  25122. /**
  25123. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25124. * Default value : false. The SPS is faster when it's set to false.
  25125. * Note : the particle custom vertex positions aren't stored values.
  25126. */
  25127. /**
  25128. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25129. * Default value : false. The SPS is faster when it's set to false.
  25130. * Note : the particle custom vertex positions aren't stored values.
  25131. */
  25132. computeParticleVertex: boolean;
  25133. /**
  25134. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25135. */
  25136. /**
  25137. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25138. */
  25139. computeBoundingBox: boolean;
  25140. /**
  25141. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25142. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25143. * Default : `true`
  25144. */
  25145. /**
  25146. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25147. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25148. * Default : `true`
  25149. */
  25150. depthSortParticles: boolean;
  25151. /**
  25152. * Gets if the SPS is created as expandable at construction time.
  25153. * Default : `false`
  25154. */
  25155. readonly expandable: boolean;
  25156. /**
  25157. * This function does nothing. It may be overwritten to set all the particle first values.
  25158. * The SPS doesn't call this function, you may have to call it by your own.
  25159. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25160. */
  25161. initParticles(): void;
  25162. /**
  25163. * This function does nothing. It may be overwritten to recycle a particle.
  25164. * The SPS doesn't call this function, you may have to call it by your own.
  25165. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25166. * @param particle The particle to recycle
  25167. * @returns the recycled particle
  25168. */
  25169. recycleParticle(particle: SolidParticle): SolidParticle;
  25170. /**
  25171. * Updates a particle : this function should be overwritten by the user.
  25172. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25173. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25174. * @example : just set a particle position or velocity and recycle conditions
  25175. * @param particle The particle to update
  25176. * @returns the updated particle
  25177. */
  25178. updateParticle(particle: SolidParticle): SolidParticle;
  25179. /**
  25180. * Updates a vertex of a particle : it can be overwritten by the user.
  25181. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25182. * @param particle the current particle
  25183. * @param vertex the current index of the current particle
  25184. * @param pt the index of the current vertex in the particle shape
  25185. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25186. * @example : just set a vertex particle position
  25187. * @returns the updated vertex
  25188. */
  25189. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25190. /**
  25191. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25192. * This does nothing and may be overwritten by the user.
  25193. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25194. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25195. * @param update the boolean update value actually passed to setParticles()
  25196. */
  25197. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25198. /**
  25199. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25200. * This will be passed three parameters.
  25201. * This does nothing and may be overwritten by the user.
  25202. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25203. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25204. * @param update the boolean update value actually passed to setParticles()
  25205. */
  25206. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25207. }
  25208. }
  25209. declare module BABYLON {
  25210. /**
  25211. * Represents one particle of a solid particle system.
  25212. */
  25213. export class SolidParticle {
  25214. /**
  25215. * particle global index
  25216. */
  25217. idx: number;
  25218. /**
  25219. * The color of the particle
  25220. */
  25221. color: Nullable<Color4>;
  25222. /**
  25223. * The world space position of the particle.
  25224. */
  25225. position: Vector3;
  25226. /**
  25227. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25228. */
  25229. rotation: Vector3;
  25230. /**
  25231. * The world space rotation quaternion of the particle.
  25232. */
  25233. rotationQuaternion: Nullable<Quaternion>;
  25234. /**
  25235. * The scaling of the particle.
  25236. */
  25237. scaling: Vector3;
  25238. /**
  25239. * The uvs of the particle.
  25240. */
  25241. uvs: Vector4;
  25242. /**
  25243. * The current speed of the particle.
  25244. */
  25245. velocity: Vector3;
  25246. /**
  25247. * The pivot point in the particle local space.
  25248. */
  25249. pivot: Vector3;
  25250. /**
  25251. * Must the particle be translated from its pivot point in its local space ?
  25252. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25253. * Default : false
  25254. */
  25255. translateFromPivot: boolean;
  25256. /**
  25257. * Is the particle active or not ?
  25258. */
  25259. alive: boolean;
  25260. /**
  25261. * Is the particle visible or not ?
  25262. */
  25263. isVisible: boolean;
  25264. /**
  25265. * Index of this particle in the global "positions" array (Internal use)
  25266. * @hidden
  25267. */ private _pos: number;
  25268. /**
  25269. * @hidden Index of this particle in the global "indices" array (Internal use)
  25270. */ private _ind: number;
  25271. /**
  25272. * @hidden ModelShape of this particle (Internal use)
  25273. */ private _model: ModelShape;
  25274. /**
  25275. * ModelShape id of this particle
  25276. */
  25277. shapeId: number;
  25278. /**
  25279. * Index of the particle in its shape id
  25280. */
  25281. idxInShape: number;
  25282. /**
  25283. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25284. */ private _modelBoundingInfo: BoundingInfo;
  25285. /**
  25286. * @hidden Particle BoundingInfo object (Internal use)
  25287. */ private _boundingInfo: BoundingInfo;
  25288. /**
  25289. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25290. */ private _sps: SolidParticleSystem;
  25291. /**
  25292. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25293. */ private _stillInvisible: boolean;
  25294. /**
  25295. * @hidden Last computed particle rotation matrix
  25296. */ private _rotationMatrix: number[];
  25297. /**
  25298. * Parent particle Id, if any.
  25299. * Default null.
  25300. */
  25301. parentId: Nullable<number>;
  25302. /**
  25303. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25304. * The possible values are :
  25305. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25306. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25307. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25308. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25309. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25310. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25311. * */
  25312. cullingStrategy: number;
  25313. /**
  25314. * @hidden Internal global position in the SPS.
  25315. */ private _globalPosition: Vector3;
  25316. /**
  25317. * Creates a Solid Particle object.
  25318. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25319. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25320. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25321. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25322. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25323. * @param shapeId (integer) is the model shape identifier in the SPS.
  25324. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25325. * @param sps defines the sps it is associated to
  25326. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25327. */
  25328. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25329. /**
  25330. * Legacy support, changed scale to scaling
  25331. */
  25332. /**
  25333. * Legacy support, changed scale to scaling
  25334. */
  25335. scale: Vector3;
  25336. /**
  25337. * Legacy support, changed quaternion to rotationQuaternion
  25338. */
  25339. /**
  25340. * Legacy support, changed quaternion to rotationQuaternion
  25341. */
  25342. quaternion: Nullable<Quaternion>;
  25343. /**
  25344. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25345. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25346. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25347. * @returns true if it intersects
  25348. */
  25349. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25350. /**
  25351. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25352. * A particle is in the frustum if its bounding box intersects the frustum
  25353. * @param frustumPlanes defines the frustum to test
  25354. * @returns true if the particle is in the frustum planes
  25355. */
  25356. isInFrustum(frustumPlanes: Plane[]): boolean;
  25357. /**
  25358. * get the rotation matrix of the particle
  25359. * @hidden
  25360. */
  25361. getRotationMatrix(m: Matrix): void;
  25362. }
  25363. /**
  25364. * Represents the shape of the model used by one particle of a solid particle system.
  25365. * SPS internal tool, don't use it manually.
  25366. */
  25367. export class ModelShape {
  25368. /**
  25369. * The shape id
  25370. * @hidden
  25371. */
  25372. shapeID: number;
  25373. /**
  25374. * flat array of model positions (internal use)
  25375. * @hidden
  25376. */ private _shape: Vector3[];
  25377. /**
  25378. * flat array of model UVs (internal use)
  25379. * @hidden
  25380. */ private _shapeUV: number[];
  25381. /**
  25382. * color array of the model
  25383. * @hidden
  25384. */ private _shapeColors: number[];
  25385. /**
  25386. * indices array of the model
  25387. * @hidden
  25388. */ private _indices: number[];
  25389. /**
  25390. * normals array of the model
  25391. * @hidden
  25392. */ private _normals: number[];
  25393. /**
  25394. * length of the shape in the model indices array (internal use)
  25395. * @hidden
  25396. */ private _indicesLength: number;
  25397. /**
  25398. * Custom position function (internal use)
  25399. * @hidden
  25400. */ private _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25401. /**
  25402. * Custom vertex function (internal use)
  25403. * @hidden
  25404. */ private _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25405. /**
  25406. * 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.
  25407. * SPS internal tool, don't use it manually.
  25408. * @hidden
  25409. */
  25410. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  25411. }
  25412. /**
  25413. * Represents a Depth Sorted Particle in the solid particle system.
  25414. */
  25415. export class DepthSortedParticle {
  25416. /**
  25417. * Index of the particle in the "indices" array
  25418. */
  25419. ind: number;
  25420. /**
  25421. * Length of the particle shape in the "indices" array
  25422. */
  25423. indicesLength: number;
  25424. /**
  25425. * Squared distance from the particle to the camera
  25426. */
  25427. sqDistance: number;
  25428. }
  25429. }
  25430. declare module BABYLON {
  25431. /**
  25432. * @hidden
  25433. */
  25434. export class _MeshCollisionData { private _checkCollisions: boolean; private _collisionMask: number; private _collisionGroup: number; private _collider: Nullable<Collider>; private _oldPositionForCollisions: Vector3; private _diffPositionForCollisions: Vector3; private _onCollideObserver: Nullable<Observer<AbstractMesh>>; private _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25435. }
  25436. }
  25437. declare module BABYLON {
  25438. /** @hidden */ private class _FacetDataStorage {
  25439. facetPositions: Vector3[];
  25440. facetNormals: Vector3[];
  25441. facetPartitioning: number[][];
  25442. facetNb: number;
  25443. partitioningSubdivisions: number;
  25444. partitioningBBoxRatio: number;
  25445. facetDataEnabled: boolean;
  25446. facetParameters: any;
  25447. bbSize: Vector3;
  25448. subDiv: {
  25449. max: number;
  25450. X: number;
  25451. Y: number;
  25452. Z: number;
  25453. };
  25454. facetDepthSort: boolean;
  25455. facetDepthSortEnabled: boolean;
  25456. depthSortedIndices: IndicesArray;
  25457. depthSortedFacets: {
  25458. ind: number;
  25459. sqDistance: number;
  25460. }[];
  25461. facetDepthSortFunction: (f1: {
  25462. ind: number;
  25463. sqDistance: number;
  25464. }, f2: {
  25465. ind: number;
  25466. sqDistance: number;
  25467. }) => number;
  25468. facetDepthSortFrom: Vector3;
  25469. facetDepthSortOrigin: Vector3;
  25470. invertedMatrix: Matrix;
  25471. }
  25472. /**
  25473. * @hidden
  25474. **/ private class _InternalAbstractMeshDataInfo { private _hasVertexAlpha: boolean; private _useVertexColors: boolean; private _numBoneInfluencers: number; private _applyFog: boolean; private _receiveShadows: boolean; private _facetData: _FacetDataStorage; private _visibility: number; private _skeleton: Nullable<Skeleton>; private _layerMask: number; private _computeBonesUsingShaders: boolean; private _isActive: boolean; private _onlyForInstances: boolean; private _isActiveIntermediate: boolean; private _onlyForInstancesIntermediate: boolean; private _actAsRegularMesh: boolean;
  25475. }
  25476. /**
  25477. * Class used to store all common mesh properties
  25478. */
  25479. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25480. /** No occlusion */
  25481. static OCCLUSION_TYPE_NONE: number;
  25482. /** Occlusion set to optimisitic */
  25483. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25484. /** Occlusion set to strict */
  25485. static OCCLUSION_TYPE_STRICT: number;
  25486. /** Use an accurante occlusion algorithm */
  25487. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25488. /** Use a conservative occlusion algorithm */
  25489. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25490. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25491. * Test order :
  25492. * Is the bounding sphere outside the frustum ?
  25493. * If not, are the bounding box vertices outside the frustum ?
  25494. * It not, then the cullable object is in the frustum.
  25495. */
  25496. static readonly CULLINGSTRATEGY_STANDARD: number;
  25497. /** Culling strategy : Bounding Sphere Only.
  25498. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25499. * It's also less accurate than the standard because some not visible objects can still be selected.
  25500. * Test : is the bounding sphere outside the frustum ?
  25501. * If not, then the cullable object is in the frustum.
  25502. */
  25503. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25504. /** Culling strategy : Optimistic Inclusion.
  25505. * This in an inclusion test first, then the standard exclusion test.
  25506. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25507. * 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.
  25508. * Anyway, it's as accurate as the standard strategy.
  25509. * Test :
  25510. * Is the cullable object bounding sphere center in the frustum ?
  25511. * If not, apply the default culling strategy.
  25512. */
  25513. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25514. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25515. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25516. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25517. * 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.
  25518. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25519. * Test :
  25520. * Is the cullable object bounding sphere center in the frustum ?
  25521. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25522. */
  25523. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25524. /**
  25525. * No billboard
  25526. */
  25527. static readonly BILLBOARDMODE_NONE: number;
  25528. /** Billboard on X axis */
  25529. static readonly BILLBOARDMODE_X: number;
  25530. /** Billboard on Y axis */
  25531. static readonly BILLBOARDMODE_Y: number;
  25532. /** Billboard on Z axis */
  25533. static readonly BILLBOARDMODE_Z: number;
  25534. /** Billboard on all axes */
  25535. static readonly BILLBOARDMODE_ALL: number;
  25536. /** Billboard on using position instead of orientation */
  25537. static readonly BILLBOARDMODE_USE_POSITION: number;
  25538. /** @hidden */ private _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25539. /**
  25540. * The culling strategy to use to check whether the mesh must be rendered or not.
  25541. * This value can be changed at any time and will be used on the next render mesh selection.
  25542. * The possible values are :
  25543. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25544. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25545. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25546. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25547. * Please read each static variable documentation to get details about the culling process.
  25548. * */
  25549. cullingStrategy: number;
  25550. /**
  25551. * Gets the number of facets in the mesh
  25552. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25553. */
  25554. readonly facetNb: number;
  25555. /**
  25556. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25557. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25558. */
  25559. partitioningSubdivisions: number;
  25560. /**
  25561. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25562. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25563. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25564. */
  25565. partitioningBBoxRatio: number;
  25566. /**
  25567. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25568. * Works only for updatable meshes.
  25569. * Doesn't work with multi-materials
  25570. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25571. */
  25572. mustDepthSortFacets: boolean;
  25573. /**
  25574. * The location (Vector3) where the facet depth sort must be computed from.
  25575. * By default, the active camera position.
  25576. * Used only when facet depth sort is enabled
  25577. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25578. */
  25579. facetDepthSortFrom: Vector3;
  25580. /**
  25581. * gets a boolean indicating if facetData is enabled
  25582. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25583. */
  25584. readonly isFacetDataEnabled: boolean;
  25585. /** @hidden */ private _updateNonUniformScalingState(value: boolean): boolean;
  25586. /**
  25587. * An event triggered when this mesh collides with another one
  25588. */
  25589. onCollideObservable: Observable<AbstractMesh>;
  25590. /** Set a function to call when this mesh collides with another one */
  25591. onCollide: () => void;
  25592. /**
  25593. * An event triggered when the collision's position changes
  25594. */
  25595. onCollisionPositionChangeObservable: Observable<Vector3>;
  25596. /** Set a function to call when the collision's position changes */
  25597. onCollisionPositionChange: () => void;
  25598. /**
  25599. * An event triggered when material is changed
  25600. */
  25601. onMaterialChangedObservable: Observable<AbstractMesh>;
  25602. /**
  25603. * Gets or sets the orientation for POV movement & rotation
  25604. */
  25605. definedFacingForward: boolean;
  25606. /** @hidden */ private _occlusionQuery: Nullable<WebGLQuery>;
  25607. /** @hidden */ private _renderingGroup: Nullable<RenderingGroup>;
  25608. /**
  25609. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25610. */
  25611. /**
  25612. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25613. */
  25614. visibility: number;
  25615. /** Gets or sets the alpha index used to sort transparent meshes
  25616. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25617. */
  25618. alphaIndex: number;
  25619. /**
  25620. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25621. */
  25622. isVisible: boolean;
  25623. /**
  25624. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25625. */
  25626. isPickable: boolean;
  25627. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25628. showSubMeshesBoundingBox: boolean;
  25629. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25630. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25631. */
  25632. isBlocker: boolean;
  25633. /**
  25634. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25635. */
  25636. enablePointerMoveEvents: boolean;
  25637. /**
  25638. * Specifies the rendering group id for this mesh (0 by default)
  25639. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25640. */
  25641. renderingGroupId: number;
  25642. private _material;
  25643. /** Gets or sets current material */
  25644. material: Nullable<Material>;
  25645. /**
  25646. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25647. * @see http://doc.babylonjs.com/babylon101/shadows
  25648. */
  25649. receiveShadows: boolean;
  25650. /** Defines color to use when rendering outline */
  25651. outlineColor: Color3;
  25652. /** Define width to use when rendering outline */
  25653. outlineWidth: number;
  25654. /** Defines color to use when rendering overlay */
  25655. overlayColor: Color3;
  25656. /** Defines alpha to use when rendering overlay */
  25657. overlayAlpha: number;
  25658. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25659. hasVertexAlpha: boolean;
  25660. /** 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) */
  25661. useVertexColors: boolean;
  25662. /**
  25663. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25664. */
  25665. computeBonesUsingShaders: boolean;
  25666. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25667. numBoneInfluencers: number;
  25668. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25669. applyFog: boolean;
  25670. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25671. useOctreeForRenderingSelection: boolean;
  25672. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25673. useOctreeForPicking: boolean;
  25674. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25675. useOctreeForCollisions: boolean;
  25676. /**
  25677. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25678. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25679. */
  25680. layerMask: number;
  25681. /**
  25682. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25683. */
  25684. alwaysSelectAsActiveMesh: boolean;
  25685. /**
  25686. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25687. */
  25688. doNotSyncBoundingInfo: boolean;
  25689. /**
  25690. * Gets or sets the current action manager
  25691. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25692. */
  25693. actionManager: Nullable<AbstractActionManager>;
  25694. private _meshCollisionData;
  25695. /**
  25696. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25697. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25698. */
  25699. ellipsoid: Vector3;
  25700. /**
  25701. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25702. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25703. */
  25704. ellipsoidOffset: Vector3;
  25705. /**
  25706. * Gets or sets a collision mask used to mask collisions (default is -1).
  25707. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25708. */
  25709. collisionMask: number;
  25710. /**
  25711. * Gets or sets the current collision group mask (-1 by default).
  25712. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25713. */
  25714. collisionGroup: number;
  25715. /**
  25716. * Defines edge width used when edgesRenderer is enabled
  25717. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25718. */
  25719. edgesWidth: number;
  25720. /**
  25721. * Defines edge color used when edgesRenderer is enabled
  25722. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25723. */
  25724. edgesColor: Color4;
  25725. /** @hidden */ private _edgesRenderer: Nullable<IEdgesRenderer>;
  25726. /** @hidden */ private _masterMesh: Nullable<AbstractMesh>;
  25727. /** @hidden */ private _boundingInfo: Nullable<BoundingInfo>;
  25728. /** @hidden */ private _renderId: number;
  25729. /**
  25730. * Gets or sets the list of subMeshes
  25731. * @see http://doc.babylonjs.com/how_to/multi_materials
  25732. */
  25733. subMeshes: SubMesh[];
  25734. /** @hidden */ private _intersectionsInProgress: AbstractMesh[];
  25735. /** @hidden */ private _unIndexed: boolean;
  25736. /** @hidden */ private _lightSources: Light[];
  25737. /** Gets the list of lights affecting that mesh */
  25738. readonly lightSources: Light[];
  25739. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  25740. /** @hidden */ private _waitingData: {
  25741. lods: Nullable<any>;
  25742. actions: Nullable<any>;
  25743. freezeWorldMatrix: Nullable<boolean>;
  25744. };
  25745. /** @hidden */ private _bonesTransformMatrices: Nullable<Float32Array>;
  25746. /** @hidden */ private _transformMatrixTexture: Nullable<RawTexture>;
  25747. /**
  25748. * Gets or sets a skeleton to apply skining transformations
  25749. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25750. */
  25751. skeleton: Nullable<Skeleton>;
  25752. /**
  25753. * An event triggered when the mesh is rebuilt.
  25754. */
  25755. onRebuildObservable: Observable<AbstractMesh>;
  25756. /**
  25757. * Creates a new AbstractMesh
  25758. * @param name defines the name of the mesh
  25759. * @param scene defines the hosting scene
  25760. */
  25761. constructor(name: string, scene?: Nullable<Scene>);
  25762. /**
  25763. * Returns the string "AbstractMesh"
  25764. * @returns "AbstractMesh"
  25765. */
  25766. getClassName(): string;
  25767. /**
  25768. * Gets a string representation of the current mesh
  25769. * @param fullDetails defines a boolean indicating if full details must be included
  25770. * @returns a string representation of the current mesh
  25771. */
  25772. toString(fullDetails?: boolean): string;
  25773. /**
  25774. * @hidden
  25775. */
  25776. protected _getEffectiveParent(): Nullable<Node>;
  25777. /** @hidden */ private _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25778. /** @hidden */ private _rebuild(): void;
  25779. /** @hidden */ private _resyncLightSources(): void;
  25780. /** @hidden */ private _resyncLighSource(light: Light): void;
  25781. /** @hidden */ private _unBindEffect(): void;
  25782. /** @hidden */ private _removeLightSource(light: Light, dispose: boolean): void;
  25783. private _markSubMeshesAsDirty;
  25784. /** @hidden */ private _markSubMeshesAsLightDirty(dispose?: boolean): void;
  25785. /** @hidden */ private _markSubMeshesAsAttributesDirty(): void;
  25786. /** @hidden */ private _markSubMeshesAsMiscDirty(): void;
  25787. /**
  25788. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25789. */
  25790. scaling: Vector3;
  25791. /**
  25792. * Returns true if the mesh is blocked. Implemented by child classes
  25793. */
  25794. readonly isBlocked: boolean;
  25795. /**
  25796. * Returns the mesh itself by default. Implemented by child classes
  25797. * @param camera defines the camera to use to pick the right LOD level
  25798. * @returns the currentAbstractMesh
  25799. */
  25800. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25801. /**
  25802. * Returns 0 by default. Implemented by child classes
  25803. * @returns an integer
  25804. */
  25805. getTotalVertices(): number;
  25806. /**
  25807. * Returns a positive integer : the total number of indices in this mesh geometry.
  25808. * @returns the numner of indices or zero if the mesh has no geometry.
  25809. */
  25810. getTotalIndices(): number;
  25811. /**
  25812. * Returns null by default. Implemented by child classes
  25813. * @returns null
  25814. */
  25815. getIndices(): Nullable<IndicesArray>;
  25816. /**
  25817. * Returns the array of the requested vertex data kind. Implemented by child classes
  25818. * @param kind defines the vertex data kind to use
  25819. * @returns null
  25820. */
  25821. getVerticesData(kind: string): Nullable<FloatArray>;
  25822. /**
  25823. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25824. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25825. * Note that a new underlying VertexBuffer object is created each call.
  25826. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25827. * @param kind defines vertex data kind:
  25828. * * VertexBuffer.PositionKind
  25829. * * VertexBuffer.UVKind
  25830. * * VertexBuffer.UV2Kind
  25831. * * VertexBuffer.UV3Kind
  25832. * * VertexBuffer.UV4Kind
  25833. * * VertexBuffer.UV5Kind
  25834. * * VertexBuffer.UV6Kind
  25835. * * VertexBuffer.ColorKind
  25836. * * VertexBuffer.MatricesIndicesKind
  25837. * * VertexBuffer.MatricesIndicesExtraKind
  25838. * * VertexBuffer.MatricesWeightsKind
  25839. * * VertexBuffer.MatricesWeightsExtraKind
  25840. * @param data defines the data source
  25841. * @param updatable defines if the data must be flagged as updatable (or static)
  25842. * @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
  25843. * @returns the current mesh
  25844. */
  25845. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25846. /**
  25847. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25848. * If the mesh has no geometry, it is simply returned as it is.
  25849. * @param kind defines vertex data kind:
  25850. * * VertexBuffer.PositionKind
  25851. * * VertexBuffer.UVKind
  25852. * * VertexBuffer.UV2Kind
  25853. * * VertexBuffer.UV3Kind
  25854. * * VertexBuffer.UV4Kind
  25855. * * VertexBuffer.UV5Kind
  25856. * * VertexBuffer.UV6Kind
  25857. * * VertexBuffer.ColorKind
  25858. * * VertexBuffer.MatricesIndicesKind
  25859. * * VertexBuffer.MatricesIndicesExtraKind
  25860. * * VertexBuffer.MatricesWeightsKind
  25861. * * VertexBuffer.MatricesWeightsExtraKind
  25862. * @param data defines the data source
  25863. * @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
  25864. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25865. * @returns the current mesh
  25866. */
  25867. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25868. /**
  25869. * Sets the mesh indices,
  25870. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25871. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25872. * @param totalVertices Defines the total number of vertices
  25873. * @returns the current mesh
  25874. */
  25875. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25876. /**
  25877. * Gets a boolean indicating if specific vertex data is present
  25878. * @param kind defines the vertex data kind to use
  25879. * @returns true is data kind is present
  25880. */
  25881. isVerticesDataPresent(kind: string): boolean;
  25882. /**
  25883. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  25884. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  25885. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  25886. * @returns a BoundingInfo
  25887. */
  25888. getBoundingInfo(): BoundingInfo;
  25889. /**
  25890. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25891. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25892. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25893. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  25894. * @returns the current mesh
  25895. */
  25896. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  25897. /**
  25898. * Overwrite the current bounding info
  25899. * @param boundingInfo defines the new bounding info
  25900. * @returns the current mesh
  25901. */
  25902. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25903. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25904. readonly useBones: boolean;
  25905. /** @hidden */ private _preActivate(): void;
  25906. /** @hidden */ private _preActivateForIntermediateRendering(renderId: number): void;
  25907. /** @hidden */ private _activate(renderId: number, intermediateRendering: boolean): boolean;
  25908. /** @hidden */ private _postActivate(): void;
  25909. /** @hidden */ private _freeze(): void;
  25910. /** @hidden */ private _unFreeze(): void;
  25911. /**
  25912. * Gets the current world matrix
  25913. * @returns a Matrix
  25914. */
  25915. getWorldMatrix(): Matrix;
  25916. /** @hidden */ private _getWorldMatrixDeterminant(): number;
  25917. /**
  25918. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25919. */
  25920. readonly isAnInstance: boolean;
  25921. /**
  25922. * Gets a boolean indicating if this mesh has instances
  25923. */
  25924. readonly hasInstances: boolean;
  25925. /**
  25926. * Perform relative position change from the point of view of behind the front of the mesh.
  25927. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25928. * Supports definition of mesh facing forward or backward
  25929. * @param amountRight defines the distance on the right axis
  25930. * @param amountUp defines the distance on the up axis
  25931. * @param amountForward defines the distance on the forward axis
  25932. * @returns the current mesh
  25933. */
  25934. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25935. /**
  25936. * Calculate relative position change from the point of view of behind the front of the mesh.
  25937. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25938. * Supports definition of mesh facing forward or backward
  25939. * @param amountRight defines the distance on the right axis
  25940. * @param amountUp defines the distance on the up axis
  25941. * @param amountForward defines the distance on the forward axis
  25942. * @returns the new displacement vector
  25943. */
  25944. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25945. /**
  25946. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25947. * Supports definition of mesh facing forward or backward
  25948. * @param flipBack defines the flip
  25949. * @param twirlClockwise defines the twirl
  25950. * @param tiltRight defines the tilt
  25951. * @returns the current mesh
  25952. */
  25953. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25954. /**
  25955. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25956. * Supports definition of mesh facing forward or backward.
  25957. * @param flipBack defines the flip
  25958. * @param twirlClockwise defines the twirl
  25959. * @param tiltRight defines the tilt
  25960. * @returns the new rotation vector
  25961. */
  25962. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25963. /**
  25964. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25965. * This means the mesh underlying bounding box and sphere are recomputed.
  25966. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25967. * @returns the current mesh
  25968. */
  25969. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25970. /** @hidden */ private _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25971. /** @hidden */ private _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25972. /** @hidden */ private _updateBoundingInfo(): AbstractMesh;
  25973. /** @hidden */ private _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25974. /** @hidden */
  25975. protected _afterComputeWorldMatrix(): void;
  25976. /** @hidden */ protected readonly _effectiveMesh: AbstractMesh;
  25977. /**
  25978. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25979. * A mesh is in the frustum if its bounding box intersects the frustum
  25980. * @param frustumPlanes defines the frustum to test
  25981. * @returns true if the mesh is in the frustum planes
  25982. */
  25983. isInFrustum(frustumPlanes: Plane[]): boolean;
  25984. /**
  25985. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25986. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25987. * @param frustumPlanes defines the frustum to test
  25988. * @returns true if the mesh is completely in the frustum planes
  25989. */
  25990. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25991. /**
  25992. * True if the mesh intersects another mesh or a SolidParticle object
  25993. * @param mesh defines a target mesh or SolidParticle to test
  25994. * @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)
  25995. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25996. * @returns true if there is an intersection
  25997. */
  25998. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25999. /**
  26000. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26001. * @param point defines the point to test
  26002. * @returns true if there is an intersection
  26003. */
  26004. intersectsPoint(point: Vector3): boolean;
  26005. /**
  26006. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26007. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26008. */
  26009. checkCollisions: boolean;
  26010. /**
  26011. * Gets Collider object used to compute collisions (not physics)
  26012. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26013. */
  26014. readonly collider: Nullable<Collider>;
  26015. /**
  26016. * Move the mesh using collision engine
  26017. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26018. * @param displacement defines the requested displacement vector
  26019. * @returns the current mesh
  26020. */
  26021. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26022. private _onCollisionPositionChange;
  26023. /** @hidden */ private _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26024. /** @hidden */ private _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26025. /** @hidden */ private _checkCollision(collider: Collider): AbstractMesh;
  26026. /** @hidden */ private _generatePointsArray(): boolean;
  26027. /**
  26028. * Checks if the passed Ray intersects with the mesh
  26029. * @param ray defines the ray to use
  26030. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26031. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26032. * @returns the picking info
  26033. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26034. */
  26035. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26036. /**
  26037. * Clones the current mesh
  26038. * @param name defines the mesh name
  26039. * @param newParent defines the new mesh parent
  26040. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26041. * @returns the new mesh
  26042. */
  26043. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26044. /**
  26045. * Disposes all the submeshes of the current meshnp
  26046. * @returns the current mesh
  26047. */
  26048. releaseSubMeshes(): AbstractMesh;
  26049. /**
  26050. * Releases resources associated with this abstract mesh.
  26051. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26052. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26053. */
  26054. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26055. /**
  26056. * Adds the passed mesh as a child to the current mesh
  26057. * @param mesh defines the child mesh
  26058. * @returns the current mesh
  26059. */
  26060. addChild(mesh: AbstractMesh): AbstractMesh;
  26061. /**
  26062. * Removes the passed mesh from the current mesh children list
  26063. * @param mesh defines the child mesh
  26064. * @returns the current mesh
  26065. */
  26066. removeChild(mesh: AbstractMesh): AbstractMesh;
  26067. /** @hidden */
  26068. private _initFacetData;
  26069. /**
  26070. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26071. * This method can be called within the render loop.
  26072. * 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
  26073. * @returns the current mesh
  26074. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26075. */
  26076. updateFacetData(): AbstractMesh;
  26077. /**
  26078. * Returns the facetLocalNormals array.
  26079. * The normals are expressed in the mesh local spac
  26080. * @returns an array of Vector3
  26081. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26082. */
  26083. getFacetLocalNormals(): Vector3[];
  26084. /**
  26085. * Returns the facetLocalPositions array.
  26086. * The facet positions are expressed in the mesh local space
  26087. * @returns an array of Vector3
  26088. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26089. */
  26090. getFacetLocalPositions(): Vector3[];
  26091. /**
  26092. * Returns the facetLocalPartioning array
  26093. * @returns an array of array of numbers
  26094. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26095. */
  26096. getFacetLocalPartitioning(): number[][];
  26097. /**
  26098. * Returns the i-th facet position in the world system.
  26099. * This method allocates a new Vector3 per call
  26100. * @param i defines the facet index
  26101. * @returns a new Vector3
  26102. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26103. */
  26104. getFacetPosition(i: number): Vector3;
  26105. /**
  26106. * Sets the reference Vector3 with the i-th facet position in the world system
  26107. * @param i defines the facet index
  26108. * @param ref defines the target vector
  26109. * @returns the current mesh
  26110. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26111. */
  26112. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26113. /**
  26114. * Returns the i-th facet normal in the world system.
  26115. * This method allocates a new Vector3 per call
  26116. * @param i defines the facet index
  26117. * @returns a new Vector3
  26118. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26119. */
  26120. getFacetNormal(i: number): Vector3;
  26121. /**
  26122. * Sets the reference Vector3 with the i-th facet normal in the world system
  26123. * @param i defines the facet index
  26124. * @param ref defines the target vector
  26125. * @returns the current mesh
  26126. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26127. */
  26128. getFacetNormalToRef(i: number, ref: Vector3): this;
  26129. /**
  26130. * 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)
  26131. * @param x defines x coordinate
  26132. * @param y defines y coordinate
  26133. * @param z defines z coordinate
  26134. * @returns the array of facet indexes
  26135. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26136. */
  26137. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26138. /**
  26139. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26140. * @param projected sets as the (x,y,z) world projection on the facet
  26141. * @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
  26142. * @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
  26143. * @param x defines x coordinate
  26144. * @param y defines y coordinate
  26145. * @param z defines z coordinate
  26146. * @returns the face index if found (or null instead)
  26147. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26148. */
  26149. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26150. /**
  26151. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26152. * @param projected sets as the (x,y,z) local projection on the facet
  26153. * @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
  26154. * @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
  26155. * @param x defines x coordinate
  26156. * @param y defines y coordinate
  26157. * @param z defines z coordinate
  26158. * @returns the face index if found (or null instead)
  26159. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26160. */
  26161. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26162. /**
  26163. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26164. * @returns the parameters
  26165. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26166. */
  26167. getFacetDataParameters(): any;
  26168. /**
  26169. * Disables the feature FacetData and frees the related memory
  26170. * @returns the current mesh
  26171. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26172. */
  26173. disableFacetData(): AbstractMesh;
  26174. /**
  26175. * Updates the AbstractMesh indices array
  26176. * @param indices defines the data source
  26177. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26178. * @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)
  26179. * @returns the current mesh
  26180. */
  26181. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26182. /**
  26183. * Creates new normals data for the mesh
  26184. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26185. * @returns the current mesh
  26186. */
  26187. createNormals(updatable: boolean): AbstractMesh;
  26188. /**
  26189. * Align the mesh with a normal
  26190. * @param normal defines the normal to use
  26191. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26192. * @returns the current mesh
  26193. */
  26194. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26195. /** @hidden */ private _checkOcclusionQuery(): boolean;
  26196. /**
  26197. * Disables the mesh edge rendering mode
  26198. * @returns the currentAbstractMesh
  26199. */
  26200. disableEdgesRendering(): AbstractMesh;
  26201. /**
  26202. * Enables the edge rendering mode on the mesh.
  26203. * This mode makes the mesh edges visible
  26204. * @param epsilon defines the maximal distance between two angles to detect a face
  26205. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26206. * @returns the currentAbstractMesh
  26207. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26208. */
  26209. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26210. }
  26211. }
  26212. declare module BABYLON {
  26213. /**
  26214. * Interface used to define ActionEvent
  26215. */
  26216. export interface IActionEvent {
  26217. /** The mesh or sprite that triggered the action */
  26218. source: any;
  26219. /** The X mouse cursor position at the time of the event */
  26220. pointerX: number;
  26221. /** The Y mouse cursor position at the time of the event */
  26222. pointerY: number;
  26223. /** The mesh that is currently pointed at (can be null) */
  26224. meshUnderPointer: Nullable<AbstractMesh>;
  26225. /** the original (browser) event that triggered the ActionEvent */
  26226. sourceEvent?: any;
  26227. /** additional data for the event */
  26228. additionalData?: any;
  26229. }
  26230. /**
  26231. * ActionEvent is the event being sent when an action is triggered.
  26232. */
  26233. export class ActionEvent implements IActionEvent {
  26234. /** The mesh or sprite that triggered the action */
  26235. source: any;
  26236. /** The X mouse cursor position at the time of the event */
  26237. pointerX: number;
  26238. /** The Y mouse cursor position at the time of the event */
  26239. pointerY: number;
  26240. /** The mesh that is currently pointed at (can be null) */
  26241. meshUnderPointer: Nullable<AbstractMesh>;
  26242. /** the original (browser) event that triggered the ActionEvent */
  26243. sourceEvent?: any;
  26244. /** additional data for the event */
  26245. additionalData?: any;
  26246. /**
  26247. * Creates a new ActionEvent
  26248. * @param source The mesh or sprite that triggered the action
  26249. * @param pointerX The X mouse cursor position at the time of the event
  26250. * @param pointerY The Y mouse cursor position at the time of the event
  26251. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26252. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26253. * @param additionalData additional data for the event
  26254. */
  26255. constructor(
  26256. /** The mesh or sprite that triggered the action */
  26257. source: any,
  26258. /** The X mouse cursor position at the time of the event */
  26259. pointerX: number,
  26260. /** The Y mouse cursor position at the time of the event */
  26261. pointerY: number,
  26262. /** The mesh that is currently pointed at (can be null) */
  26263. meshUnderPointer: Nullable<AbstractMesh>,
  26264. /** the original (browser) event that triggered the ActionEvent */
  26265. sourceEvent?: any,
  26266. /** additional data for the event */
  26267. additionalData?: any);
  26268. /**
  26269. * Helper function to auto-create an ActionEvent from a source mesh.
  26270. * @param source The source mesh that triggered the event
  26271. * @param evt The original (browser) event
  26272. * @param additionalData additional data for the event
  26273. * @returns the new ActionEvent
  26274. */
  26275. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26276. /**
  26277. * Helper function to auto-create an ActionEvent from a source sprite
  26278. * @param source The source sprite that triggered the event
  26279. * @param scene Scene associated with the sprite
  26280. * @param evt The original (browser) event
  26281. * @param additionalData additional data for the event
  26282. * @returns the new ActionEvent
  26283. */
  26284. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26285. /**
  26286. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26287. * @param scene the scene where the event occurred
  26288. * @param evt The original (browser) event
  26289. * @returns the new ActionEvent
  26290. */
  26291. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26292. /**
  26293. * Helper function to auto-create an ActionEvent from a primitive
  26294. * @param prim defines the target primitive
  26295. * @param pointerPos defines the pointer position
  26296. * @param evt The original (browser) event
  26297. * @param additionalData additional data for the event
  26298. * @returns the new ActionEvent
  26299. */
  26300. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26301. }
  26302. }
  26303. declare module BABYLON {
  26304. /**
  26305. * Abstract class used to decouple action Manager from scene and meshes.
  26306. * Do not instantiate.
  26307. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26308. */
  26309. export abstract class AbstractActionManager implements IDisposable {
  26310. /** Gets the list of active triggers */
  26311. static Triggers: {
  26312. [key: string]: number;
  26313. };
  26314. /** Gets the cursor to use when hovering items */
  26315. hoverCursor: string;
  26316. /** Gets the list of actions */
  26317. actions: IAction[];
  26318. /**
  26319. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26320. */
  26321. isRecursive: boolean;
  26322. /**
  26323. * Releases all associated resources
  26324. */
  26325. abstract dispose(): void;
  26326. /**
  26327. * Does this action manager has pointer triggers
  26328. */
  26329. abstract readonly hasPointerTriggers: boolean;
  26330. /**
  26331. * Does this action manager has pick triggers
  26332. */
  26333. abstract readonly hasPickTriggers: boolean;
  26334. /**
  26335. * Process a specific trigger
  26336. * @param trigger defines the trigger to process
  26337. * @param evt defines the event details to be processed
  26338. */
  26339. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26340. /**
  26341. * Does this action manager handles actions of any of the given triggers
  26342. * @param triggers defines the triggers to be tested
  26343. * @return a boolean indicating whether one (or more) of the triggers is handled
  26344. */
  26345. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26346. /**
  26347. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26348. * speed.
  26349. * @param triggerA defines the trigger to be tested
  26350. * @param triggerB defines the trigger to be tested
  26351. * @return a boolean indicating whether one (or more) of the triggers is handled
  26352. */
  26353. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26354. /**
  26355. * Does this action manager handles actions of a given trigger
  26356. * @param trigger defines the trigger to be tested
  26357. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26358. * @return whether the trigger is handled
  26359. */
  26360. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26361. /**
  26362. * Serialize this manager to a JSON object
  26363. * @param name defines the property name to store this manager
  26364. * @returns a JSON representation of this manager
  26365. */
  26366. abstract serialize(name: string): any;
  26367. /**
  26368. * Registers an action to this action manager
  26369. * @param action defines the action to be registered
  26370. * @return the action amended (prepared) after registration
  26371. */
  26372. abstract registerAction(action: IAction): Nullable<IAction>;
  26373. /**
  26374. * Unregisters an action to this action manager
  26375. * @param action defines the action to be unregistered
  26376. * @return a boolean indicating whether the action has been unregistered
  26377. */
  26378. abstract unregisterAction(action: IAction): Boolean;
  26379. /**
  26380. * Does exist one action manager with at least one trigger
  26381. **/
  26382. static readonly HasTriggers: boolean;
  26383. /**
  26384. * Does exist one action manager with at least one pick trigger
  26385. **/
  26386. static readonly HasPickTriggers: boolean;
  26387. /**
  26388. * Does exist one action manager that handles actions of a given trigger
  26389. * @param trigger defines the trigger to be tested
  26390. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26391. **/
  26392. static HasSpecificTrigger(trigger: number): boolean;
  26393. }
  26394. }
  26395. declare module BABYLON {
  26396. /**
  26397. * Defines how a node can be built from a string name.
  26398. */
  26399. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26400. /**
  26401. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26402. */
  26403. export class Node implements IBehaviorAware<Node> {
  26404. /** @hidden */ private static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26405. private static _NodeConstructors;
  26406. /**
  26407. * Add a new node constructor
  26408. * @param type defines the type name of the node to construct
  26409. * @param constructorFunc defines the constructor function
  26410. */
  26411. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26412. /**
  26413. * Returns a node constructor based on type name
  26414. * @param type defines the type name
  26415. * @param name defines the new node name
  26416. * @param scene defines the hosting scene
  26417. * @param options defines optional options to transmit to constructors
  26418. * @returns the new constructor or null
  26419. */
  26420. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26421. /**
  26422. * Gets or sets the name of the node
  26423. */
  26424. name: string;
  26425. /**
  26426. * Gets or sets the id of the node
  26427. */
  26428. id: string;
  26429. /**
  26430. * Gets or sets the unique id of the node
  26431. */
  26432. uniqueId: number;
  26433. /**
  26434. * Gets or sets a string used to store user defined state for the node
  26435. */
  26436. state: string;
  26437. /**
  26438. * Gets or sets an object used to store user defined information for the node
  26439. */
  26440. metadata: any;
  26441. /**
  26442. * For internal use only. Please do not use.
  26443. */
  26444. reservedDataStore: any;
  26445. /**
  26446. * List of inspectable custom properties (used by the Inspector)
  26447. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26448. */
  26449. inspectableCustomProperties: IInspectable[];
  26450. private _doNotSerialize;
  26451. /**
  26452. * Gets or sets a boolean used to define if the node must be serialized
  26453. */
  26454. doNotSerialize: boolean;
  26455. /** @hidden */ private _isDisposed: boolean;
  26456. /**
  26457. * Gets a list of Animations associated with the node
  26458. */
  26459. animations: Animation[];
  26460. protected _ranges: {
  26461. [name: string]: Nullable<AnimationRange>;
  26462. };
  26463. /**
  26464. * Callback raised when the node is ready to be used
  26465. */
  26466. onReady: Nullable<(node: Node) => void>;
  26467. private _isEnabled;
  26468. private _isParentEnabled;
  26469. private _isReady;
  26470. /** @hidden */ private _currentRenderId: number;
  26471. private _parentUpdateId;
  26472. /** @hidden */ private _childUpdateId: number;
  26473. /** @hidden */ private _waitingParentId: Nullable<string>;
  26474. /** @hidden */ private _scene: Scene;
  26475. /** @hidden */ private _cache: any;
  26476. private _parentNode;
  26477. private _children;
  26478. /** @hidden */ private _worldMatrix: Matrix;
  26479. /** @hidden */ private _worldMatrixDeterminant: number;
  26480. /** @hidden */ private _worldMatrixDeterminantIsDirty: boolean;
  26481. /** @hidden */
  26482. private _sceneRootNodesIndex;
  26483. /**
  26484. * Gets a boolean indicating if the node has been disposed
  26485. * @returns true if the node was disposed
  26486. */
  26487. isDisposed(): boolean;
  26488. /**
  26489. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26490. * @see https://doc.babylonjs.com/how_to/parenting
  26491. */
  26492. parent: Nullable<Node>;
  26493. private addToSceneRootNodes;
  26494. private removeFromSceneRootNodes;
  26495. private _animationPropertiesOverride;
  26496. /**
  26497. * Gets or sets the animation properties override
  26498. */
  26499. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26500. /**
  26501. * Gets a string idenfifying the name of the class
  26502. * @returns "Node" string
  26503. */
  26504. getClassName(): string;
  26505. /** @hidden */ protected readonly _isNode: boolean;
  26506. /**
  26507. * An event triggered when the mesh is disposed
  26508. */
  26509. onDisposeObservable: Observable<Node>;
  26510. private _onDisposeObserver;
  26511. /**
  26512. * Sets a callback that will be raised when the node will be disposed
  26513. */
  26514. onDispose: () => void;
  26515. /**
  26516. * Creates a new Node
  26517. * @param name the name and id to be given to this node
  26518. * @param scene the scene this node will be added to
  26519. * @param addToRootNodes the node will be added to scene.rootNodes
  26520. */
  26521. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26522. /**
  26523. * Gets the scene of the node
  26524. * @returns a scene
  26525. */
  26526. getScene(): Scene;
  26527. /**
  26528. * Gets the engine of the node
  26529. * @returns a Engine
  26530. */
  26531. getEngine(): Engine;
  26532. private _behaviors;
  26533. /**
  26534. * Attach a behavior to the node
  26535. * @see http://doc.babylonjs.com/features/behaviour
  26536. * @param behavior defines the behavior to attach
  26537. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26538. * @returns the current Node
  26539. */
  26540. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26541. /**
  26542. * Remove an attached behavior
  26543. * @see http://doc.babylonjs.com/features/behaviour
  26544. * @param behavior defines the behavior to attach
  26545. * @returns the current Node
  26546. */
  26547. removeBehavior(behavior: Behavior<Node>): Node;
  26548. /**
  26549. * Gets the list of attached behaviors
  26550. * @see http://doc.babylonjs.com/features/behaviour
  26551. */
  26552. readonly behaviors: Behavior<Node>[];
  26553. /**
  26554. * Gets an attached behavior by name
  26555. * @param name defines the name of the behavior to look for
  26556. * @see http://doc.babylonjs.com/features/behaviour
  26557. * @returns null if behavior was not found else the requested behavior
  26558. */
  26559. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26560. /**
  26561. * Returns the latest update of the World matrix
  26562. * @returns a Matrix
  26563. */
  26564. getWorldMatrix(): Matrix;
  26565. /** @hidden */ private _getWorldMatrixDeterminant(): number;
  26566. /**
  26567. * Returns directly the latest state of the mesh World matrix.
  26568. * A Matrix is returned.
  26569. */
  26570. readonly worldMatrixFromCache: Matrix;
  26571. /** @hidden */ private _initCache(): void;
  26572. /** @hidden */
  26573. updateCache(force?: boolean): void;
  26574. /** @hidden */ private _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26575. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  26576. /** @hidden */ private _isSynchronized(): boolean;
  26577. /** @hidden */ private _markSyncedWithParent(): void;
  26578. /** @hidden */
  26579. isSynchronizedWithParent(): boolean;
  26580. /** @hidden */
  26581. isSynchronized(): boolean;
  26582. /**
  26583. * Is this node ready to be used/rendered
  26584. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26585. * @return true if the node is ready
  26586. */
  26587. isReady(completeCheck?: boolean): boolean;
  26588. /**
  26589. * Is this node enabled?
  26590. * 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
  26591. * @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
  26592. * @return whether this node (and its parent) is enabled
  26593. */
  26594. isEnabled(checkAncestors?: boolean): boolean;
  26595. /** @hidden */
  26596. protected _syncParentEnabledState(): void;
  26597. /**
  26598. * Set the enabled state of this node
  26599. * @param value defines the new enabled state
  26600. */
  26601. setEnabled(value: boolean): void;
  26602. /**
  26603. * Is this node a descendant of the given node?
  26604. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26605. * @param ancestor defines the parent node to inspect
  26606. * @returns a boolean indicating if this node is a descendant of the given node
  26607. */
  26608. isDescendantOf(ancestor: Node): boolean;
  26609. /** @hidden */ private _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26610. /**
  26611. * Will return all nodes that have this node as ascendant
  26612. * @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
  26613. * @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
  26614. * @return all children nodes of all types
  26615. */
  26616. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26617. /**
  26618. * Get all child-meshes of this node
  26619. * @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)
  26620. * @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
  26621. * @returns an array of AbstractMesh
  26622. */
  26623. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26624. /**
  26625. * Get all direct children of this node
  26626. * @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
  26627. * @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)
  26628. * @returns an array of Node
  26629. */
  26630. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26631. /** @hidden */ private _setReady(state: boolean): void;
  26632. /**
  26633. * Get an animation by name
  26634. * @param name defines the name of the animation to look for
  26635. * @returns null if not found else the requested animation
  26636. */
  26637. getAnimationByName(name: string): Nullable<Animation>;
  26638. /**
  26639. * Creates an animation range for this node
  26640. * @param name defines the name of the range
  26641. * @param from defines the starting key
  26642. * @param to defines the end key
  26643. */
  26644. createAnimationRange(name: string, from: number, to: number): void;
  26645. /**
  26646. * Delete a specific animation range
  26647. * @param name defines the name of the range to delete
  26648. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26649. */
  26650. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26651. /**
  26652. * Get an animation range by name
  26653. * @param name defines the name of the animation range to look for
  26654. * @returns null if not found else the requested animation range
  26655. */
  26656. getAnimationRange(name: string): Nullable<AnimationRange>;
  26657. /**
  26658. * Gets the list of all animation ranges defined on this node
  26659. * @returns an array
  26660. */
  26661. getAnimationRanges(): Nullable<AnimationRange>[];
  26662. /**
  26663. * Will start the animation sequence
  26664. * @param name defines the range frames for animation sequence
  26665. * @param loop defines if the animation should loop (false by default)
  26666. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26667. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26668. * @returns the object created for this animation. If range does not exist, it will return null
  26669. */
  26670. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26671. /**
  26672. * Serialize animation ranges into a JSON compatible object
  26673. * @returns serialization object
  26674. */
  26675. serializeAnimationRanges(): any;
  26676. /**
  26677. * Computes the world matrix of the node
  26678. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26679. * @returns the world matrix
  26680. */
  26681. computeWorldMatrix(force?: boolean): Matrix;
  26682. /**
  26683. * Releases resources associated with this node.
  26684. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26685. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26686. */
  26687. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26688. /**
  26689. * Parse animation range data from a serialization object and store them into a given node
  26690. * @param node defines where to store the animation ranges
  26691. * @param parsedNode defines the serialization object to read data from
  26692. * @param scene defines the hosting scene
  26693. */
  26694. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26695. /**
  26696. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26697. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26698. * @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
  26699. * @returns the new bounding vectors
  26700. */
  26701. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26702. min: Vector3;
  26703. max: Vector3;
  26704. };
  26705. }
  26706. }
  26707. declare module BABYLON {
  26708. /**
  26709. * @hidden
  26710. */
  26711. export class _IAnimationState {
  26712. key: number;
  26713. repeatCount: number;
  26714. workValue?: any;
  26715. loopMode?: number;
  26716. offsetValue?: any;
  26717. highLimitValue?: any;
  26718. }
  26719. /**
  26720. * Class used to store any kind of animation
  26721. */
  26722. export class Animation {
  26723. /**Name of the animation */
  26724. name: string;
  26725. /**Property to animate */
  26726. targetProperty: string;
  26727. /**The frames per second of the animation */
  26728. framePerSecond: number;
  26729. /**The data type of the animation */
  26730. dataType: number;
  26731. /**The loop mode of the animation */
  26732. loopMode?: number | undefined;
  26733. /**Specifies if blending should be enabled */
  26734. enableBlending?: boolean | undefined;
  26735. /**
  26736. * Use matrix interpolation instead of using direct key value when animating matrices
  26737. */
  26738. static AllowMatricesInterpolation: boolean;
  26739. /**
  26740. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26741. */
  26742. static AllowMatrixDecomposeForInterpolation: boolean;
  26743. /**
  26744. * Stores the key frames of the animation
  26745. */
  26746. private _keys;
  26747. /**
  26748. * Stores the easing function of the animation
  26749. */
  26750. private _easingFunction;
  26751. /**
  26752. * @hidden Internal use only
  26753. */ private _runtimeAnimations: RuntimeAnimation[];
  26754. /**
  26755. * The set of event that will be linked to this animation
  26756. */
  26757. private _events;
  26758. /**
  26759. * Stores an array of target property paths
  26760. */
  26761. targetPropertyPath: string[];
  26762. /**
  26763. * Stores the blending speed of the animation
  26764. */
  26765. blendingSpeed: number;
  26766. /**
  26767. * Stores the animation ranges for the animation
  26768. */
  26769. private _ranges;
  26770. /**
  26771. * @hidden Internal use
  26772. */ private static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26773. /**
  26774. * Sets up an animation
  26775. * @param property The property to animate
  26776. * @param animationType The animation type to apply
  26777. * @param framePerSecond The frames per second of the animation
  26778. * @param easingFunction The easing function used in the animation
  26779. * @returns The created animation
  26780. */
  26781. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26782. /**
  26783. * Create and start an animation on a node
  26784. * @param name defines the name of the global animation that will be run on all nodes
  26785. * @param node defines the root node where the animation will take place
  26786. * @param targetProperty defines property to animate
  26787. * @param framePerSecond defines the number of frame per second yo use
  26788. * @param totalFrame defines the number of frames in total
  26789. * @param from defines the initial value
  26790. * @param to defines the final value
  26791. * @param loopMode defines which loop mode you want to use (off by default)
  26792. * @param easingFunction defines the easing function to use (linear by default)
  26793. * @param onAnimationEnd defines the callback to call when animation end
  26794. * @returns the animatable created for this animation
  26795. */
  26796. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26797. /**
  26798. * Create and start an animation on a node and its descendants
  26799. * @param name defines the name of the global animation that will be run on all nodes
  26800. * @param node defines the root node where the animation will take place
  26801. * @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
  26802. * @param targetProperty defines property to animate
  26803. * @param framePerSecond defines the number of frame per second to use
  26804. * @param totalFrame defines the number of frames in total
  26805. * @param from defines the initial value
  26806. * @param to defines the final value
  26807. * @param loopMode defines which loop mode you want to use (off by default)
  26808. * @param easingFunction defines the easing function to use (linear by default)
  26809. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26810. * @returns the list of animatables created for all nodes
  26811. * @example https://www.babylonjs-playground.com/#MH0VLI
  26812. */
  26813. 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[]>;
  26814. /**
  26815. * Creates a new animation, merges it with the existing animations and starts it
  26816. * @param name Name of the animation
  26817. * @param node Node which contains the scene that begins the animations
  26818. * @param targetProperty Specifies which property to animate
  26819. * @param framePerSecond The frames per second of the animation
  26820. * @param totalFrame The total number of frames
  26821. * @param from The frame at the beginning of the animation
  26822. * @param to The frame at the end of the animation
  26823. * @param loopMode Specifies the loop mode of the animation
  26824. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26825. * @param onAnimationEnd Callback to run once the animation is complete
  26826. * @returns Nullable animation
  26827. */
  26828. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26829. /**
  26830. * Transition property of an host to the target Value
  26831. * @param property The property to transition
  26832. * @param targetValue The target Value of the property
  26833. * @param host The object where the property to animate belongs
  26834. * @param scene Scene used to run the animation
  26835. * @param frameRate Framerate (in frame/s) to use
  26836. * @param transition The transition type we want to use
  26837. * @param duration The duration of the animation, in milliseconds
  26838. * @param onAnimationEnd Callback trigger at the end of the animation
  26839. * @returns Nullable animation
  26840. */
  26841. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26842. /**
  26843. * Return the array of runtime animations currently using this animation
  26844. */
  26845. readonly runtimeAnimations: RuntimeAnimation[];
  26846. /**
  26847. * Specifies if any of the runtime animations are currently running
  26848. */
  26849. readonly hasRunningRuntimeAnimations: boolean;
  26850. /**
  26851. * Initializes the animation
  26852. * @param name Name of the animation
  26853. * @param targetProperty Property to animate
  26854. * @param framePerSecond The frames per second of the animation
  26855. * @param dataType The data type of the animation
  26856. * @param loopMode The loop mode of the animation
  26857. * @param enableBlending Specifies if blending should be enabled
  26858. */
  26859. constructor(
  26860. /**Name of the animation */
  26861. name: string,
  26862. /**Property to animate */
  26863. targetProperty: string,
  26864. /**The frames per second of the animation */
  26865. framePerSecond: number,
  26866. /**The data type of the animation */
  26867. dataType: number,
  26868. /**The loop mode of the animation */
  26869. loopMode?: number | undefined,
  26870. /**Specifies if blending should be enabled */
  26871. enableBlending?: boolean | undefined);
  26872. /**
  26873. * Converts the animation to a string
  26874. * @param fullDetails support for multiple levels of logging within scene loading
  26875. * @returns String form of the animation
  26876. */
  26877. toString(fullDetails?: boolean): string;
  26878. /**
  26879. * Add an event to this animation
  26880. * @param event Event to add
  26881. */
  26882. addEvent(event: AnimationEvent): void;
  26883. /**
  26884. * Remove all events found at the given frame
  26885. * @param frame The frame to remove events from
  26886. */
  26887. removeEvents(frame: number): void;
  26888. /**
  26889. * Retrieves all the events from the animation
  26890. * @returns Events from the animation
  26891. */
  26892. getEvents(): AnimationEvent[];
  26893. /**
  26894. * Creates an animation range
  26895. * @param name Name of the animation range
  26896. * @param from Starting frame of the animation range
  26897. * @param to Ending frame of the animation
  26898. */
  26899. createRange(name: string, from: number, to: number): void;
  26900. /**
  26901. * Deletes an animation range by name
  26902. * @param name Name of the animation range to delete
  26903. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26904. */
  26905. deleteRange(name: string, deleteFrames?: boolean): void;
  26906. /**
  26907. * Gets the animation range by name, or null if not defined
  26908. * @param name Name of the animation range
  26909. * @returns Nullable animation range
  26910. */
  26911. getRange(name: string): Nullable<AnimationRange>;
  26912. /**
  26913. * Gets the key frames from the animation
  26914. * @returns The key frames of the animation
  26915. */
  26916. getKeys(): Array<IAnimationKey>;
  26917. /**
  26918. * Gets the highest frame rate of the animation
  26919. * @returns Highest frame rate of the animation
  26920. */
  26921. getHighestFrame(): number;
  26922. /**
  26923. * Gets the easing function of the animation
  26924. * @returns Easing function of the animation
  26925. */
  26926. getEasingFunction(): IEasingFunction;
  26927. /**
  26928. * Sets the easing function of the animation
  26929. * @param easingFunction A custom mathematical formula for animation
  26930. */
  26931. setEasingFunction(easingFunction: EasingFunction): void;
  26932. /**
  26933. * Interpolates a scalar linearly
  26934. * @param startValue Start value of the animation curve
  26935. * @param endValue End value of the animation curve
  26936. * @param gradient Scalar amount to interpolate
  26937. * @returns Interpolated scalar value
  26938. */
  26939. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26940. /**
  26941. * Interpolates a scalar cubically
  26942. * @param startValue Start value of the animation curve
  26943. * @param outTangent End tangent of the animation
  26944. * @param endValue End value of the animation curve
  26945. * @param inTangent Start tangent of the animation curve
  26946. * @param gradient Scalar amount to interpolate
  26947. * @returns Interpolated scalar value
  26948. */
  26949. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26950. /**
  26951. * Interpolates a quaternion using a spherical linear interpolation
  26952. * @param startValue Start value of the animation curve
  26953. * @param endValue End value of the animation curve
  26954. * @param gradient Scalar amount to interpolate
  26955. * @returns Interpolated quaternion value
  26956. */
  26957. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26958. /**
  26959. * Interpolates a quaternion cubically
  26960. * @param startValue Start value of the animation curve
  26961. * @param outTangent End tangent of the animation curve
  26962. * @param endValue End value of the animation curve
  26963. * @param inTangent Start tangent of the animation curve
  26964. * @param gradient Scalar amount to interpolate
  26965. * @returns Interpolated quaternion value
  26966. */
  26967. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26968. /**
  26969. * Interpolates a Vector3 linearl
  26970. * @param startValue Start value of the animation curve
  26971. * @param endValue End value of the animation curve
  26972. * @param gradient Scalar amount to interpolate
  26973. * @returns Interpolated scalar value
  26974. */
  26975. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26976. /**
  26977. * Interpolates a Vector3 cubically
  26978. * @param startValue Start value of the animation curve
  26979. * @param outTangent End tangent of the animation
  26980. * @param endValue End value of the animation curve
  26981. * @param inTangent Start tangent of the animation curve
  26982. * @param gradient Scalar amount to interpolate
  26983. * @returns InterpolatedVector3 value
  26984. */
  26985. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26986. /**
  26987. * Interpolates a Vector2 linearly
  26988. * @param startValue Start value of the animation curve
  26989. * @param endValue End value of the animation curve
  26990. * @param gradient Scalar amount to interpolate
  26991. * @returns Interpolated Vector2 value
  26992. */
  26993. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26994. /**
  26995. * Interpolates a Vector2 cubically
  26996. * @param startValue Start value of the animation curve
  26997. * @param outTangent End tangent of the animation
  26998. * @param endValue End value of the animation curve
  26999. * @param inTangent Start tangent of the animation curve
  27000. * @param gradient Scalar amount to interpolate
  27001. * @returns Interpolated Vector2 value
  27002. */
  27003. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27004. /**
  27005. * Interpolates a size linearly
  27006. * @param startValue Start value of the animation curve
  27007. * @param endValue End value of the animation curve
  27008. * @param gradient Scalar amount to interpolate
  27009. * @returns Interpolated Size value
  27010. */
  27011. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27012. /**
  27013. * Interpolates a Color3 linearly
  27014. * @param startValue Start value of the animation curve
  27015. * @param endValue End value of the animation curve
  27016. * @param gradient Scalar amount to interpolate
  27017. * @returns Interpolated Color3 value
  27018. */
  27019. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27020. /**
  27021. * Interpolates a Color4 linearly
  27022. * @param startValue Start value of the animation curve
  27023. * @param endValue End value of the animation curve
  27024. * @param gradient Scalar amount to interpolate
  27025. * @returns Interpolated Color3 value
  27026. */
  27027. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  27028. /**
  27029. * @hidden Internal use only
  27030. */ private _getKeyValue(value: any): any;
  27031. /**
  27032. * @hidden Internal use only
  27033. */ private _interpolate(currentFrame: number, state: _IAnimationState): any;
  27034. /**
  27035. * Defines the function to use to interpolate matrices
  27036. * @param startValue defines the start matrix
  27037. * @param endValue defines the end matrix
  27038. * @param gradient defines the gradient between both matrices
  27039. * @param result defines an optional target matrix where to store the interpolation
  27040. * @returns the interpolated matrix
  27041. */
  27042. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27043. /**
  27044. * Makes a copy of the animation
  27045. * @returns Cloned animation
  27046. */
  27047. clone(): Animation;
  27048. /**
  27049. * Sets the key frames of the animation
  27050. * @param values The animation key frames to set
  27051. */
  27052. setKeys(values: Array<IAnimationKey>): void;
  27053. /**
  27054. * Serializes the animation to an object
  27055. * @returns Serialized object
  27056. */
  27057. serialize(): any;
  27058. /**
  27059. * Float animation type
  27060. */
  27061. static readonly ANIMATIONTYPE_FLOAT: number;
  27062. /**
  27063. * Vector3 animation type
  27064. */
  27065. static readonly ANIMATIONTYPE_VECTOR3: number;
  27066. /**
  27067. * Quaternion animation type
  27068. */
  27069. static readonly ANIMATIONTYPE_QUATERNION: number;
  27070. /**
  27071. * Matrix animation type
  27072. */
  27073. static readonly ANIMATIONTYPE_MATRIX: number;
  27074. /**
  27075. * Color3 animation type
  27076. */
  27077. static readonly ANIMATIONTYPE_COLOR3: number;
  27078. /**
  27079. * Color3 animation type
  27080. */
  27081. static readonly ANIMATIONTYPE_COLOR4: number;
  27082. /**
  27083. * Vector2 animation type
  27084. */
  27085. static readonly ANIMATIONTYPE_VECTOR2: number;
  27086. /**
  27087. * Size animation type
  27088. */
  27089. static readonly ANIMATIONTYPE_SIZE: number;
  27090. /**
  27091. * Relative Loop Mode
  27092. */
  27093. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27094. /**
  27095. * Cycle Loop Mode
  27096. */
  27097. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27098. /**
  27099. * Constant Loop Mode
  27100. */
  27101. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27102. /** @hidden */ private static _UniversalLerp(left: any, right: any, amount: number): any;
  27103. /**
  27104. * Parses an animation object and creates an animation
  27105. * @param parsedAnimation Parsed animation object
  27106. * @returns Animation object
  27107. */
  27108. static Parse(parsedAnimation: any): Animation;
  27109. /**
  27110. * Appends the serialized animations from the source animations
  27111. * @param source Source containing the animations
  27112. * @param destination Target to store the animations
  27113. */
  27114. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27115. }
  27116. }
  27117. declare module BABYLON {
  27118. /**
  27119. * Interface containing an array of animations
  27120. */
  27121. export interface IAnimatable {
  27122. /**
  27123. * Array of animations
  27124. */
  27125. animations: Nullable<Array<Animation>>;
  27126. }
  27127. }
  27128. declare module BABYLON {
  27129. /**
  27130. * This represents all the required information to add a fresnel effect on a material:
  27131. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27132. */
  27133. export class FresnelParameters {
  27134. private _isEnabled;
  27135. /**
  27136. * Define if the fresnel effect is enable or not.
  27137. */
  27138. isEnabled: boolean;
  27139. /**
  27140. * Define the color used on edges (grazing angle)
  27141. */
  27142. leftColor: Color3;
  27143. /**
  27144. * Define the color used on center
  27145. */
  27146. rightColor: Color3;
  27147. /**
  27148. * Define bias applied to computed fresnel term
  27149. */
  27150. bias: number;
  27151. /**
  27152. * Defined the power exponent applied to fresnel term
  27153. */
  27154. power: number;
  27155. /**
  27156. * Clones the current fresnel and its valuues
  27157. * @returns a clone fresnel configuration
  27158. */
  27159. clone(): FresnelParameters;
  27160. /**
  27161. * Serializes the current fresnel parameters to a JSON representation.
  27162. * @return the JSON serialization
  27163. */
  27164. serialize(): any;
  27165. /**
  27166. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27167. * @param parsedFresnelParameters Define the JSON representation
  27168. * @returns the parsed parameters
  27169. */
  27170. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27171. }
  27172. }
  27173. declare module BABYLON {
  27174. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27175. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27176. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27177. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27178. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27179. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27180. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27181. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27182. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27183. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27184. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27185. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27186. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27187. /**
  27188. * Decorator used to define property that can be serialized as reference to a camera
  27189. * @param sourceName defines the name of the property to decorate
  27190. */
  27191. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27192. /**
  27193. * Class used to help serialization objects
  27194. */
  27195. export class SerializationHelper {
  27196. /** @hidden */ private static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27197. /** @hidden */ private static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27198. /** @hidden */ private static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27199. /** @hidden */ private static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27200. /**
  27201. * Appends the serialized animations from the source animations
  27202. * @param source Source containing the animations
  27203. * @param destination Target to store the animations
  27204. */
  27205. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27206. /**
  27207. * Static function used to serialized a specific entity
  27208. * @param entity defines the entity to serialize
  27209. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27210. * @returns a JSON compatible object representing the serialization of the entity
  27211. */
  27212. static Serialize<T>(entity: T, serializationObject?: any): any;
  27213. /**
  27214. * Creates a new entity from a serialization data object
  27215. * @param creationFunction defines a function used to instanciated the new entity
  27216. * @param source defines the source serialization data
  27217. * @param scene defines the hosting scene
  27218. * @param rootUrl defines the root url for resources
  27219. * @returns a new entity
  27220. */
  27221. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27222. /**
  27223. * Clones an object
  27224. * @param creationFunction defines the function used to instanciate the new object
  27225. * @param source defines the source object
  27226. * @returns the cloned object
  27227. */
  27228. static Clone<T>(creationFunction: () => T, source: T): T;
  27229. /**
  27230. * Instanciates a new object based on a source one (some data will be shared between both object)
  27231. * @param creationFunction defines the function used to instanciate the new object
  27232. * @param source defines the source object
  27233. * @returns the new object
  27234. */
  27235. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27236. }
  27237. }
  27238. declare module BABYLON {
  27239. /**
  27240. * Class used to manipulate GUIDs
  27241. */
  27242. export class GUID {
  27243. /**
  27244. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27245. * Be aware Math.random() could cause collisions, but:
  27246. * "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"
  27247. * @returns a pseudo random id
  27248. */
  27249. static RandomId(): string;
  27250. }
  27251. }
  27252. declare module BABYLON {
  27253. /**
  27254. * Base class of all the textures in babylon.
  27255. * It groups all the common properties the materials, post process, lights... might need
  27256. * in order to make a correct use of the texture.
  27257. */
  27258. export class BaseTexture implements IAnimatable {
  27259. /**
  27260. * Default anisotropic filtering level for the application.
  27261. * It is set to 4 as a good tradeoff between perf and quality.
  27262. */
  27263. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27264. /**
  27265. * Gets or sets the unique id of the texture
  27266. */
  27267. uniqueId: number;
  27268. /**
  27269. * Define the name of the texture.
  27270. */
  27271. name: string;
  27272. /**
  27273. * Gets or sets an object used to store user defined information.
  27274. */
  27275. metadata: any;
  27276. /**
  27277. * For internal use only. Please do not use.
  27278. */
  27279. reservedDataStore: any;
  27280. private _hasAlpha;
  27281. /**
  27282. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27283. */
  27284. hasAlpha: boolean;
  27285. /**
  27286. * Defines if the alpha value should be determined via the rgb values.
  27287. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27288. */
  27289. getAlphaFromRGB: boolean;
  27290. /**
  27291. * Intensity or strength of the texture.
  27292. * It is commonly used by materials to fine tune the intensity of the texture
  27293. */
  27294. level: number;
  27295. /**
  27296. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27297. * This is part of the texture as textures usually maps to one uv set.
  27298. */
  27299. coordinatesIndex: number;
  27300. private _coordinatesMode;
  27301. /**
  27302. * How a texture is mapped.
  27303. *
  27304. * | Value | Type | Description |
  27305. * | ----- | ----------------------------------- | ----------- |
  27306. * | 0 | EXPLICIT_MODE | |
  27307. * | 1 | SPHERICAL_MODE | |
  27308. * | 2 | PLANAR_MODE | |
  27309. * | 3 | CUBIC_MODE | |
  27310. * | 4 | PROJECTION_MODE | |
  27311. * | 5 | SKYBOX_MODE | |
  27312. * | 6 | INVCUBIC_MODE | |
  27313. * | 7 | EQUIRECTANGULAR_MODE | |
  27314. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27315. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27316. */
  27317. coordinatesMode: number;
  27318. /**
  27319. * | Value | Type | Description |
  27320. * | ----- | ------------------ | ----------- |
  27321. * | 0 | CLAMP_ADDRESSMODE | |
  27322. * | 1 | WRAP_ADDRESSMODE | |
  27323. * | 2 | MIRROR_ADDRESSMODE | |
  27324. */
  27325. wrapU: number;
  27326. /**
  27327. * | Value | Type | Description |
  27328. * | ----- | ------------------ | ----------- |
  27329. * | 0 | CLAMP_ADDRESSMODE | |
  27330. * | 1 | WRAP_ADDRESSMODE | |
  27331. * | 2 | MIRROR_ADDRESSMODE | |
  27332. */
  27333. wrapV: number;
  27334. /**
  27335. * | Value | Type | Description |
  27336. * | ----- | ------------------ | ----------- |
  27337. * | 0 | CLAMP_ADDRESSMODE | |
  27338. * | 1 | WRAP_ADDRESSMODE | |
  27339. * | 2 | MIRROR_ADDRESSMODE | |
  27340. */
  27341. wrapR: number;
  27342. /**
  27343. * With compliant hardware and browser (supporting anisotropic filtering)
  27344. * this defines the level of anisotropic filtering in the texture.
  27345. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27346. */
  27347. anisotropicFilteringLevel: number;
  27348. /**
  27349. * Define if the texture is a cube texture or if false a 2d texture.
  27350. */
  27351. isCube: boolean;
  27352. /**
  27353. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27354. */
  27355. is3D: boolean;
  27356. /**
  27357. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27358. * HDR texture are usually stored in linear space.
  27359. * This only impacts the PBR and Background materials
  27360. */
  27361. gammaSpace: boolean;
  27362. /**
  27363. * Gets or sets whether or not the texture contains RGBD data.
  27364. */
  27365. isRGBD: boolean;
  27366. /**
  27367. * Is Z inverted in the texture (useful in a cube texture).
  27368. */
  27369. invertZ: boolean;
  27370. /**
  27371. * Are mip maps generated for this texture or not.
  27372. */
  27373. readonly noMipmap: boolean;
  27374. /**
  27375. * @hidden
  27376. */
  27377. lodLevelInAlpha: boolean;
  27378. /**
  27379. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27380. */
  27381. lodGenerationOffset: number;
  27382. /**
  27383. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27384. */
  27385. lodGenerationScale: number;
  27386. /**
  27387. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27388. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27389. * average roughness values.
  27390. */
  27391. linearSpecularLOD: boolean;
  27392. /**
  27393. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27394. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27395. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27396. */
  27397. irradianceTexture: Nullable<BaseTexture>;
  27398. /**
  27399. * Define if the texture is a render target.
  27400. */
  27401. isRenderTarget: boolean;
  27402. /**
  27403. * Define the unique id of the texture in the scene.
  27404. */
  27405. readonly uid: string;
  27406. /**
  27407. * Return a string representation of the texture.
  27408. * @returns the texture as a string
  27409. */
  27410. toString(): string;
  27411. /**
  27412. * Get the class name of the texture.
  27413. * @returns "BaseTexture"
  27414. */
  27415. getClassName(): string;
  27416. /**
  27417. * Define the list of animation attached to the texture.
  27418. */
  27419. animations: Animation[];
  27420. /**
  27421. * An event triggered when the texture is disposed.
  27422. */
  27423. onDisposeObservable: Observable<BaseTexture>;
  27424. private _onDisposeObserver;
  27425. /**
  27426. * Callback triggered when the texture has been disposed.
  27427. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27428. */
  27429. onDispose: () => void;
  27430. /**
  27431. * Define the current state of the loading sequence when in delayed load mode.
  27432. */
  27433. delayLoadState: number;
  27434. private _scene;
  27435. /** @hidden */ private _texture: Nullable<InternalTexture>;
  27436. private _uid;
  27437. /**
  27438. * Define if the texture is preventinga material to render or not.
  27439. * If not and the texture is not ready, the engine will use a default black texture instead.
  27440. */
  27441. readonly isBlocking: boolean;
  27442. /**
  27443. * Instantiates a new BaseTexture.
  27444. * Base class of all the textures in babylon.
  27445. * It groups all the common properties the materials, post process, lights... might need
  27446. * in order to make a correct use of the texture.
  27447. * @param scene Define the scene the texture blongs to
  27448. */
  27449. constructor(scene: Nullable<Scene>);
  27450. /**
  27451. * Get the scene the texture belongs to.
  27452. * @returns the scene or null if undefined
  27453. */
  27454. getScene(): Nullable<Scene>;
  27455. /**
  27456. * Get the texture transform matrix used to offset tile the texture for istance.
  27457. * @returns the transformation matrix
  27458. */
  27459. getTextureMatrix(): Matrix;
  27460. /**
  27461. * Get the texture reflection matrix used to rotate/transform the reflection.
  27462. * @returns the reflection matrix
  27463. */
  27464. getReflectionTextureMatrix(): Matrix;
  27465. /**
  27466. * Get the underlying lower level texture from Babylon.
  27467. * @returns the insternal texture
  27468. */
  27469. getInternalTexture(): Nullable<InternalTexture>;
  27470. /**
  27471. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27472. * @returns true if ready or not blocking
  27473. */
  27474. isReadyOrNotBlocking(): boolean;
  27475. /**
  27476. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27477. * @returns true if fully ready
  27478. */
  27479. isReady(): boolean;
  27480. private _cachedSize;
  27481. /**
  27482. * Get the size of the texture.
  27483. * @returns the texture size.
  27484. */
  27485. getSize(): ISize;
  27486. /**
  27487. * Get the base size of the texture.
  27488. * It can be different from the size if the texture has been resized for POT for instance
  27489. * @returns the base size
  27490. */
  27491. getBaseSize(): ISize;
  27492. /**
  27493. * Update the sampling mode of the texture.
  27494. * Default is Trilinear mode.
  27495. *
  27496. * | Value | Type | Description |
  27497. * | ----- | ------------------ | ----------- |
  27498. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27499. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27500. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27501. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27502. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27503. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27504. * | 7 | NEAREST_LINEAR | |
  27505. * | 8 | NEAREST_NEAREST | |
  27506. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27507. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27508. * | 11 | LINEAR_LINEAR | |
  27509. * | 12 | LINEAR_NEAREST | |
  27510. *
  27511. * > _mag_: magnification filter (close to the viewer)
  27512. * > _min_: minification filter (far from the viewer)
  27513. * > _mip_: filter used between mip map levels
  27514. *@param samplingMode Define the new sampling mode of the texture
  27515. */
  27516. updateSamplingMode(samplingMode: number): void;
  27517. /**
  27518. * Scales the texture if is `canRescale()`
  27519. * @param ratio the resize factor we want to use to rescale
  27520. */
  27521. scale(ratio: number): void;
  27522. /**
  27523. * Get if the texture can rescale.
  27524. */
  27525. readonly canRescale: boolean;
  27526. /** @hidden */ private _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27527. /** @hidden */ private _rebuild(): void;
  27528. /**
  27529. * Triggers the load sequence in delayed load mode.
  27530. */
  27531. delayLoad(): void;
  27532. /**
  27533. * Clones the texture.
  27534. * @returns the cloned texture
  27535. */
  27536. clone(): Nullable<BaseTexture>;
  27537. /**
  27538. * Get the texture underlying type (INT, FLOAT...)
  27539. */
  27540. readonly textureType: number;
  27541. /**
  27542. * Get the texture underlying format (RGB, RGBA...)
  27543. */
  27544. readonly textureFormat: number;
  27545. /**
  27546. * Indicates that textures need to be re-calculated for all materials
  27547. */
  27548. protected _markAllSubMeshesAsTexturesDirty(): void;
  27549. /**
  27550. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27551. * This will returns an RGBA array buffer containing either in values (0-255) or
  27552. * float values (0-1) depending of the underlying buffer type.
  27553. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27554. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27555. * @param buffer defines a user defined buffer to fill with data (can be null)
  27556. * @returns The Array buffer containing the pixels data.
  27557. */
  27558. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27559. /**
  27560. * Release and destroy the underlying lower level texture aka internalTexture.
  27561. */
  27562. releaseInternalTexture(): void;
  27563. /** @hidden */ protected readonly _lodTextureHigh: Nullable<BaseTexture>;
  27564. /** @hidden */ protected readonly _lodTextureMid: Nullable<BaseTexture>;
  27565. /** @hidden */ protected readonly _lodTextureLow: Nullable<BaseTexture>;
  27566. /**
  27567. * Dispose the texture and release its associated resources.
  27568. */
  27569. dispose(): void;
  27570. /**
  27571. * Serialize the texture into a JSON representation that can be parsed later on.
  27572. * @returns the JSON representation of the texture
  27573. */
  27574. serialize(): any;
  27575. /**
  27576. * Helper function to be called back once a list of texture contains only ready textures.
  27577. * @param textures Define the list of textures to wait for
  27578. * @param callback Define the callback triggered once the entire list will be ready
  27579. */
  27580. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27581. }
  27582. }
  27583. declare module BABYLON {
  27584. /**
  27585. * Options to be used when creating an effect.
  27586. */
  27587. export interface IEffectCreationOptions {
  27588. /**
  27589. * Atrributes that will be used in the shader.
  27590. */
  27591. attributes: string[];
  27592. /**
  27593. * Uniform varible names that will be set in the shader.
  27594. */
  27595. uniformsNames: string[];
  27596. /**
  27597. * Uniform buffer varible names that will be set in the shader.
  27598. */
  27599. uniformBuffersNames: string[];
  27600. /**
  27601. * Sampler texture variable names that will be set in the shader.
  27602. */
  27603. samplers: string[];
  27604. /**
  27605. * Define statements that will be set in the shader.
  27606. */
  27607. defines: any;
  27608. /**
  27609. * Possible fallbacks for this effect to improve performance when needed.
  27610. */
  27611. fallbacks: Nullable<IEffectFallbacks>;
  27612. /**
  27613. * Callback that will be called when the shader is compiled.
  27614. */
  27615. onCompiled: Nullable<(effect: Effect) => void>;
  27616. /**
  27617. * Callback that will be called if an error occurs during shader compilation.
  27618. */
  27619. onError: Nullable<(effect: Effect, errors: string) => void>;
  27620. /**
  27621. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  27622. */
  27623. indexParameters?: any;
  27624. /**
  27625. * Max number of lights that can be used in the shader.
  27626. */
  27627. maxSimultaneousLights?: number;
  27628. /**
  27629. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  27630. */
  27631. transformFeedbackVaryings?: Nullable<string[]>;
  27632. }
  27633. /**
  27634. * Effect containing vertex and fragment shader that can be executed on an object.
  27635. */
  27636. export class Effect implements IDisposable {
  27637. /**
  27638. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27639. */
  27640. static ShadersRepository: string;
  27641. /**
  27642. * Name of the effect.
  27643. */
  27644. name: any;
  27645. /**
  27646. * String container all the define statements that should be set on the shader.
  27647. */
  27648. defines: string;
  27649. /**
  27650. * Callback that will be called when the shader is compiled.
  27651. */
  27652. onCompiled: Nullable<(effect: Effect) => void>;
  27653. /**
  27654. * Callback that will be called if an error occurs during shader compilation.
  27655. */
  27656. onError: Nullable<(effect: Effect, errors: string) => void>;
  27657. /**
  27658. * Callback that will be called when effect is bound.
  27659. */
  27660. onBind: Nullable<(effect: Effect) => void>;
  27661. /**
  27662. * Unique ID of the effect.
  27663. */
  27664. uniqueId: number;
  27665. /**
  27666. * Observable that will be called when the shader is compiled.
  27667. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  27668. */
  27669. onCompileObservable: Observable<Effect>;
  27670. /**
  27671. * Observable that will be called if an error occurs during shader compilation.
  27672. */
  27673. onErrorObservable: Observable<Effect>;
  27674. /** @hidden */ private _onBindObservable: Nullable<Observable<Effect>>;
  27675. /**
  27676. * Observable that will be called when effect is bound.
  27677. */
  27678. readonly onBindObservable: Observable<Effect>;
  27679. /** @hidden */ private _bonesComputationForcedToCPU: boolean;
  27680. private static _uniqueIdSeed;
  27681. private _engine;
  27682. private _uniformBuffersNames;
  27683. private _uniformsNames;
  27684. private _samplerList;
  27685. private _samplers;
  27686. private _isReady;
  27687. private _compilationError;
  27688. private _allFallbacksProcessed;
  27689. private _attributesNames;
  27690. private _attributes;
  27691. private _uniforms;
  27692. /**
  27693. * Key for the effect.
  27694. * @hidden
  27695. */ private _key: string;
  27696. private _indexParameters;
  27697. private _fallbacks;
  27698. private _vertexSourceCode;
  27699. private _fragmentSourceCode;
  27700. private _vertexSourceCodeOverride;
  27701. private _fragmentSourceCodeOverride;
  27702. private _transformFeedbackVaryings;
  27703. /**
  27704. * Compiled shader to webGL program.
  27705. * @hidden
  27706. */ private _pipelineContext: Nullable<IPipelineContext>;
  27707. private _valueCache;
  27708. private static _baseCache;
  27709. /**
  27710. * Instantiates an effect.
  27711. * An effect can be used to create/manage/execute vertex and fragment shaders.
  27712. * @param baseName Name of the effect.
  27713. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  27714. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  27715. * @param samplers List of sampler variables that will be passed to the shader.
  27716. * @param engine Engine to be used to render the effect
  27717. * @param defines Define statements to be added to the shader.
  27718. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  27719. * @param onCompiled Callback that will be called when the shader is compiled.
  27720. * @param onError Callback that will be called if an error occurs during shader compilation.
  27721. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  27722. */
  27723. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  27724. private _useFinalCode;
  27725. /**
  27726. * Unique key for this effect
  27727. */
  27728. readonly key: string;
  27729. /**
  27730. * If the effect has been compiled and prepared.
  27731. * @returns if the effect is compiled and prepared.
  27732. */
  27733. isReady(): boolean;
  27734. private _isReadyInternal;
  27735. /**
  27736. * The engine the effect was initialized with.
  27737. * @returns the engine.
  27738. */
  27739. getEngine(): Engine;
  27740. /**
  27741. * The pipeline context for this effect
  27742. * @returns the associated pipeline context
  27743. */
  27744. getPipelineContext(): Nullable<IPipelineContext>;
  27745. /**
  27746. * The set of names of attribute variables for the shader.
  27747. * @returns An array of attribute names.
  27748. */
  27749. getAttributesNames(): string[];
  27750. /**
  27751. * Returns the attribute at the given index.
  27752. * @param index The index of the attribute.
  27753. * @returns The location of the attribute.
  27754. */
  27755. getAttributeLocation(index: number): number;
  27756. /**
  27757. * Returns the attribute based on the name of the variable.
  27758. * @param name of the attribute to look up.
  27759. * @returns the attribute location.
  27760. */
  27761. getAttributeLocationByName(name: string): number;
  27762. /**
  27763. * The number of attributes.
  27764. * @returns the numnber of attributes.
  27765. */
  27766. getAttributesCount(): number;
  27767. /**
  27768. * Gets the index of a uniform variable.
  27769. * @param uniformName of the uniform to look up.
  27770. * @returns the index.
  27771. */
  27772. getUniformIndex(uniformName: string): number;
  27773. /**
  27774. * Returns the attribute based on the name of the variable.
  27775. * @param uniformName of the uniform to look up.
  27776. * @returns the location of the uniform.
  27777. */
  27778. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  27779. /**
  27780. * Returns an array of sampler variable names
  27781. * @returns The array of sampler variable neames.
  27782. */
  27783. getSamplers(): string[];
  27784. /**
  27785. * The error from the last compilation.
  27786. * @returns the error string.
  27787. */
  27788. getCompilationError(): string;
  27789. /**
  27790. * Gets a boolean indicating that all fallbacks were used during compilation
  27791. * @returns true if all fallbacks were used
  27792. */
  27793. allFallbacksProcessed(): boolean;
  27794. /**
  27795. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  27796. * @param func The callback to be used.
  27797. */
  27798. executeWhenCompiled(func: (effect: Effect) => void): void;
  27799. private _checkIsReady;
  27800. private _loadShader;
  27801. /**
  27802. * Recompiles the webGL program
  27803. * @param vertexSourceCode The source code for the vertex shader.
  27804. * @param fragmentSourceCode The source code for the fragment shader.
  27805. * @param onCompiled Callback called when completed.
  27806. * @param onError Callback called on error.
  27807. * @hidden
  27808. */ private _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  27809. /**
  27810. * Prepares the effect
  27811. * @hidden
  27812. */ private _prepareEffect(): void;
  27813. private _processCompilationErrors;
  27814. /**
  27815. * Checks if the effect is supported. (Must be called after compilation)
  27816. */
  27817. readonly isSupported: boolean;
  27818. /**
  27819. * Binds a texture to the engine to be used as output of the shader.
  27820. * @param channel Name of the output variable.
  27821. * @param texture Texture to bind.
  27822. * @hidden
  27823. */ private _bindTexture(channel: string, texture: InternalTexture): void;
  27824. /**
  27825. * Sets a texture on the engine to be used in the shader.
  27826. * @param channel Name of the sampler variable.
  27827. * @param texture Texture to set.
  27828. */
  27829. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  27830. /**
  27831. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  27832. * @param channel Name of the sampler variable.
  27833. * @param texture Texture to set.
  27834. */
  27835. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  27836. /**
  27837. * Sets an array of textures on the engine to be used in the shader.
  27838. * @param channel Name of the variable.
  27839. * @param textures Textures to set.
  27840. */
  27841. setTextureArray(channel: string, textures: BaseTexture[]): void;
  27842. /**
  27843. * 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)
  27844. * @param channel Name of the sampler variable.
  27845. * @param postProcess Post process to get the input texture from.
  27846. */
  27847. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  27848. /**
  27849. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  27850. * 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)
  27851. * @param channel Name of the sampler variable.
  27852. * @param postProcess Post process to get the output texture from.
  27853. */
  27854. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  27855. /** @hidden */ private _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  27856. /** @hidden */ private _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  27857. /** @hidden */ private _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  27858. /** @hidden */ private _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  27859. /**
  27860. * Binds a buffer to a uniform.
  27861. * @param buffer Buffer to bind.
  27862. * @param name Name of the uniform variable to bind to.
  27863. */
  27864. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  27865. /**
  27866. * Binds block to a uniform.
  27867. * @param blockName Name of the block to bind.
  27868. * @param index Index to bind.
  27869. */
  27870. bindUniformBlock(blockName: string, index: number): void;
  27871. /**
  27872. * Sets an interger value on a uniform variable.
  27873. * @param uniformName Name of the variable.
  27874. * @param value Value to be set.
  27875. * @returns this effect.
  27876. */
  27877. setInt(uniformName: string, value: number): Effect;
  27878. /**
  27879. * Sets an int array on a uniform variable.
  27880. * @param uniformName Name of the variable.
  27881. * @param array array to be set.
  27882. * @returns this effect.
  27883. */
  27884. setIntArray(uniformName: string, array: Int32Array): Effect;
  27885. /**
  27886. * 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)
  27887. * @param uniformName Name of the variable.
  27888. * @param array array to be set.
  27889. * @returns this effect.
  27890. */
  27891. setIntArray2(uniformName: string, array: Int32Array): Effect;
  27892. /**
  27893. * 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)
  27894. * @param uniformName Name of the variable.
  27895. * @param array array to be set.
  27896. * @returns this effect.
  27897. */
  27898. setIntArray3(uniformName: string, array: Int32Array): Effect;
  27899. /**
  27900. * 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)
  27901. * @param uniformName Name of the variable.
  27902. * @param array array to be set.
  27903. * @returns this effect.
  27904. */
  27905. setIntArray4(uniformName: string, array: Int32Array): Effect;
  27906. /**
  27907. * Sets an float array on a uniform variable.
  27908. * @param uniformName Name of the variable.
  27909. * @param array array to be set.
  27910. * @returns this effect.
  27911. */
  27912. setFloatArray(uniformName: string, array: Float32Array): Effect;
  27913. /**
  27914. * 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)
  27915. * @param uniformName Name of the variable.
  27916. * @param array array to be set.
  27917. * @returns this effect.
  27918. */
  27919. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  27920. /**
  27921. * 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)
  27922. * @param uniformName Name of the variable.
  27923. * @param array array to be set.
  27924. * @returns this effect.
  27925. */
  27926. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  27927. /**
  27928. * 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)
  27929. * @param uniformName Name of the variable.
  27930. * @param array array to be set.
  27931. * @returns this effect.
  27932. */
  27933. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  27934. /**
  27935. * Sets an array on a uniform variable.
  27936. * @param uniformName Name of the variable.
  27937. * @param array array to be set.
  27938. * @returns this effect.
  27939. */
  27940. setArray(uniformName: string, array: number[]): Effect;
  27941. /**
  27942. * 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)
  27943. * @param uniformName Name of the variable.
  27944. * @param array array to be set.
  27945. * @returns this effect.
  27946. */
  27947. setArray2(uniformName: string, array: number[]): Effect;
  27948. /**
  27949. * 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)
  27950. * @param uniformName Name of the variable.
  27951. * @param array array to be set.
  27952. * @returns this effect.
  27953. */
  27954. setArray3(uniformName: string, array: number[]): Effect;
  27955. /**
  27956. * 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)
  27957. * @param uniformName Name of the variable.
  27958. * @param array array to be set.
  27959. * @returns this effect.
  27960. */
  27961. setArray4(uniformName: string, array: number[]): Effect;
  27962. /**
  27963. * Sets matrices on a uniform variable.
  27964. * @param uniformName Name of the variable.
  27965. * @param matrices matrices to be set.
  27966. * @returns this effect.
  27967. */
  27968. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  27969. /**
  27970. * Sets matrix on a uniform variable.
  27971. * @param uniformName Name of the variable.
  27972. * @param matrix matrix to be set.
  27973. * @returns this effect.
  27974. */
  27975. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  27976. /**
  27977. * 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)
  27978. * @param uniformName Name of the variable.
  27979. * @param matrix matrix to be set.
  27980. * @returns this effect.
  27981. */
  27982. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  27983. /**
  27984. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  27985. * @param uniformName Name of the variable.
  27986. * @param matrix matrix to be set.
  27987. * @returns this effect.
  27988. */
  27989. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  27990. /**
  27991. * Sets a float on a uniform variable.
  27992. * @param uniformName Name of the variable.
  27993. * @param value value to be set.
  27994. * @returns this effect.
  27995. */
  27996. setFloat(uniformName: string, value: number): Effect;
  27997. /**
  27998. * Sets a boolean on a uniform variable.
  27999. * @param uniformName Name of the variable.
  28000. * @param bool value to be set.
  28001. * @returns this effect.
  28002. */
  28003. setBool(uniformName: string, bool: boolean): Effect;
  28004. /**
  28005. * Sets a Vector2 on a uniform variable.
  28006. * @param uniformName Name of the variable.
  28007. * @param vector2 vector2 to be set.
  28008. * @returns this effect.
  28009. */
  28010. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28011. /**
  28012. * Sets a float2 on a uniform variable.
  28013. * @param uniformName Name of the variable.
  28014. * @param x First float in float2.
  28015. * @param y Second float in float2.
  28016. * @returns this effect.
  28017. */
  28018. setFloat2(uniformName: string, x: number, y: number): Effect;
  28019. /**
  28020. * Sets a Vector3 on a uniform variable.
  28021. * @param uniformName Name of the variable.
  28022. * @param vector3 Value to be set.
  28023. * @returns this effect.
  28024. */
  28025. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28026. /**
  28027. * Sets a float3 on a uniform variable.
  28028. * @param uniformName Name of the variable.
  28029. * @param x First float in float3.
  28030. * @param y Second float in float3.
  28031. * @param z Third float in float3.
  28032. * @returns this effect.
  28033. */
  28034. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28035. /**
  28036. * Sets a Vector4 on a uniform variable.
  28037. * @param uniformName Name of the variable.
  28038. * @param vector4 Value to be set.
  28039. * @returns this effect.
  28040. */
  28041. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28042. /**
  28043. * Sets a float4 on a uniform variable.
  28044. * @param uniformName Name of the variable.
  28045. * @param x First float in float4.
  28046. * @param y Second float in float4.
  28047. * @param z Third float in float4.
  28048. * @param w Fourth float in float4.
  28049. * @returns this effect.
  28050. */
  28051. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28052. /**
  28053. * Sets a Color3 on a uniform variable.
  28054. * @param uniformName Name of the variable.
  28055. * @param color3 Value to be set.
  28056. * @returns this effect.
  28057. */
  28058. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28059. /**
  28060. * Sets a Color4 on a uniform variable.
  28061. * @param uniformName Name of the variable.
  28062. * @param color3 Value to be set.
  28063. * @param alpha Alpha value to be set.
  28064. * @returns this effect.
  28065. */
  28066. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28067. /**
  28068. * Sets a Color4 on a uniform variable
  28069. * @param uniformName defines the name of the variable
  28070. * @param color4 defines the value to be set
  28071. * @returns this effect.
  28072. */
  28073. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28074. /** Release all associated resources */
  28075. dispose(): void;
  28076. /**
  28077. * This function will add a new shader to the shader store
  28078. * @param name the name of the shader
  28079. * @param pixelShader optional pixel shader content
  28080. * @param vertexShader optional vertex shader content
  28081. */
  28082. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28083. /**
  28084. * Store of each shader (The can be looked up using effect.key)
  28085. */
  28086. static ShadersStore: {
  28087. [key: string]: string;
  28088. };
  28089. /**
  28090. * Store of each included file for a shader (The can be looked up using effect.key)
  28091. */
  28092. static IncludesShadersStore: {
  28093. [key: string]: string;
  28094. };
  28095. /**
  28096. * Resets the cache of effects.
  28097. */
  28098. static ResetCache(): void;
  28099. }
  28100. }
  28101. declare module BABYLON {
  28102. /**
  28103. * Class used to describe the capabilities of the engine relatively to the current browser
  28104. */
  28105. export class EngineCapabilities {
  28106. /** Maximum textures units per fragment shader */
  28107. maxTexturesImageUnits: number;
  28108. /** Maximum texture units per vertex shader */
  28109. maxVertexTextureImageUnits: number;
  28110. /** Maximum textures units in the entire pipeline */
  28111. maxCombinedTexturesImageUnits: number;
  28112. /** Maximum texture size */
  28113. maxTextureSize: number;
  28114. /** Maximum cube texture size */
  28115. maxCubemapTextureSize: number;
  28116. /** Maximum render texture size */
  28117. maxRenderTextureSize: number;
  28118. /** Maximum number of vertex attributes */
  28119. maxVertexAttribs: number;
  28120. /** Maximum number of varyings */
  28121. maxVaryingVectors: number;
  28122. /** Maximum number of uniforms per vertex shader */
  28123. maxVertexUniformVectors: number;
  28124. /** Maximum number of uniforms per fragment shader */
  28125. maxFragmentUniformVectors: number;
  28126. /** Defines if standard derivates (dx/dy) are supported */
  28127. standardDerivatives: boolean;
  28128. /** Defines if s3tc texture compression is supported */
  28129. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  28130. /** Defines if pvrtc texture compression is supported */
  28131. pvrtc: any;
  28132. /** Defines if etc1 texture compression is supported */
  28133. etc1: any;
  28134. /** Defines if etc2 texture compression is supported */
  28135. etc2: any;
  28136. /** Defines if astc texture compression is supported */
  28137. astc: any;
  28138. /** Defines if float textures are supported */
  28139. textureFloat: boolean;
  28140. /** Defines if vertex array objects are supported */
  28141. vertexArrayObject: boolean;
  28142. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28143. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  28144. /** Gets the maximum level of anisotropy supported */
  28145. maxAnisotropy: number;
  28146. /** Defines if instancing is supported */
  28147. instancedArrays: boolean;
  28148. /** Defines if 32 bits indices are supported */
  28149. uintIndices: boolean;
  28150. /** Defines if high precision shaders are supported */
  28151. highPrecisionShaderSupported: boolean;
  28152. /** Defines if depth reading in the fragment shader is supported */
  28153. fragmentDepthSupported: boolean;
  28154. /** Defines if float texture linear filtering is supported*/
  28155. textureFloatLinearFiltering: boolean;
  28156. /** Defines if rendering to float textures is supported */
  28157. textureFloatRender: boolean;
  28158. /** Defines if half float textures are supported*/
  28159. textureHalfFloat: boolean;
  28160. /** Defines if half float texture linear filtering is supported*/
  28161. textureHalfFloatLinearFiltering: boolean;
  28162. /** Defines if rendering to half float textures is supported */
  28163. textureHalfFloatRender: boolean;
  28164. /** Defines if textureLOD shader command is supported */
  28165. textureLOD: boolean;
  28166. /** Defines if draw buffers extension is supported */
  28167. drawBuffersExtension: boolean;
  28168. /** Defines if depth textures are supported */
  28169. depthTextureExtension: boolean;
  28170. /** Defines if float color buffer are supported */
  28171. colorBufferFloat: boolean;
  28172. /** Gets disjoint timer query extension (null if not supported) */
  28173. timerQuery: EXT_disjoint_timer_query;
  28174. /** Defines if timestamp can be used with timer query */
  28175. canUseTimestampForTimerQuery: boolean;
  28176. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  28177. multiview: any;
  28178. /** Function used to let the system compiles shaders in background */
  28179. parallelShaderCompile: {
  28180. COMPLETION_STATUS_KHR: number;
  28181. };
  28182. /** Max number of texture samples for MSAA */
  28183. maxMSAASamples: number;
  28184. /** Defines if the blend min max extension is supported */
  28185. blendMinMax: boolean;
  28186. }
  28187. }
  28188. declare module BABYLON {
  28189. /**
  28190. * @hidden
  28191. **/
  28192. export class DepthCullingState {
  28193. private _isDepthTestDirty;
  28194. private _isDepthMaskDirty;
  28195. private _isDepthFuncDirty;
  28196. private _isCullFaceDirty;
  28197. private _isCullDirty;
  28198. private _isZOffsetDirty;
  28199. private _isFrontFaceDirty;
  28200. private _depthTest;
  28201. private _depthMask;
  28202. private _depthFunc;
  28203. private _cull;
  28204. private _cullFace;
  28205. private _zOffset;
  28206. private _frontFace;
  28207. /**
  28208. * Initializes the state.
  28209. */
  28210. constructor();
  28211. readonly isDirty: boolean;
  28212. zOffset: number;
  28213. cullFace: Nullable<number>;
  28214. cull: Nullable<boolean>;
  28215. depthFunc: Nullable<number>;
  28216. depthMask: boolean;
  28217. depthTest: boolean;
  28218. frontFace: Nullable<number>;
  28219. reset(): void;
  28220. apply(gl: WebGLRenderingContext): void;
  28221. }
  28222. }
  28223. declare module BABYLON {
  28224. /**
  28225. * @hidden
  28226. **/
  28227. export class StencilState {
  28228. /** 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 */
  28229. static readonly ALWAYS: number;
  28230. /** Passed to stencilOperation to specify that stencil value must be kept */
  28231. static readonly KEEP: number;
  28232. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28233. static readonly REPLACE: number;
  28234. private _isStencilTestDirty;
  28235. private _isStencilMaskDirty;
  28236. private _isStencilFuncDirty;
  28237. private _isStencilOpDirty;
  28238. private _stencilTest;
  28239. private _stencilMask;
  28240. private _stencilFunc;
  28241. private _stencilFuncRef;
  28242. private _stencilFuncMask;
  28243. private _stencilOpStencilFail;
  28244. private _stencilOpDepthFail;
  28245. private _stencilOpStencilDepthPass;
  28246. readonly isDirty: boolean;
  28247. stencilFunc: number;
  28248. stencilFuncRef: number;
  28249. stencilFuncMask: number;
  28250. stencilOpStencilFail: number;
  28251. stencilOpDepthFail: number;
  28252. stencilOpStencilDepthPass: number;
  28253. stencilMask: number;
  28254. stencilTest: boolean;
  28255. constructor();
  28256. reset(): void;
  28257. apply(gl: WebGLRenderingContext): void;
  28258. }
  28259. }
  28260. declare module BABYLON {
  28261. /**
  28262. * @hidden
  28263. **/
  28264. export class AlphaState {
  28265. private _isAlphaBlendDirty;
  28266. private _isBlendFunctionParametersDirty;
  28267. private _isBlendEquationParametersDirty;
  28268. private _isBlendConstantsDirty;
  28269. private _alphaBlend;
  28270. private _blendFunctionParameters;
  28271. private _blendEquationParameters;
  28272. private _blendConstants;
  28273. /**
  28274. * Initializes the state.
  28275. */
  28276. constructor();
  28277. readonly isDirty: boolean;
  28278. alphaBlend: boolean;
  28279. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  28280. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  28281. setAlphaEquationParameters(rgb: number, alpha: number): void;
  28282. reset(): void;
  28283. apply(gl: WebGLRenderingContext): void;
  28284. }
  28285. }
  28286. declare module BABYLON {
  28287. /** @hidden */
  28288. export class WebGL2ShaderProcessor implements IShaderProcessor {
  28289. attributeProcessor(attribute: string): string;
  28290. varyingProcessor(varying: string, isFragment: boolean): string;
  28291. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  28292. }
  28293. }
  28294. declare module BABYLON {
  28295. /**
  28296. * Interface for attribute information associated with buffer instanciation
  28297. */
  28298. export class InstancingAttributeInfo {
  28299. /**
  28300. * Index/offset of the attribute in the vertex shader
  28301. */
  28302. index: number;
  28303. /**
  28304. * size of the attribute, 1, 2, 3 or 4
  28305. */
  28306. attributeSize: number;
  28307. /**
  28308. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  28309. * default is FLOAT
  28310. */
  28311. attribyteType: number;
  28312. /**
  28313. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  28314. */
  28315. normalized: boolean;
  28316. /**
  28317. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  28318. */
  28319. offset: number;
  28320. /**
  28321. * Name of the GLSL attribute, for debugging purpose only
  28322. */
  28323. attributeName: string;
  28324. }
  28325. }
  28326. declare module BABYLON {
  28327. interface ThinEngine {
  28328. /**
  28329. * Update a video texture
  28330. * @param texture defines the texture to update
  28331. * @param video defines the video element to use
  28332. * @param invertY defines if data must be stored with Y axis inverted
  28333. */
  28334. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28335. }
  28336. }
  28337. declare module BABYLON {
  28338. /**
  28339. * Settings for finer control over video usage
  28340. */
  28341. export interface VideoTextureSettings {
  28342. /**
  28343. * Applies `autoplay` to video, if specified
  28344. */
  28345. autoPlay?: boolean;
  28346. /**
  28347. * Applies `loop` to video, if specified
  28348. */
  28349. loop?: boolean;
  28350. /**
  28351. * Automatically updates internal texture from video at every frame in the render loop
  28352. */
  28353. autoUpdateTexture: boolean;
  28354. /**
  28355. * Image src displayed during the video loading or until the user interacts with the video.
  28356. */
  28357. poster?: string;
  28358. }
  28359. /**
  28360. * If you want to display a video in your scene, this is the special texture for that.
  28361. * This special texture works similar to other textures, with the exception of a few parameters.
  28362. * @see https://doc.babylonjs.com/how_to/video_texture
  28363. */
  28364. export class VideoTexture extends Texture {
  28365. /**
  28366. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  28367. */
  28368. readonly autoUpdateTexture: boolean;
  28369. /**
  28370. * The video instance used by the texture internally
  28371. */
  28372. readonly video: HTMLVideoElement;
  28373. private _onUserActionRequestedObservable;
  28374. /**
  28375. * Event triggerd when a dom action is required by the user to play the video.
  28376. * This happens due to recent changes in browser policies preventing video to auto start.
  28377. */
  28378. readonly onUserActionRequestedObservable: Observable<Texture>;
  28379. private _generateMipMaps;
  28380. private _engine;
  28381. private _stillImageCaptured;
  28382. private _displayingPosterTexture;
  28383. private _settings;
  28384. private _createInternalTextureOnEvent;
  28385. private _frameId;
  28386. /**
  28387. * Creates a video texture.
  28388. * If you want to display a video in your scene, this is the special texture for that.
  28389. * This special texture works similar to other textures, with the exception of a few parameters.
  28390. * @see https://doc.babylonjs.com/how_to/video_texture
  28391. * @param name optional name, will detect from video source, if not defined
  28392. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  28393. * @param scene is obviously the current scene.
  28394. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  28395. * @param invertY is false by default but can be used to invert video on Y axis
  28396. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  28397. * @param settings allows finer control over video usage
  28398. */
  28399. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  28400. private _getName;
  28401. private _getVideo;
  28402. private _createInternalTexture;
  28403. private reset;
  28404. /**
  28405. * @hidden Internal method to initiate `update`.
  28406. */ private _rebuild(): void;
  28407. /**
  28408. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  28409. */
  28410. update(): void;
  28411. /**
  28412. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  28413. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  28414. */
  28415. updateTexture(isVisible: boolean): void;
  28416. protected _updateInternalTexture: () => void;
  28417. /**
  28418. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  28419. * @param url New url.
  28420. */
  28421. updateURL(url: string): void;
  28422. /**
  28423. * Dispose the texture and release its associated resources.
  28424. */
  28425. dispose(): void;
  28426. /**
  28427. * Creates a video texture straight from a stream.
  28428. * @param scene Define the scene the texture should be created in
  28429. * @param stream Define the stream the texture should be created from
  28430. * @returns The created video texture as a promise
  28431. */
  28432. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  28433. /**
  28434. * Creates a video texture straight from your WebCam video feed.
  28435. * @param scene Define the scene the texture should be created in
  28436. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28437. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28438. * @returns The created video texture as a promise
  28439. */
  28440. static CreateFromWebCamAsync(scene: Scene, constraints: {
  28441. minWidth: number;
  28442. maxWidth: number;
  28443. minHeight: number;
  28444. maxHeight: number;
  28445. deviceId: string;
  28446. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  28447. /**
  28448. * Creates a video texture straight from your WebCam video feed.
  28449. * @param scene Define the scene the texture should be created in
  28450. * @param onReady Define a callback to triggered once the texture will be ready
  28451. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28452. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28453. */
  28454. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  28455. minWidth: number;
  28456. maxWidth: number;
  28457. minHeight: number;
  28458. maxHeight: number;
  28459. deviceId: string;
  28460. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  28461. }
  28462. }
  28463. declare module BABYLON {
  28464. /**
  28465. * Defines the interface used by objects working like Scene
  28466. * @hidden
  28467. */
  28468. interface ISceneLike { private _addPendingData(data: any): void; private _removePendingData(data: any): void;
  28469. offlineProvider: IOfflineProvider;
  28470. }
  28471. /** Interface defining initialization parameters for Engine class */
  28472. export interface EngineOptions extends WebGLContextAttributes {
  28473. /**
  28474. * Defines if the engine should no exceed a specified device ratio
  28475. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  28476. */
  28477. limitDeviceRatio?: number;
  28478. /**
  28479. * Defines if webvr should be enabled automatically
  28480. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28481. */
  28482. autoEnableWebVR?: boolean;
  28483. /**
  28484. * Defines if webgl2 should be turned off even if supported
  28485. * @see http://doc.babylonjs.com/features/webgl2
  28486. */
  28487. disableWebGL2Support?: boolean;
  28488. /**
  28489. * Defines if webaudio should be initialized as well
  28490. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28491. */
  28492. audioEngine?: boolean;
  28493. /**
  28494. * Defines if animations should run using a deterministic lock step
  28495. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28496. */
  28497. deterministicLockstep?: boolean;
  28498. /** Defines the maximum steps to use with deterministic lock step mode */
  28499. lockstepMaxSteps?: number;
  28500. /**
  28501. * Defines that engine should ignore context lost events
  28502. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  28503. */
  28504. doNotHandleContextLost?: boolean;
  28505. /**
  28506. * Defines that engine should ignore modifying touch action attribute and style
  28507. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  28508. */
  28509. doNotHandleTouchAction?: boolean;
  28510. /**
  28511. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  28512. */
  28513. useHighPrecisionFloats?: boolean;
  28514. }
  28515. /**
  28516. * The base engine class (root of all engines)
  28517. */
  28518. export class ThinEngine {
  28519. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  28520. static ExceptionList: ({
  28521. key: string;
  28522. capture: string;
  28523. captureConstraint: number;
  28524. targets: string[];
  28525. } | {
  28526. key: string;
  28527. capture: null;
  28528. captureConstraint: null;
  28529. targets: string[];
  28530. })[];
  28531. /** @hidden */ private static _TextureLoaders: IInternalTextureLoader[];
  28532. /**
  28533. * Returns the current npm package of the sdk
  28534. */
  28535. static readonly NpmPackage: string;
  28536. /**
  28537. * Returns the current version of the framework
  28538. */
  28539. static readonly Version: string;
  28540. /**
  28541. * Returns a string describing the current engine
  28542. */
  28543. readonly description: string;
  28544. /**
  28545. * Gets or sets the epsilon value used by collision engine
  28546. */
  28547. static CollisionsEpsilon: number;
  28548. /**
  28549. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28550. */
  28551. static ShadersRepository: string;
  28552. /** @hidden */ private _shaderProcessor: IShaderProcessor;
  28553. /**
  28554. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28555. */
  28556. forcePOTTextures: boolean;
  28557. /**
  28558. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28559. */
  28560. isFullscreen: boolean;
  28561. /**
  28562. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28563. */
  28564. cullBackFaces: boolean;
  28565. /**
  28566. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28567. */
  28568. renderEvenInBackground: boolean;
  28569. /**
  28570. * Gets or sets a boolean indicating that cache can be kept between frames
  28571. */
  28572. preventCacheWipeBetweenFrames: boolean;
  28573. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28574. validateShaderPrograms: boolean;
  28575. /**
  28576. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28577. */
  28578. disableUniformBuffers: boolean;
  28579. /** @hidden */ private _uniformBuffers: UniformBuffer[];
  28580. /**
  28581. * Gets a boolean indicating that the engine supports uniform buffers
  28582. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28583. */
  28584. readonly supportsUniformBuffers: boolean;
  28585. /** @hidden */ private _gl: WebGLRenderingContext;
  28586. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  28587. protected _windowIsBackground: boolean;
  28588. protected _webGLVersion: number;
  28589. protected _highPrecisionShadersAllowed: boolean;
  28590. /** @hidden */ protected readonly _shouldUseHighPrecisionShader: boolean;
  28591. /**
  28592. * Gets a boolean indicating that only power of 2 textures are supported
  28593. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28594. */
  28595. readonly needPOTTextures: boolean;
  28596. /** @hidden */ private _badOS: boolean;
  28597. /** @hidden */ private _badDesktopOS: boolean;
  28598. private _hardwareScalingLevel;
  28599. /** @hidden */ private _caps: EngineCapabilities;
  28600. private _isStencilEnable;
  28601. protected _colorWrite: boolean;
  28602. private _glVersion;
  28603. private _glRenderer;
  28604. private _glVendor;
  28605. /** @hidden */ private _videoTextureSupported: boolean;
  28606. protected _renderingQueueLaunched: boolean;
  28607. protected _activeRenderLoops: (() => void)[];
  28608. /**
  28609. * Observable signaled when a context lost event is raised
  28610. */
  28611. onContextLostObservable: Observable<ThinEngine>;
  28612. /**
  28613. * Observable signaled when a context restored event is raised
  28614. */
  28615. onContextRestoredObservable: Observable<ThinEngine>;
  28616. private _onContextLost;
  28617. private _onContextRestored;
  28618. protected _contextWasLost: boolean;
  28619. /** @hidden */ private _doNotHandleContextLost: boolean;
  28620. /**
  28621. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28622. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28623. */
  28624. doNotHandleContextLost: boolean;
  28625. /**
  28626. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28627. */
  28628. disableVertexArrayObjects: boolean;
  28629. /** @hidden */
  28630. protected _depthCullingState: DepthCullingState;
  28631. /** @hidden */
  28632. protected _stencilState: StencilState;
  28633. /** @hidden */
  28634. protected _alphaState: AlphaState;
  28635. /** @hidden */ private _internalTexturesCache: InternalTexture[];
  28636. /** @hidden */
  28637. protected _activeChannel: number;
  28638. private _currentTextureChannel;
  28639. /** @hidden */
  28640. protected _boundTexturesCache: {
  28641. [key: string]: Nullable<InternalTexture>;
  28642. };
  28643. /** @hidden */
  28644. protected _currentEffect: Nullable<Effect>;
  28645. /** @hidden */
  28646. protected _currentProgram: Nullable<WebGLProgram>;
  28647. private _compiledEffects;
  28648. private _vertexAttribArraysEnabled;
  28649. /** @hidden */
  28650. protected _cachedViewport: Nullable<IViewportLike>;
  28651. private _cachedVertexArrayObject;
  28652. /** @hidden */
  28653. protected _cachedVertexBuffers: any;
  28654. /** @hidden */
  28655. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  28656. /** @hidden */
  28657. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28658. /** @hidden */ private _currentRenderTarget: Nullable<InternalTexture>;
  28659. private _uintIndicesCurrentlySet;
  28660. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  28661. /** @hidden */
  28662. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28663. private _currentBufferPointers;
  28664. private _currentInstanceLocations;
  28665. private _currentInstanceBuffers;
  28666. private _textureUnits;
  28667. /** @hidden */ private _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  28668. /** @hidden */ private _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  28669. /** @hidden */ private _bindedRenderFunction: any;
  28670. private _vaoRecordInProgress;
  28671. private _mustWipeVertexAttributes;
  28672. private _emptyTexture;
  28673. private _emptyCubeTexture;
  28674. private _emptyTexture3D;
  28675. /** @hidden */ private _frameHandler: number;
  28676. private _nextFreeTextureSlots;
  28677. private _maxSimultaneousTextures;
  28678. private _activeRequests;
  28679. protected _texturesSupported: string[];
  28680. /** @hidden */ private _textureFormatInUse: Nullable<string>;
  28681. protected readonly _supportsHardwareTextureRescaling: boolean;
  28682. /**
  28683. * Gets the list of texture formats supported
  28684. */
  28685. readonly texturesSupported: Array<string>;
  28686. /**
  28687. * Gets the list of texture formats in use
  28688. */
  28689. readonly textureFormatInUse: Nullable<string>;
  28690. /**
  28691. * Gets the current viewport
  28692. */
  28693. readonly currentViewport: Nullable<IViewportLike>;
  28694. /**
  28695. * Gets the default empty texture
  28696. */
  28697. readonly emptyTexture: InternalTexture;
  28698. /**
  28699. * Gets the default empty 3D texture
  28700. */
  28701. readonly emptyTexture3D: InternalTexture;
  28702. /**
  28703. * Gets the default empty cube texture
  28704. */
  28705. readonly emptyCubeTexture: InternalTexture;
  28706. /**
  28707. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28708. */
  28709. readonly premultipliedAlpha: boolean;
  28710. /**
  28711. * Observable event triggered before each texture is initialized
  28712. */
  28713. onBeforeTextureInitObservable: Observable<Texture>;
  28714. /**
  28715. * Creates a new engine
  28716. * @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
  28717. * @param antialias defines enable antialiasing (default: false)
  28718. * @param options defines further options to be sent to the getContext() function
  28719. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28720. */
  28721. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28722. private _rebuildInternalTextures;
  28723. private _rebuildEffects;
  28724. /**
  28725. * Gets a boolean indicating if all created effects are ready
  28726. * @returns true if all effects are ready
  28727. */
  28728. areAllEffectsReady(): boolean;
  28729. protected _rebuildBuffers(): void;
  28730. private _initGLContext;
  28731. /**
  28732. * Gets version of the current webGL context
  28733. */
  28734. readonly webGLVersion: number;
  28735. /**
  28736. * Gets a string idenfifying the name of the class
  28737. * @returns "Engine" string
  28738. */
  28739. getClassName(): string;
  28740. /**
  28741. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28742. */
  28743. readonly isStencilEnable: boolean;
  28744. /** @hidden */ private _prepareWorkingCanvas(): void;
  28745. /**
  28746. * Reset the texture cache to empty state
  28747. */
  28748. resetTextureCache(): void;
  28749. /**
  28750. * Gets an object containing information about the current webGL context
  28751. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28752. */
  28753. getGlInfo(): {
  28754. vendor: string;
  28755. renderer: string;
  28756. version: string;
  28757. };
  28758. /**
  28759. * Defines the hardware scaling level.
  28760. * By default the hardware scaling level is computed from the window device ratio.
  28761. * 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.
  28762. * @param level defines the level to use
  28763. */
  28764. setHardwareScalingLevel(level: number): void;
  28765. /**
  28766. * Gets the current hardware scaling level.
  28767. * By default the hardware scaling level is computed from the window device ratio.
  28768. * 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.
  28769. * @returns a number indicating the current hardware scaling level
  28770. */
  28771. getHardwareScalingLevel(): number;
  28772. /**
  28773. * Gets the list of loaded textures
  28774. * @returns an array containing all loaded textures
  28775. */
  28776. getLoadedTexturesCache(): InternalTexture[];
  28777. /**
  28778. * Gets the object containing all engine capabilities
  28779. * @returns the EngineCapabilities object
  28780. */
  28781. getCaps(): EngineCapabilities;
  28782. /**
  28783. * stop executing a render loop function and remove it from the execution array
  28784. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28785. */
  28786. stopRenderLoop(renderFunction?: () => void): void;
  28787. /** @hidden */ private _renderLoop(): void;
  28788. /**
  28789. * Gets the HTML canvas attached with the current webGL context
  28790. * @returns a HTML canvas
  28791. */
  28792. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28793. /**
  28794. * Gets host window
  28795. * @returns the host window object
  28796. */
  28797. getHostWindow(): Nullable<Window>;
  28798. /**
  28799. * Gets the current render width
  28800. * @param useScreen defines if screen size must be used (or the current render target if any)
  28801. * @returns a number defining the current render width
  28802. */
  28803. getRenderWidth(useScreen?: boolean): number;
  28804. /**
  28805. * Gets the current render height
  28806. * @param useScreen defines if screen size must be used (or the current render target if any)
  28807. * @returns a number defining the current render height
  28808. */
  28809. getRenderHeight(useScreen?: boolean): number;
  28810. /**
  28811. * Can be used to override the current requestAnimationFrame requester.
  28812. * @hidden
  28813. */
  28814. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  28815. /**
  28816. * Register and execute a render loop. The engine can have more than one render function
  28817. * @param renderFunction defines the function to continuously execute
  28818. */
  28819. runRenderLoop(renderFunction: () => void): void;
  28820. /**
  28821. * Clear the current render buffer or the current render target (if any is set up)
  28822. * @param color defines the color to use
  28823. * @param backBuffer defines if the back buffer must be cleared
  28824. * @param depth defines if the depth buffer must be cleared
  28825. * @param stencil defines if the stencil buffer must be cleared
  28826. */
  28827. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28828. private _viewportCached;
  28829. /** @hidden */ private _viewport(x: number, y: number, width: number, height: number): void;
  28830. /**
  28831. * Set the WebGL's viewport
  28832. * @param viewport defines the viewport element to be used
  28833. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28834. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28835. */
  28836. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  28837. /**
  28838. * Begin a new frame
  28839. */
  28840. beginFrame(): void;
  28841. /**
  28842. * Enf the current frame
  28843. */
  28844. endFrame(): void;
  28845. /**
  28846. * Resize the view according to the canvas' size
  28847. */
  28848. resize(): void;
  28849. /**
  28850. * Force a specific size of the canvas
  28851. * @param width defines the new canvas' width
  28852. * @param height defines the new canvas' height
  28853. */
  28854. setSize(width: number, height: number): void;
  28855. /**
  28856. * Binds the frame buffer to the specified texture.
  28857. * @param texture The texture to render to or null for the default canvas
  28858. * @param faceIndex The face of the texture to render to in case of cube texture
  28859. * @param requiredWidth The width of the target to render to
  28860. * @param requiredHeight The height of the target to render to
  28861. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28862. * @param depthStencilTexture The depth stencil texture to use to render
  28863. * @param lodLevel defines le lod level to bind to the frame buffer
  28864. */
  28865. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28866. /** @hidden */ private _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  28867. /**
  28868. * Unbind the current render target texture from the webGL context
  28869. * @param texture defines the render target texture to unbind
  28870. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28871. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28872. */
  28873. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28874. /**
  28875. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28876. */
  28877. flushFramebuffer(): void;
  28878. /**
  28879. * Unbind the current render target and bind the default framebuffer
  28880. */
  28881. restoreDefaultFramebuffer(): void;
  28882. private _resetVertexBufferBinding;
  28883. /**
  28884. * Creates a vertex buffer
  28885. * @param data the data for the vertex buffer
  28886. * @returns the new WebGL static buffer
  28887. */
  28888. createVertexBuffer(data: DataArray): DataBuffer;
  28889. private _createVertexBuffer;
  28890. /**
  28891. * Creates a dynamic vertex buffer
  28892. * @param data the data for the dynamic vertex buffer
  28893. * @returns the new WebGL dynamic buffer
  28894. */
  28895. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  28896. /**
  28897. * Updates a dynamic vertex buffer.
  28898. * @param vertexBuffer the vertex buffer to update
  28899. * @param data the data used to update the vertex buffer
  28900. * @param byteOffset the byte offset of the data
  28901. * @param byteLength the byte length of the data
  28902. */
  28903. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28904. protected _resetIndexBufferBinding(): void;
  28905. /**
  28906. * Creates a new index buffer
  28907. * @param indices defines the content of the index buffer
  28908. * @param updatable defines if the index buffer must be updatable
  28909. * @returns a new webGL buffer
  28910. */
  28911. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  28912. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  28913. /**
  28914. * Bind a webGL buffer to the webGL context
  28915. * @param buffer defines the buffer to bind
  28916. */
  28917. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  28918. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  28919. private bindBuffer;
  28920. /**
  28921. * update the bound buffer with the given data
  28922. * @param data defines the data to update
  28923. */
  28924. updateArrayBuffer(data: Float32Array): void;
  28925. private _vertexAttribPointer;
  28926. private _bindIndexBufferWithCache;
  28927. private _bindVertexBuffersAttributes;
  28928. /**
  28929. * Records a vertex array object
  28930. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28931. * @param vertexBuffers defines the list of vertex buffers to store
  28932. * @param indexBuffer defines the index buffer to store
  28933. * @param effect defines the effect to store
  28934. * @returns the new vertex array object
  28935. */
  28936. recordVertexArrayObject(vertexBuffers: {
  28937. [key: string]: VertexBuffer;
  28938. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  28939. /**
  28940. * Bind a specific vertex array object
  28941. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28942. * @param vertexArrayObject defines the vertex array object to bind
  28943. * @param indexBuffer defines the index buffer to bind
  28944. */
  28945. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  28946. /**
  28947. * Bind webGl buffers directly to the webGL context
  28948. * @param vertexBuffer defines the vertex buffer to bind
  28949. * @param indexBuffer defines the index buffer to bind
  28950. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28951. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28952. * @param effect defines the effect associated with the vertex buffer
  28953. */
  28954. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28955. private _unbindVertexArrayObject;
  28956. /**
  28957. * Bind a list of vertex buffers to the webGL context
  28958. * @param vertexBuffers defines the list of vertex buffers to bind
  28959. * @param indexBuffer defines the index buffer to bind
  28960. * @param effect defines the effect associated with the vertex buffers
  28961. */
  28962. bindBuffers(vertexBuffers: {
  28963. [key: string]: Nullable<VertexBuffer>;
  28964. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  28965. /**
  28966. * Unbind all instance attributes
  28967. */
  28968. unbindInstanceAttributes(): void;
  28969. /**
  28970. * Release and free the memory of a vertex array object
  28971. * @param vao defines the vertex array object to delete
  28972. */
  28973. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28974. /** @hidden */ private _releaseBuffer(buffer: DataBuffer): boolean;
  28975. protected _deleteBuffer(buffer: DataBuffer): void;
  28976. /**
  28977. * Creates a webGL buffer to use with instanciation
  28978. * @param capacity defines the size of the buffer
  28979. * @returns the webGL buffer
  28980. */
  28981. createInstancesBuffer(capacity: number): DataBuffer;
  28982. /**
  28983. * Delete a webGL buffer used with instanciation
  28984. * @param buffer defines the webGL buffer to delete
  28985. */
  28986. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28987. /**
  28988. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28989. * @param instancesBuffer defines the webGL buffer to update and bind
  28990. * @param data defines the data to store in the buffer
  28991. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28992. */
  28993. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28994. /**
  28995. * Apply all cached states (depth, culling, stencil and alpha)
  28996. */
  28997. applyStates(): void;
  28998. /**
  28999. * Send a draw order
  29000. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29001. * @param indexStart defines the starting index
  29002. * @param indexCount defines the number of index to draw
  29003. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29004. */
  29005. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29006. /**
  29007. * Draw a list of points
  29008. * @param verticesStart defines the index of first vertex to draw
  29009. * @param verticesCount defines the count of vertices to draw
  29010. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29011. */
  29012. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29013. /**
  29014. * Draw a list of unindexed primitives
  29015. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29016. * @param verticesStart defines the index of first vertex to draw
  29017. * @param verticesCount defines the count of vertices to draw
  29018. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29019. */
  29020. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29021. /**
  29022. * Draw a list of indexed primitives
  29023. * @param fillMode defines the primitive to use
  29024. * @param indexStart defines the starting index
  29025. * @param indexCount defines the number of index to draw
  29026. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29027. */
  29028. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29029. /**
  29030. * Draw a list of unindexed primitives
  29031. * @param fillMode defines the primitive to use
  29032. * @param verticesStart defines the index of first vertex to draw
  29033. * @param verticesCount defines the count of vertices to draw
  29034. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29035. */
  29036. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29037. private _drawMode;
  29038. /** @hidden */
  29039. protected _reportDrawCall(): void;
  29040. /** @hidden */ private _releaseEffect(effect: Effect): void;
  29041. /** @hidden */ private _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29042. /**
  29043. * Create a new effect (used to store vertex/fragment shaders)
  29044. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29045. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  29046. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29047. * @param samplers defines an array of string used to represent textures
  29048. * @param defines defines the string containing the defines to use to compile the shaders
  29049. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29050. * @param onCompiled defines a function to call when the effect creation is successful
  29051. * @param onError defines a function to call when the effect creation has failed
  29052. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29053. * @returns the new Effect
  29054. */
  29055. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  29056. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  29057. private _compileShader;
  29058. private _compileRawShader;
  29059. /**
  29060. * Directly creates a webGL program
  29061. * @param pipelineContext defines the pipeline context to attach to
  29062. * @param vertexCode defines the vertex shader code to use
  29063. * @param fragmentCode defines the fragment shader code to use
  29064. * @param context defines the webGL context to use (if not set, the current one will be used)
  29065. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29066. * @returns the new webGL program
  29067. */
  29068. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29069. /**
  29070. * Creates a webGL program
  29071. * @param pipelineContext defines the pipeline context to attach to
  29072. * @param vertexCode defines the vertex shader code to use
  29073. * @param fragmentCode defines the fragment shader code to use
  29074. * @param defines defines the string containing the defines to use to compile the shaders
  29075. * @param context defines the webGL context to use (if not set, the current one will be used)
  29076. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29077. * @returns the new webGL program
  29078. */
  29079. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29080. /**
  29081. * Creates a new pipeline context
  29082. * @returns the new pipeline
  29083. */
  29084. createPipelineContext(): IPipelineContext;
  29085. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29086. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  29087. /** @hidden */ private _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29088. /** @hidden */ private _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29089. /** @hidden */ private _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29090. /**
  29091. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29092. * @param pipelineContext defines the pipeline context to use
  29093. * @param uniformsNames defines the list of uniform names
  29094. * @returns an array of webGL uniform locations
  29095. */
  29096. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29097. /**
  29098. * Gets the lsit of active attributes for a given webGL program
  29099. * @param pipelineContext defines the pipeline context to use
  29100. * @param attributesNames defines the list of attribute names to get
  29101. * @returns an array of indices indicating the offset of each attribute
  29102. */
  29103. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29104. /**
  29105. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29106. * @param effect defines the effect to activate
  29107. */
  29108. enableEffect(effect: Nullable<Effect>): void;
  29109. /**
  29110. * Set the value of an uniform to an array of int32
  29111. * @param uniform defines the webGL uniform location where to store the value
  29112. * @param array defines the array of int32 to store
  29113. */
  29114. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29115. /**
  29116. * Set the value of an uniform to an array of int32 (stored as vec2)
  29117. * @param uniform defines the webGL uniform location where to store the value
  29118. * @param array defines the array of int32 to store
  29119. */
  29120. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29121. /**
  29122. * Set the value of an uniform to an array of int32 (stored as vec3)
  29123. * @param uniform defines the webGL uniform location where to store the value
  29124. * @param array defines the array of int32 to store
  29125. */
  29126. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29127. /**
  29128. * Set the value of an uniform to an array of int32 (stored as vec4)
  29129. * @param uniform defines the webGL uniform location where to store the value
  29130. * @param array defines the array of int32 to store
  29131. */
  29132. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29133. /**
  29134. * Set the value of an uniform to an array of float32
  29135. * @param uniform defines the webGL uniform location where to store the value
  29136. * @param array defines the array of float32 to store
  29137. */
  29138. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29139. /**
  29140. * Set the value of an uniform to an array of float32 (stored as vec2)
  29141. * @param uniform defines the webGL uniform location where to store the value
  29142. * @param array defines the array of float32 to store
  29143. */
  29144. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29145. /**
  29146. * Set the value of an uniform to an array of float32 (stored as vec3)
  29147. * @param uniform defines the webGL uniform location where to store the value
  29148. * @param array defines the array of float32 to store
  29149. */
  29150. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29151. /**
  29152. * Set the value of an uniform to an array of float32 (stored as vec4)
  29153. * @param uniform defines the webGL uniform location where to store the value
  29154. * @param array defines the array of float32 to store
  29155. */
  29156. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29157. /**
  29158. * Set the value of an uniform to an array of number
  29159. * @param uniform defines the webGL uniform location where to store the value
  29160. * @param array defines the array of number to store
  29161. */
  29162. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29163. /**
  29164. * Set the value of an uniform to an array of number (stored as vec2)
  29165. * @param uniform defines the webGL uniform location where to store the value
  29166. * @param array defines the array of number to store
  29167. */
  29168. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29169. /**
  29170. * Set the value of an uniform to an array of number (stored as vec3)
  29171. * @param uniform defines the webGL uniform location where to store the value
  29172. * @param array defines the array of number to store
  29173. */
  29174. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29175. /**
  29176. * Set the value of an uniform to an array of number (stored as vec4)
  29177. * @param uniform defines the webGL uniform location where to store the value
  29178. * @param array defines the array of number to store
  29179. */
  29180. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29181. /**
  29182. * Set the value of an uniform to an array of float32 (stored as matrices)
  29183. * @param uniform defines the webGL uniform location where to store the value
  29184. * @param matrices defines the array of float32 to store
  29185. */
  29186. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29187. /**
  29188. * Set the value of an uniform to a matrix (3x3)
  29189. * @param uniform defines the webGL uniform location where to store the value
  29190. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29191. */
  29192. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29193. /**
  29194. * Set the value of an uniform to a matrix (2x2)
  29195. * @param uniform defines the webGL uniform location where to store the value
  29196. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29197. */
  29198. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29199. /**
  29200. * Set the value of an uniform to a number (int)
  29201. * @param uniform defines the webGL uniform location where to store the value
  29202. * @param value defines the int number to store
  29203. */
  29204. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29205. /**
  29206. * Set the value of an uniform to a number (float)
  29207. * @param uniform defines the webGL uniform location where to store the value
  29208. * @param value defines the float number to store
  29209. */
  29210. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29211. /**
  29212. * Set the value of an uniform to a vec2
  29213. * @param uniform defines the webGL uniform location where to store the value
  29214. * @param x defines the 1st component of the value
  29215. * @param y defines the 2nd component of the value
  29216. */
  29217. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29218. /**
  29219. * Set the value of an uniform to a vec3
  29220. * @param uniform defines the webGL uniform location where to store the value
  29221. * @param x defines the 1st component of the value
  29222. * @param y defines the 2nd component of the value
  29223. * @param z defines the 3rd component of the value
  29224. */
  29225. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29226. /**
  29227. * Set the value of an uniform to a boolean
  29228. * @param uniform defines the webGL uniform location where to store the value
  29229. * @param bool defines the boolean to store
  29230. */
  29231. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29232. /**
  29233. * Set the value of an uniform to a vec4
  29234. * @param uniform defines the webGL uniform location where to store the value
  29235. * @param x defines the 1st component of the value
  29236. * @param y defines the 2nd component of the value
  29237. * @param z defines the 3rd component of the value
  29238. * @param w defines the 4th component of the value
  29239. */
  29240. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29241. /**
  29242. * Sets a Color4 on a uniform variable
  29243. * @param uniform defines the uniform location
  29244. * @param color4 defines the value to be set
  29245. */
  29246. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  29247. /**
  29248. * Gets the depth culling state manager
  29249. */
  29250. readonly depthCullingState: DepthCullingState;
  29251. /**
  29252. * Gets the alpha state manager
  29253. */
  29254. readonly alphaState: AlphaState;
  29255. /**
  29256. * Gets the stencil state manager
  29257. */
  29258. readonly stencilState: StencilState;
  29259. /**
  29260. * Clears the list of texture accessible through engine.
  29261. * This can help preventing texture load conflict due to name collision.
  29262. */
  29263. clearInternalTexturesCache(): void;
  29264. /**
  29265. * Force the entire cache to be cleared
  29266. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29267. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29268. */
  29269. wipeCaches(bruteForce?: boolean): void;
  29270. /** @hidden */ private _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29271. min: number;
  29272. mag: number;
  29273. };
  29274. /** @hidden */ private _createTexture(): WebGLTexture;
  29275. /**
  29276. * Usually called from Texture.ts.
  29277. * Passed information to create a WebGLTexture
  29278. * @param urlArg defines a value which contains one of the following:
  29279. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29280. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29281. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29282. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29283. * @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)
  29284. * @param scene needed for loading to the correct scene
  29285. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29286. * @param onLoad optional callback to be called upon successful completion
  29287. * @param onError optional callback to be called upon failure
  29288. * @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
  29289. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29290. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29291. * @param forcedExtension defines the extension to use to pick the right loader
  29292. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29293. * @param mimeType defines an optional mime type
  29294. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29295. */
  29296. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  29297. /**
  29298. * @hidden
  29299. */ private _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  29300. /**
  29301. * Creates a raw texture
  29302. * @param data defines the data to store in the texture
  29303. * @param width defines the width of the texture
  29304. * @param height defines the height of the texture
  29305. * @param format defines the format of the data
  29306. * @param generateMipMaps defines if the engine should generate the mip levels
  29307. * @param invertY defines if data must be stored with Y axis inverted
  29308. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29309. * @param compression defines the compression used (null by default)
  29310. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29311. * @returns the raw texture inside an InternalTexture
  29312. */
  29313. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  29314. /**
  29315. * Creates a new raw cube texture
  29316. * @param data defines the array of data to use to create each face
  29317. * @param size defines the size of the textures
  29318. * @param format defines the format of the data
  29319. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29320. * @param generateMipMaps defines if the engine should generate the mip levels
  29321. * @param invertY defines if data must be stored with Y axis inverted
  29322. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29323. * @param compression defines the compression used (null by default)
  29324. * @returns the cube texture as an InternalTexture
  29325. */
  29326. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  29327. /**
  29328. * Creates a new raw 3D texture
  29329. * @param data defines the data used to create the texture
  29330. * @param width defines the width of the texture
  29331. * @param height defines the height of the texture
  29332. * @param depth defines the depth of the texture
  29333. * @param format defines the format of the texture
  29334. * @param generateMipMaps defines if the engine must generate mip levels
  29335. * @param invertY defines if data must be stored with Y axis inverted
  29336. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29337. * @param compression defines the compressed used (can be null)
  29338. * @param textureType defines the compressed used (can be null)
  29339. * @returns a new raw 3D texture (stored in an InternalTexture)
  29340. */
  29341. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  29342. private _unpackFlipYCached;
  29343. /**
  29344. * In case you are sharing the context with other applications, it might
  29345. * be interested to not cache the unpack flip y state to ensure a consistent
  29346. * value would be set.
  29347. */
  29348. enableUnpackFlipYCached: boolean;
  29349. /** @hidden */ private _unpackFlipY(value: boolean): void;
  29350. /** @hidden */ private _getUnpackAlignement(): number;
  29351. /**
  29352. * Update the sampling mode of a given texture
  29353. * @param samplingMode defines the required sampling mode
  29354. * @param texture defines the texture to update
  29355. */
  29356. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29357. /**
  29358. * Updates a depth texture Comparison Mode and Function.
  29359. * If the comparison Function is equal to 0, the mode will be set to none.
  29360. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29361. * @param texture The texture to set the comparison function for
  29362. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29363. */
  29364. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29365. /** @hidden */ private _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29366. width: number;
  29367. height: number;
  29368. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29369. /**
  29370. * Creates a depth stencil texture.
  29371. * This is only available in WebGL 2 or with the depth texture extension available.
  29372. * @param size The size of face edge in the texture.
  29373. * @param options The options defining the texture.
  29374. * @returns The texture
  29375. */
  29376. createDepthStencilTexture(size: number | {
  29377. width: number;
  29378. height: number;
  29379. }, options: DepthTextureCreationOptions): InternalTexture;
  29380. /**
  29381. * Creates a depth stencil texture.
  29382. * This is only available in WebGL 2 or with the depth texture extension available.
  29383. * @param size The size of face edge in the texture.
  29384. * @param options The options defining the texture.
  29385. * @returns The texture
  29386. */
  29387. private _createDepthStencilTexture;
  29388. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29389. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  29390. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29391. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  29392. /**
  29393. * @hidden
  29394. */ private _setCubeMapTextureParams(loadMipmap: boolean): void;
  29395. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  29396. private _prepareWebGLTexture;
  29397. /** @hidden */ private _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29398. /** @hidden */ private _releaseFramebufferObjects(texture: InternalTexture): void;
  29399. /** @hidden */ private _releaseTexture(texture: InternalTexture): void;
  29400. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  29401. protected _setProgram(program: WebGLProgram): void;
  29402. protected _boundUniforms: {
  29403. [key: number]: WebGLUniformLocation;
  29404. };
  29405. /**
  29406. * Binds an effect to the webGL context
  29407. * @param effect defines the effect to bind
  29408. */
  29409. bindSamplers(effect: Effect): void;
  29410. private _activateCurrentTexture;
  29411. /** @hidden */ private _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29412. /** @hidden */ private _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29413. /**
  29414. * Unbind all textures from the webGL context
  29415. */
  29416. unbindAllTextures(): void;
  29417. /**
  29418. * Sets a texture to the according uniform.
  29419. * @param channel The texture channel
  29420. * @param uniform The uniform to set
  29421. * @param texture The texture to apply
  29422. */
  29423. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29424. private _bindSamplerUniformToChannel;
  29425. private _getTextureWrapMode;
  29426. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  29427. /**
  29428. * Sets an array of texture to the webGL context
  29429. * @param channel defines the channel where the texture array must be set
  29430. * @param uniform defines the associated uniform location
  29431. * @param textures defines the array of textures to bind
  29432. */
  29433. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29434. /** @hidden */ private _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29435. private _setTextureParameterFloat;
  29436. private _setTextureParameterInteger;
  29437. /**
  29438. * Unbind all vertex attributes from the webGL context
  29439. */
  29440. unbindAllAttributes(): void;
  29441. /**
  29442. * 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
  29443. */
  29444. releaseEffects(): void;
  29445. /**
  29446. * Dispose and release all associated resources
  29447. */
  29448. dispose(): void;
  29449. /**
  29450. * Attach a new callback raised when context lost event is fired
  29451. * @param callback defines the callback to call
  29452. */
  29453. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29454. /**
  29455. * Attach a new callback raised when context restored event is fired
  29456. * @param callback defines the callback to call
  29457. */
  29458. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29459. /**
  29460. * Get the current error code of the webGL context
  29461. * @returns the error code
  29462. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29463. */
  29464. getError(): number;
  29465. private _canRenderToFloatFramebuffer;
  29466. private _canRenderToHalfFloatFramebuffer;
  29467. private _canRenderToFramebuffer;
  29468. /** @hidden */ private _getWebGLTextureType(type: number): number;
  29469. /** @hidden */ private _getInternalFormat(format: number): number;
  29470. /** @hidden */ private _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29471. /** @hidden */ private _getRGBAMultiSampleBufferFormat(type: number): number;
  29472. /** @hidden */ private _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  29473. /**
  29474. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29475. * @returns true if the engine can be created
  29476. * @ignorenaming
  29477. */
  29478. static isSupported(): boolean;
  29479. /**
  29480. * Find the next highest power of two.
  29481. * @param x Number to start search from.
  29482. * @return Next highest power of two.
  29483. */
  29484. static CeilingPOT(x: number): number;
  29485. /**
  29486. * Find the next lowest power of two.
  29487. * @param x Number to start search from.
  29488. * @return Next lowest power of two.
  29489. */
  29490. static FloorPOT(x: number): number;
  29491. /**
  29492. * Find the nearest power of two.
  29493. * @param x Number to start search from.
  29494. * @return Next nearest power of two.
  29495. */
  29496. static NearestPOT(x: number): number;
  29497. /**
  29498. * Get the closest exponent of two
  29499. * @param value defines the value to approximate
  29500. * @param max defines the maximum value to return
  29501. * @param mode defines how to define the closest value
  29502. * @returns closest exponent of two of the given value
  29503. */
  29504. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  29505. /**
  29506. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  29507. * @param func - the function to be called
  29508. * @param requester - the object that will request the next frame. Falls back to window.
  29509. * @returns frame number
  29510. */
  29511. static QueueNewFrame(func: () => void, requester?: any): number;
  29512. }
  29513. }
  29514. declare module BABYLON {
  29515. /**
  29516. * Class representing spherical harmonics coefficients to the 3rd degree
  29517. */
  29518. export class SphericalHarmonics {
  29519. /**
  29520. * Defines whether or not the harmonics have been prescaled for rendering.
  29521. */
  29522. preScaled: boolean;
  29523. /**
  29524. * The l0,0 coefficients of the spherical harmonics
  29525. */
  29526. l00: Vector3;
  29527. /**
  29528. * The l1,-1 coefficients of the spherical harmonics
  29529. */
  29530. l1_1: Vector3;
  29531. /**
  29532. * The l1,0 coefficients of the spherical harmonics
  29533. */
  29534. l10: Vector3;
  29535. /**
  29536. * The l1,1 coefficients of the spherical harmonics
  29537. */
  29538. l11: Vector3;
  29539. /**
  29540. * The l2,-2 coefficients of the spherical harmonics
  29541. */
  29542. l2_2: Vector3;
  29543. /**
  29544. * The l2,-1 coefficients of the spherical harmonics
  29545. */
  29546. l2_1: Vector3;
  29547. /**
  29548. * The l2,0 coefficients of the spherical harmonics
  29549. */
  29550. l20: Vector3;
  29551. /**
  29552. * The l2,1 coefficients of the spherical harmonics
  29553. */
  29554. l21: Vector3;
  29555. /**
  29556. * The l2,2 coefficients of the spherical harmonics
  29557. */
  29558. l22: Vector3;
  29559. /**
  29560. * Adds a light to the spherical harmonics
  29561. * @param direction the direction of the light
  29562. * @param color the color of the light
  29563. * @param deltaSolidAngle the delta solid angle of the light
  29564. */
  29565. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  29566. /**
  29567. * Scales the spherical harmonics by the given amount
  29568. * @param scale the amount to scale
  29569. */
  29570. scaleInPlace(scale: number): void;
  29571. /**
  29572. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  29573. *
  29574. * ```
  29575. * E_lm = A_l * L_lm
  29576. * ```
  29577. *
  29578. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  29579. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  29580. * the scaling factors are given in equation 9.
  29581. */
  29582. convertIncidentRadianceToIrradiance(): void;
  29583. /**
  29584. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  29585. *
  29586. * ```
  29587. * L = (1/pi) * E * rho
  29588. * ```
  29589. *
  29590. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  29591. */
  29592. convertIrradianceToLambertianRadiance(): void;
  29593. /**
  29594. * Integrates the reconstruction coefficients directly in to the SH preventing further
  29595. * required operations at run time.
  29596. *
  29597. * This is simply done by scaling back the SH with Ylm constants parameter.
  29598. * The trigonometric part being applied by the shader at run time.
  29599. */
  29600. preScaleForRendering(): void;
  29601. /**
  29602. * Constructs a spherical harmonics from an array.
  29603. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  29604. * @returns the spherical harmonics
  29605. */
  29606. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  29607. /**
  29608. * Gets the spherical harmonics from polynomial
  29609. * @param polynomial the spherical polynomial
  29610. * @returns the spherical harmonics
  29611. */
  29612. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  29613. }
  29614. /**
  29615. * Class representing spherical polynomial coefficients to the 3rd degree
  29616. */
  29617. export class SphericalPolynomial {
  29618. private _harmonics;
  29619. /**
  29620. * The spherical harmonics used to create the polynomials.
  29621. */
  29622. readonly preScaledHarmonics: SphericalHarmonics;
  29623. /**
  29624. * The x coefficients of the spherical polynomial
  29625. */
  29626. x: Vector3;
  29627. /**
  29628. * The y coefficients of the spherical polynomial
  29629. */
  29630. y: Vector3;
  29631. /**
  29632. * The z coefficients of the spherical polynomial
  29633. */
  29634. z: Vector3;
  29635. /**
  29636. * The xx coefficients of the spherical polynomial
  29637. */
  29638. xx: Vector3;
  29639. /**
  29640. * The yy coefficients of the spherical polynomial
  29641. */
  29642. yy: Vector3;
  29643. /**
  29644. * The zz coefficients of the spherical polynomial
  29645. */
  29646. zz: Vector3;
  29647. /**
  29648. * The xy coefficients of the spherical polynomial
  29649. */
  29650. xy: Vector3;
  29651. /**
  29652. * The yz coefficients of the spherical polynomial
  29653. */
  29654. yz: Vector3;
  29655. /**
  29656. * The zx coefficients of the spherical polynomial
  29657. */
  29658. zx: Vector3;
  29659. /**
  29660. * Adds an ambient color to the spherical polynomial
  29661. * @param color the color to add
  29662. */
  29663. addAmbient(color: Color3): void;
  29664. /**
  29665. * Scales the spherical polynomial by the given amount
  29666. * @param scale the amount to scale
  29667. */
  29668. scaleInPlace(scale: number): void;
  29669. /**
  29670. * Gets the spherical polynomial from harmonics
  29671. * @param harmonics the spherical harmonics
  29672. * @returns the spherical polynomial
  29673. */
  29674. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  29675. /**
  29676. * Constructs a spherical polynomial from an array.
  29677. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  29678. * @returns the spherical polynomial
  29679. */
  29680. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  29681. }
  29682. }
  29683. declare module BABYLON {
  29684. /**
  29685. * Defines the source of the internal texture
  29686. */
  29687. export enum InternalTextureSource {
  29688. /**
  29689. * The source of the texture data is unknown
  29690. */
  29691. Unknown = 0,
  29692. /**
  29693. * Texture data comes from an URL
  29694. */
  29695. Url = 1,
  29696. /**
  29697. * Texture data is only used for temporary storage
  29698. */
  29699. Temp = 2,
  29700. /**
  29701. * Texture data comes from raw data (ArrayBuffer)
  29702. */
  29703. Raw = 3,
  29704. /**
  29705. * Texture content is dynamic (video or dynamic texture)
  29706. */
  29707. Dynamic = 4,
  29708. /**
  29709. * Texture content is generated by rendering to it
  29710. */
  29711. RenderTarget = 5,
  29712. /**
  29713. * Texture content is part of a multi render target process
  29714. */
  29715. MultiRenderTarget = 6,
  29716. /**
  29717. * Texture data comes from a cube data file
  29718. */
  29719. Cube = 7,
  29720. /**
  29721. * Texture data comes from a raw cube data
  29722. */
  29723. CubeRaw = 8,
  29724. /**
  29725. * Texture data come from a prefiltered cube data file
  29726. */
  29727. CubePrefiltered = 9,
  29728. /**
  29729. * Texture content is raw 3D data
  29730. */
  29731. Raw3D = 10,
  29732. /**
  29733. * Texture content is a depth texture
  29734. */
  29735. Depth = 11,
  29736. /**
  29737. * Texture data comes from a raw cube data encoded with RGBD
  29738. */
  29739. CubeRawRGBD = 12
  29740. }
  29741. /**
  29742. * Class used to store data associated with WebGL texture data for the engine
  29743. * This class should not be used directly
  29744. */
  29745. export class InternalTexture {
  29746. /** @hidden */ private static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  29747. /**
  29748. * Defines if the texture is ready
  29749. */
  29750. isReady: boolean;
  29751. /**
  29752. * Defines if the texture is a cube texture
  29753. */
  29754. isCube: boolean;
  29755. /**
  29756. * Defines if the texture contains 3D data
  29757. */
  29758. is3D: boolean;
  29759. /**
  29760. * Defines if the texture contains multiview data
  29761. */
  29762. isMultiview: boolean;
  29763. /**
  29764. * Gets the URL used to load this texture
  29765. */
  29766. url: string;
  29767. /**
  29768. * Gets the sampling mode of the texture
  29769. */
  29770. samplingMode: number;
  29771. /**
  29772. * Gets a boolean indicating if the texture needs mipmaps generation
  29773. */
  29774. generateMipMaps: boolean;
  29775. /**
  29776. * Gets the number of samples used by the texture (WebGL2+ only)
  29777. */
  29778. samples: number;
  29779. /**
  29780. * Gets the type of the texture (int, float...)
  29781. */
  29782. type: number;
  29783. /**
  29784. * Gets the format of the texture (RGB, RGBA...)
  29785. */
  29786. format: number;
  29787. /**
  29788. * Observable called when the texture is loaded
  29789. */
  29790. onLoadedObservable: Observable<InternalTexture>;
  29791. /**
  29792. * Gets the width of the texture
  29793. */
  29794. width: number;
  29795. /**
  29796. * Gets the height of the texture
  29797. */
  29798. height: number;
  29799. /**
  29800. * Gets the depth of the texture
  29801. */
  29802. depth: number;
  29803. /**
  29804. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  29805. */
  29806. baseWidth: number;
  29807. /**
  29808. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  29809. */
  29810. baseHeight: number;
  29811. /**
  29812. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  29813. */
  29814. baseDepth: number;
  29815. /**
  29816. * Gets a boolean indicating if the texture is inverted on Y axis
  29817. */
  29818. invertY: boolean;
  29819. /** @hidden */ private _invertVScale: boolean;
  29820. /** @hidden */ private _associatedChannel: number;
  29821. /** @hidden */ private _source: InternalTextureSource;
  29822. /** @hidden */ private _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  29823. /** @hidden */ private _bufferView: Nullable<ArrayBufferView>;
  29824. /** @hidden */ private _bufferViewArray: Nullable<ArrayBufferView[]>;
  29825. /** @hidden */ private _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  29826. /** @hidden */ private _size: number;
  29827. /** @hidden */ private _extension: string;
  29828. /** @hidden */ private _files: Nullable<string[]>;
  29829. /** @hidden */ private _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  29830. /** @hidden */ private _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  29831. /** @hidden */ private _framebuffer: Nullable<WebGLFramebuffer>;
  29832. /** @hidden */ private _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  29833. /** @hidden */ private _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  29834. /** @hidden */ private _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  29835. /** @hidden */ private _attachments: Nullable<number[]>;
  29836. /** @hidden */ private _cachedCoordinatesMode: Nullable<number>;
  29837. /** @hidden */ private _cachedWrapU: Nullable<number>;
  29838. /** @hidden */ private _cachedWrapV: Nullable<number>;
  29839. /** @hidden */ private _cachedWrapR: Nullable<number>;
  29840. /** @hidden */ private _cachedAnisotropicFilteringLevel: Nullable<number>;
  29841. /** @hidden */ private _isDisabled: boolean;
  29842. /** @hidden */ private _compression: Nullable<string>;
  29843. /** @hidden */ private _generateStencilBuffer: boolean;
  29844. /** @hidden */ private _generateDepthBuffer: boolean;
  29845. /** @hidden */ private _comparisonFunction: number;
  29846. /** @hidden */ private _sphericalPolynomial: Nullable<SphericalPolynomial>;
  29847. /** @hidden */ private _lodGenerationScale: number;
  29848. /** @hidden */ private _lodGenerationOffset: number;
  29849. /** @hidden */ private _colorTextureArray: Nullable<WebGLTexture>;
  29850. /** @hidden */ private _depthStencilTextureArray: Nullable<WebGLTexture>;
  29851. /** @hidden */ private _lodTextureHigh: Nullable<BaseTexture>;
  29852. /** @hidden */ private _lodTextureMid: Nullable<BaseTexture>;
  29853. /** @hidden */ private _lodTextureLow: Nullable<BaseTexture>;
  29854. /** @hidden */ private _isRGBD: boolean;
  29855. /** @hidden */ private _linearSpecularLOD: boolean;
  29856. /** @hidden */ private _irradianceTexture: Nullable<BaseTexture>;
  29857. /** @hidden */ private _webGLTexture: Nullable<WebGLTexture>;
  29858. /** @hidden */ private _references: number;
  29859. private _engine;
  29860. /**
  29861. * Gets the Engine the texture belongs to.
  29862. * @returns The babylon engine
  29863. */
  29864. getEngine(): ThinEngine;
  29865. /**
  29866. * Gets the data source type of the texture
  29867. */
  29868. readonly source: InternalTextureSource;
  29869. /**
  29870. * Creates a new InternalTexture
  29871. * @param engine defines the engine to use
  29872. * @param source defines the type of data that will be used
  29873. * @param delayAllocation if the texture allocation should be delayed (default: false)
  29874. */
  29875. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  29876. /**
  29877. * Increments the number of references (ie. the number of Texture that point to it)
  29878. */
  29879. incrementReferences(): void;
  29880. /**
  29881. * Change the size of the texture (not the size of the content)
  29882. * @param width defines the new width
  29883. * @param height defines the new height
  29884. * @param depth defines the new depth (1 by default)
  29885. */
  29886. updateSize(width: int, height: int, depth?: int): void;
  29887. /** @hidden */ private _rebuild(): void;
  29888. /** @hidden */ private _swapAndDie(target: InternalTexture): void;
  29889. /**
  29890. * Dispose the current allocated resources
  29891. */
  29892. dispose(): void;
  29893. }
  29894. }
  29895. declare module BABYLON {
  29896. /**
  29897. * Class used to work with sound analyzer using fast fourier transform (FFT)
  29898. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29899. */
  29900. export class Analyser {
  29901. /**
  29902. * Gets or sets the smoothing
  29903. * @ignorenaming
  29904. */
  29905. SMOOTHING: number;
  29906. /**
  29907. * Gets or sets the FFT table size
  29908. * @ignorenaming
  29909. */
  29910. FFT_SIZE: number;
  29911. /**
  29912. * Gets or sets the bar graph amplitude
  29913. * @ignorenaming
  29914. */
  29915. BARGRAPHAMPLITUDE: number;
  29916. /**
  29917. * Gets or sets the position of the debug canvas
  29918. * @ignorenaming
  29919. */
  29920. DEBUGCANVASPOS: {
  29921. x: number;
  29922. y: number;
  29923. };
  29924. /**
  29925. * Gets or sets the debug canvas size
  29926. * @ignorenaming
  29927. */
  29928. DEBUGCANVASSIZE: {
  29929. width: number;
  29930. height: number;
  29931. };
  29932. private _byteFreqs;
  29933. private _byteTime;
  29934. private _floatFreqs;
  29935. private _webAudioAnalyser;
  29936. private _debugCanvas;
  29937. private _debugCanvasContext;
  29938. private _scene;
  29939. private _registerFunc;
  29940. private _audioEngine;
  29941. /**
  29942. * Creates a new analyser
  29943. * @param scene defines hosting scene
  29944. */
  29945. constructor(scene: Scene);
  29946. /**
  29947. * Get the number of data values you will have to play with for the visualization
  29948. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  29949. * @returns a number
  29950. */
  29951. getFrequencyBinCount(): number;
  29952. /**
  29953. * Gets the current frequency data as a byte array
  29954. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29955. * @returns a Uint8Array
  29956. */
  29957. getByteFrequencyData(): Uint8Array;
  29958. /**
  29959. * Gets the current waveform as a byte array
  29960. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29961. * @returns a Uint8Array
  29962. */
  29963. getByteTimeDomainData(): Uint8Array;
  29964. /**
  29965. * Gets the current frequency data as a float array
  29966. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29967. * @returns a Float32Array
  29968. */
  29969. getFloatFrequencyData(): Float32Array;
  29970. /**
  29971. * Renders the debug canvas
  29972. */
  29973. drawDebugCanvas(): void;
  29974. /**
  29975. * Stops rendering the debug canvas and removes it
  29976. */
  29977. stopDebugCanvas(): void;
  29978. /**
  29979. * Connects two audio nodes
  29980. * @param inputAudioNode defines first node to connect
  29981. * @param outputAudioNode defines second node to connect
  29982. */
  29983. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  29984. /**
  29985. * Releases all associated resources
  29986. */
  29987. dispose(): void;
  29988. }
  29989. }
  29990. declare module BABYLON {
  29991. /**
  29992. * This represents an audio engine and it is responsible
  29993. * to play, synchronize and analyse sounds throughout the application.
  29994. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29995. */
  29996. export interface IAudioEngine extends IDisposable {
  29997. /**
  29998. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29999. */
  30000. readonly canUseWebAudio: boolean;
  30001. /**
  30002. * Gets the current AudioContext if available.
  30003. */
  30004. readonly audioContext: Nullable<AudioContext>;
  30005. /**
  30006. * The master gain node defines the global audio volume of your audio engine.
  30007. */
  30008. readonly masterGain: GainNode;
  30009. /**
  30010. * Gets whether or not mp3 are supported by your browser.
  30011. */
  30012. readonly isMP3supported: boolean;
  30013. /**
  30014. * Gets whether or not ogg are supported by your browser.
  30015. */
  30016. readonly isOGGsupported: boolean;
  30017. /**
  30018. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30019. * @ignoreNaming
  30020. */
  30021. WarnedWebAudioUnsupported: boolean;
  30022. /**
  30023. * Defines if the audio engine relies on a custom unlocked button.
  30024. * In this case, the embedded button will not be displayed.
  30025. */
  30026. useCustomUnlockedButton: boolean;
  30027. /**
  30028. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  30029. */
  30030. readonly unlocked: boolean;
  30031. /**
  30032. * Event raised when audio has been unlocked on the browser.
  30033. */
  30034. onAudioUnlockedObservable: Observable<AudioEngine>;
  30035. /**
  30036. * Event raised when audio has been locked on the browser.
  30037. */
  30038. onAudioLockedObservable: Observable<AudioEngine>;
  30039. /**
  30040. * Flags the audio engine in Locked state.
  30041. * This happens due to new browser policies preventing audio to autoplay.
  30042. */
  30043. lock(): void;
  30044. /**
  30045. * Unlocks the audio engine once a user action has been done on the dom.
  30046. * This is helpful to resume play once browser policies have been satisfied.
  30047. */
  30048. unlock(): void;
  30049. }
  30050. /**
  30051. * This represents the default audio engine used in babylon.
  30052. * It is responsible to play, synchronize and analyse sounds throughout the application.
  30053. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30054. */
  30055. export class AudioEngine implements IAudioEngine {
  30056. private _audioContext;
  30057. private _audioContextInitialized;
  30058. private _muteButton;
  30059. private _hostElement;
  30060. /**
  30061. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30062. */
  30063. canUseWebAudio: boolean;
  30064. /**
  30065. * The master gain node defines the global audio volume of your audio engine.
  30066. */
  30067. masterGain: GainNode;
  30068. /**
  30069. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30070. * @ignoreNaming
  30071. */
  30072. WarnedWebAudioUnsupported: boolean;
  30073. /**
  30074. * Gets whether or not mp3 are supported by your browser.
  30075. */
  30076. isMP3supported: boolean;
  30077. /**
  30078. * Gets whether or not ogg are supported by your browser.
  30079. */
  30080. isOGGsupported: boolean;
  30081. /**
  30082. * Gets whether audio has been unlocked on the device.
  30083. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  30084. * a user interaction has happened.
  30085. */
  30086. unlocked: boolean;
  30087. /**
  30088. * Defines if the audio engine relies on a custom unlocked button.
  30089. * In this case, the embedded button will not be displayed.
  30090. */
  30091. useCustomUnlockedButton: boolean;
  30092. /**
  30093. * Event raised when audio has been unlocked on the browser.
  30094. */
  30095. onAudioUnlockedObservable: Observable<AudioEngine>;
  30096. /**
  30097. * Event raised when audio has been locked on the browser.
  30098. */
  30099. onAudioLockedObservable: Observable<AudioEngine>;
  30100. /**
  30101. * Gets the current AudioContext if available.
  30102. */
  30103. readonly audioContext: Nullable<AudioContext>;
  30104. private _connectedAnalyser;
  30105. /**
  30106. * Instantiates a new audio engine.
  30107. *
  30108. * There should be only one per page as some browsers restrict the number
  30109. * of audio contexts you can create.
  30110. * @param hostElement defines the host element where to display the mute icon if necessary
  30111. */
  30112. constructor(hostElement?: Nullable<HTMLElement>);
  30113. /**
  30114. * Flags the audio engine in Locked state.
  30115. * This happens due to new browser policies preventing audio to autoplay.
  30116. */
  30117. lock(): void;
  30118. /**
  30119. * Unlocks the audio engine once a user action has been done on the dom.
  30120. * This is helpful to resume play once browser policies have been satisfied.
  30121. */
  30122. unlock(): void;
  30123. private _resumeAudioContext;
  30124. private _initializeAudioContext;
  30125. private _tryToRun;
  30126. private _triggerRunningState;
  30127. private _triggerSuspendedState;
  30128. private _displayMuteButton;
  30129. private _moveButtonToTopLeft;
  30130. private _onResize;
  30131. private _hideMuteButton;
  30132. /**
  30133. * Destroy and release the resources associated with the audio ccontext.
  30134. */
  30135. dispose(): void;
  30136. /**
  30137. * Gets the global volume sets on the master gain.
  30138. * @returns the global volume if set or -1 otherwise
  30139. */
  30140. getGlobalVolume(): number;
  30141. /**
  30142. * Sets the global volume of your experience (sets on the master gain).
  30143. * @param newVolume Defines the new global volume of the application
  30144. */
  30145. setGlobalVolume(newVolume: number): void;
  30146. /**
  30147. * Connect the audio engine to an audio analyser allowing some amazing
  30148. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30149. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30150. * @param analyser The analyser to connect to the engine
  30151. */
  30152. connectToAnalyser(analyser: Analyser): void;
  30153. }
  30154. }
  30155. declare module BABYLON {
  30156. /**
  30157. * Interface used to present a loading screen while loading a scene
  30158. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30159. */
  30160. export interface ILoadingScreen {
  30161. /**
  30162. * Function called to display the loading screen
  30163. */
  30164. displayLoadingUI: () => void;
  30165. /**
  30166. * Function called to hide the loading screen
  30167. */
  30168. hideLoadingUI: () => void;
  30169. /**
  30170. * Gets or sets the color to use for the background
  30171. */
  30172. loadingUIBackgroundColor: string;
  30173. /**
  30174. * Gets or sets the text to display while loading
  30175. */
  30176. loadingUIText: string;
  30177. }
  30178. /**
  30179. * Class used for the default loading screen
  30180. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30181. */
  30182. export class DefaultLoadingScreen implements ILoadingScreen {
  30183. private _renderingCanvas;
  30184. private _loadingText;
  30185. private _loadingDivBackgroundColor;
  30186. private _loadingDiv;
  30187. private _loadingTextDiv;
  30188. /** Gets or sets the logo url to use for the default loading screen */
  30189. static DefaultLogoUrl: string;
  30190. /** Gets or sets the spinner url to use for the default loading screen */
  30191. static DefaultSpinnerUrl: string;
  30192. /**
  30193. * Creates a new default loading screen
  30194. * @param _renderingCanvas defines the canvas used to render the scene
  30195. * @param _loadingText defines the default text to display
  30196. * @param _loadingDivBackgroundColor defines the default background color
  30197. */
  30198. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30199. /**
  30200. * Function called to display the loading screen
  30201. */
  30202. displayLoadingUI(): void;
  30203. /**
  30204. * Function called to hide the loading screen
  30205. */
  30206. hideLoadingUI(): void;
  30207. /**
  30208. * Gets or sets the text to display while loading
  30209. */
  30210. loadingUIText: string;
  30211. /**
  30212. * Gets or sets the color to use for the background
  30213. */
  30214. loadingUIBackgroundColor: string;
  30215. private _resizeLoadingUI;
  30216. }
  30217. }
  30218. declare module BABYLON {
  30219. /**
  30220. * Interface for any object that can request an animation frame
  30221. */
  30222. export interface ICustomAnimationFrameRequester {
  30223. /**
  30224. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30225. */
  30226. renderFunction?: Function;
  30227. /**
  30228. * Called to request the next frame to render to
  30229. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30230. */
  30231. requestAnimationFrame: Function;
  30232. /**
  30233. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30234. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30235. */
  30236. requestID?: number;
  30237. }
  30238. }
  30239. declare module BABYLON {
  30240. /**
  30241. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  30242. */
  30243. export class PerformanceMonitor {
  30244. private _enabled;
  30245. private _rollingFrameTime;
  30246. private _lastFrameTimeMs;
  30247. /**
  30248. * constructor
  30249. * @param frameSampleSize The number of samples required to saturate the sliding window
  30250. */
  30251. constructor(frameSampleSize?: number);
  30252. /**
  30253. * Samples current frame
  30254. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  30255. */
  30256. sampleFrame(timeMs?: number): void;
  30257. /**
  30258. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30259. */
  30260. readonly averageFrameTime: number;
  30261. /**
  30262. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30263. */
  30264. readonly averageFrameTimeVariance: number;
  30265. /**
  30266. * Returns the frame time of the most recent frame
  30267. */
  30268. readonly instantaneousFrameTime: number;
  30269. /**
  30270. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  30271. */
  30272. readonly averageFPS: number;
  30273. /**
  30274. * Returns the average framerate in frames per second using the most recent frame time
  30275. */
  30276. readonly instantaneousFPS: number;
  30277. /**
  30278. * Returns true if enough samples have been taken to completely fill the sliding window
  30279. */
  30280. readonly isSaturated: boolean;
  30281. /**
  30282. * Enables contributions to the sliding window sample set
  30283. */
  30284. enable(): void;
  30285. /**
  30286. * Disables contributions to the sliding window sample set
  30287. * Samples will not be interpolated over the disabled period
  30288. */
  30289. disable(): void;
  30290. /**
  30291. * Returns true if sampling is enabled
  30292. */
  30293. readonly isEnabled: boolean;
  30294. /**
  30295. * Resets performance monitor
  30296. */
  30297. reset(): void;
  30298. }
  30299. /**
  30300. * RollingAverage
  30301. *
  30302. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  30303. */
  30304. export class RollingAverage {
  30305. /**
  30306. * Current average
  30307. */
  30308. average: number;
  30309. /**
  30310. * Current variance
  30311. */
  30312. variance: number;
  30313. protected _samples: Array<number>;
  30314. protected _sampleCount: number;
  30315. protected _pos: number;
  30316. protected _m2: number;
  30317. /**
  30318. * constructor
  30319. * @param length The number of samples required to saturate the sliding window
  30320. */
  30321. constructor(length: number);
  30322. /**
  30323. * Adds a sample to the sample set
  30324. * @param v The sample value
  30325. */
  30326. add(v: number): void;
  30327. /**
  30328. * Returns previously added values or null if outside of history or outside the sliding window domain
  30329. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  30330. * @return Value previously recorded with add() or null if outside of range
  30331. */
  30332. history(i: number): number;
  30333. /**
  30334. * Returns true if enough samples have been taken to completely fill the sliding window
  30335. * @return true if sample-set saturated
  30336. */
  30337. isSaturated(): boolean;
  30338. /**
  30339. * Resets the rolling average (equivalent to 0 samples taken so far)
  30340. */
  30341. reset(): void;
  30342. /**
  30343. * Wraps a value around the sample range boundaries
  30344. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  30345. * @return Wrapped position in sample range
  30346. */
  30347. protected _wrapPosition(i: number): number;
  30348. }
  30349. }
  30350. declare module BABYLON {
  30351. /**
  30352. * This class is used to track a performance counter which is number based.
  30353. * The user has access to many properties which give statistics of different nature.
  30354. *
  30355. * The implementer can track two kinds of Performance Counter: time and count.
  30356. * 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.
  30357. * 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.
  30358. */
  30359. export class PerfCounter {
  30360. /**
  30361. * Gets or sets a global boolean to turn on and off all the counters
  30362. */
  30363. static Enabled: boolean;
  30364. /**
  30365. * Returns the smallest value ever
  30366. */
  30367. readonly min: number;
  30368. /**
  30369. * Returns the biggest value ever
  30370. */
  30371. readonly max: number;
  30372. /**
  30373. * Returns the average value since the performance counter is running
  30374. */
  30375. readonly average: number;
  30376. /**
  30377. * Returns the average value of the last second the counter was monitored
  30378. */
  30379. readonly lastSecAverage: number;
  30380. /**
  30381. * Returns the current value
  30382. */
  30383. readonly current: number;
  30384. /**
  30385. * Gets the accumulated total
  30386. */
  30387. readonly total: number;
  30388. /**
  30389. * Gets the total value count
  30390. */
  30391. readonly count: number;
  30392. /**
  30393. * Creates a new counter
  30394. */
  30395. constructor();
  30396. /**
  30397. * Call this method to start monitoring a new frame.
  30398. * 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.
  30399. */
  30400. fetchNewFrame(): void;
  30401. /**
  30402. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30403. * @param newCount the count value to add to the monitored count
  30404. * @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.
  30405. */
  30406. addCount(newCount: number, fetchResult: boolean): void;
  30407. /**
  30408. * Start monitoring this performance counter
  30409. */
  30410. beginMonitoring(): void;
  30411. /**
  30412. * Compute the time lapsed since the previous beginMonitoring() call.
  30413. * @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
  30414. */
  30415. endMonitoring(newFrame?: boolean): void;
  30416. private _fetchResult;
  30417. private _startMonitoringTime;
  30418. private _min;
  30419. private _max;
  30420. private _average;
  30421. private _current;
  30422. private _totalValueCount;
  30423. private _totalAccumulated;
  30424. private _lastSecAverage;
  30425. private _lastSecAccumulated;
  30426. private _lastSecTime;
  30427. private _lastSecValueCount;
  30428. }
  30429. }
  30430. declare module BABYLON {
  30431. /**
  30432. * Defines the interface used by display changed events
  30433. */
  30434. export interface IDisplayChangedEventArgs {
  30435. /** Gets the vrDisplay object (if any) */
  30436. vrDisplay: Nullable<any>;
  30437. /** Gets a boolean indicating if webVR is supported */
  30438. vrSupported: boolean;
  30439. }
  30440. /**
  30441. * Defines the interface used by objects containing a viewport (like a camera)
  30442. */
  30443. interface IViewportOwnerLike {
  30444. /**
  30445. * Gets or sets the viewport
  30446. */
  30447. viewport: IViewportLike;
  30448. }
  30449. /**
  30450. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30451. */
  30452. export class Engine extends ThinEngine {
  30453. /** Defines that alpha blending is disabled */
  30454. static readonly ALPHA_DISABLE: number;
  30455. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30456. static readonly ALPHA_ADD: number;
  30457. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30458. static readonly ALPHA_COMBINE: number;
  30459. /** Defines that alpha blending to DEST - SRC * DEST */
  30460. static readonly ALPHA_SUBTRACT: number;
  30461. /** Defines that alpha blending to SRC * DEST */
  30462. static readonly ALPHA_MULTIPLY: number;
  30463. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  30464. static readonly ALPHA_MAXIMIZED: number;
  30465. /** Defines that alpha blending to SRC + DEST */
  30466. static readonly ALPHA_ONEONE: number;
  30467. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  30468. static readonly ALPHA_PREMULTIPLIED: number;
  30469. /**
  30470. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  30471. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  30472. */
  30473. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  30474. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  30475. static readonly ALPHA_INTERPOLATE: number;
  30476. /**
  30477. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  30478. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  30479. */
  30480. static readonly ALPHA_SCREENMODE: number;
  30481. /** Defines that the ressource is not delayed*/
  30482. static readonly DELAYLOADSTATE_NONE: number;
  30483. /** Defines that the ressource was successfully delay loaded */
  30484. static readonly DELAYLOADSTATE_LOADED: number;
  30485. /** Defines that the ressource is currently delay loading */
  30486. static readonly DELAYLOADSTATE_LOADING: number;
  30487. /** Defines that the ressource is delayed and has not started loading */
  30488. static readonly DELAYLOADSTATE_NOTLOADED: number;
  30489. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  30490. static readonly NEVER: number;
  30491. /** 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 */
  30492. static readonly ALWAYS: number;
  30493. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  30494. static readonly LESS: number;
  30495. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  30496. static readonly EQUAL: number;
  30497. /** 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 */
  30498. static readonly LEQUAL: number;
  30499. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  30500. static readonly GREATER: number;
  30501. /** 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 */
  30502. static readonly GEQUAL: number;
  30503. /** 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 */
  30504. static readonly NOTEQUAL: number;
  30505. /** Passed to stencilOperation to specify that stencil value must be kept */
  30506. static readonly KEEP: number;
  30507. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30508. static readonly REPLACE: number;
  30509. /** Passed to stencilOperation to specify that stencil value must be incremented */
  30510. static readonly INCR: number;
  30511. /** Passed to stencilOperation to specify that stencil value must be decremented */
  30512. static readonly DECR: number;
  30513. /** Passed to stencilOperation to specify that stencil value must be inverted */
  30514. static readonly INVERT: number;
  30515. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  30516. static readonly INCR_WRAP: number;
  30517. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  30518. static readonly DECR_WRAP: number;
  30519. /** Texture is not repeating outside of 0..1 UVs */
  30520. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  30521. /** Texture is repeating outside of 0..1 UVs */
  30522. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  30523. /** Texture is repeating and mirrored */
  30524. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  30525. /** ALPHA */
  30526. static readonly TEXTUREFORMAT_ALPHA: number;
  30527. /** LUMINANCE */
  30528. static readonly TEXTUREFORMAT_LUMINANCE: number;
  30529. /** LUMINANCE_ALPHA */
  30530. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  30531. /** RGB */
  30532. static readonly TEXTUREFORMAT_RGB: number;
  30533. /** RGBA */
  30534. static readonly TEXTUREFORMAT_RGBA: number;
  30535. /** RED */
  30536. static readonly TEXTUREFORMAT_RED: number;
  30537. /** RED (2nd reference) */
  30538. static readonly TEXTUREFORMAT_R: number;
  30539. /** RG */
  30540. static readonly TEXTUREFORMAT_RG: number;
  30541. /** RED_INTEGER */
  30542. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  30543. /** RED_INTEGER (2nd reference) */
  30544. static readonly TEXTUREFORMAT_R_INTEGER: number;
  30545. /** RG_INTEGER */
  30546. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  30547. /** RGB_INTEGER */
  30548. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  30549. /** RGBA_INTEGER */
  30550. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  30551. /** UNSIGNED_BYTE */
  30552. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  30553. /** UNSIGNED_BYTE (2nd reference) */
  30554. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  30555. /** FLOAT */
  30556. static readonly TEXTURETYPE_FLOAT: number;
  30557. /** HALF_FLOAT */
  30558. static readonly TEXTURETYPE_HALF_FLOAT: number;
  30559. /** BYTE */
  30560. static readonly TEXTURETYPE_BYTE: number;
  30561. /** SHORT */
  30562. static readonly TEXTURETYPE_SHORT: number;
  30563. /** UNSIGNED_SHORT */
  30564. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  30565. /** INT */
  30566. static readonly TEXTURETYPE_INT: number;
  30567. /** UNSIGNED_INT */
  30568. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  30569. /** UNSIGNED_SHORT_4_4_4_4 */
  30570. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  30571. /** UNSIGNED_SHORT_5_5_5_1 */
  30572. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  30573. /** UNSIGNED_SHORT_5_6_5 */
  30574. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  30575. /** UNSIGNED_INT_2_10_10_10_REV */
  30576. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  30577. /** UNSIGNED_INT_24_8 */
  30578. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  30579. /** UNSIGNED_INT_10F_11F_11F_REV */
  30580. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  30581. /** UNSIGNED_INT_5_9_9_9_REV */
  30582. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  30583. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  30584. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  30585. /** nearest is mag = nearest and min = nearest and mip = linear */
  30586. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  30587. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30588. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  30589. /** Trilinear is mag = linear and min = linear and mip = linear */
  30590. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  30591. /** nearest is mag = nearest and min = nearest and mip = linear */
  30592. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  30593. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30594. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  30595. /** Trilinear is mag = linear and min = linear and mip = linear */
  30596. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  30597. /** mag = nearest and min = nearest and mip = nearest */
  30598. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  30599. /** mag = nearest and min = linear and mip = nearest */
  30600. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  30601. /** mag = nearest and min = linear and mip = linear */
  30602. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  30603. /** mag = nearest and min = linear and mip = none */
  30604. static readonly TEXTURE_NEAREST_LINEAR: number;
  30605. /** mag = nearest and min = nearest and mip = none */
  30606. static readonly TEXTURE_NEAREST_NEAREST: number;
  30607. /** mag = linear and min = nearest and mip = nearest */
  30608. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  30609. /** mag = linear and min = nearest and mip = linear */
  30610. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  30611. /** mag = linear and min = linear and mip = none */
  30612. static readonly TEXTURE_LINEAR_LINEAR: number;
  30613. /** mag = linear and min = nearest and mip = none */
  30614. static readonly TEXTURE_LINEAR_NEAREST: number;
  30615. /** Explicit coordinates mode */
  30616. static readonly TEXTURE_EXPLICIT_MODE: number;
  30617. /** Spherical coordinates mode */
  30618. static readonly TEXTURE_SPHERICAL_MODE: number;
  30619. /** Planar coordinates mode */
  30620. static readonly TEXTURE_PLANAR_MODE: number;
  30621. /** Cubic coordinates mode */
  30622. static readonly TEXTURE_CUBIC_MODE: number;
  30623. /** Projection coordinates mode */
  30624. static readonly TEXTURE_PROJECTION_MODE: number;
  30625. /** Skybox coordinates mode */
  30626. static readonly TEXTURE_SKYBOX_MODE: number;
  30627. /** Inverse Cubic coordinates mode */
  30628. static readonly TEXTURE_INVCUBIC_MODE: number;
  30629. /** Equirectangular coordinates mode */
  30630. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  30631. /** Equirectangular Fixed coordinates mode */
  30632. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  30633. /** Equirectangular Fixed Mirrored coordinates mode */
  30634. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  30635. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  30636. static readonly SCALEMODE_FLOOR: number;
  30637. /** Defines that texture rescaling will look for the nearest power of 2 size */
  30638. static readonly SCALEMODE_NEAREST: number;
  30639. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  30640. static readonly SCALEMODE_CEILING: number;
  30641. /**
  30642. * Returns the current npm package of the sdk
  30643. */
  30644. static readonly NpmPackage: string;
  30645. /**
  30646. * Returns the current version of the framework
  30647. */
  30648. static readonly Version: string;
  30649. /** Gets the list of created engines */
  30650. static readonly Instances: Engine[];
  30651. /**
  30652. * Gets the latest created engine
  30653. */
  30654. static readonly LastCreatedEngine: Nullable<Engine>;
  30655. /**
  30656. * Gets the latest created scene
  30657. */
  30658. static readonly LastCreatedScene: Nullable<Scene>;
  30659. /**
  30660. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  30661. * @param flag defines which part of the materials must be marked as dirty
  30662. * @param predicate defines a predicate used to filter which materials should be affected
  30663. */
  30664. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  30665. /**
  30666. * Method called to create the default loading screen.
  30667. * This can be overriden in your own app.
  30668. * @param canvas The rendering canvas element
  30669. * @returns The loading screen
  30670. */
  30671. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30672. /**
  30673. * Method called to create the default rescale post process on each engine.
  30674. */ private static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30675. /**
  30676. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  30677. **/
  30678. enableOfflineSupport: boolean;
  30679. /**
  30680. * 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)
  30681. **/
  30682. disableManifestCheck: boolean;
  30683. /**
  30684. * Gets the list of created scenes
  30685. */
  30686. scenes: Scene[];
  30687. /**
  30688. * Event raised when a new scene is created
  30689. */
  30690. onNewSceneAddedObservable: Observable<Scene>;
  30691. /**
  30692. * Gets the list of created postprocesses
  30693. */
  30694. postProcesses: PostProcess[];
  30695. /**
  30696. * Gets a boolean indicating if the pointer is currently locked
  30697. */
  30698. isPointerLock: boolean;
  30699. /**
  30700. * Observable event triggered each time the rendering canvas is resized
  30701. */
  30702. onResizeObservable: Observable<Engine>;
  30703. /**
  30704. * Observable event triggered each time the canvas loses focus
  30705. */
  30706. onCanvasBlurObservable: Observable<Engine>;
  30707. /**
  30708. * Observable event triggered each time the canvas gains focus
  30709. */
  30710. onCanvasFocusObservable: Observable<Engine>;
  30711. /**
  30712. * Observable event triggered each time the canvas receives pointerout event
  30713. */
  30714. onCanvasPointerOutObservable: Observable<PointerEvent>;
  30715. /**
  30716. * Observable raised when the engine begins a new frame
  30717. */
  30718. onBeginFrameObservable: Observable<Engine>;
  30719. /**
  30720. * If set, will be used to request the next animation frame for the render loop
  30721. */
  30722. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30723. /**
  30724. * Observable raised when the engine ends the current frame
  30725. */
  30726. onEndFrameObservable: Observable<Engine>;
  30727. /**
  30728. * Observable raised when the engine is about to compile a shader
  30729. */
  30730. onBeforeShaderCompilationObservable: Observable<Engine>;
  30731. /**
  30732. * Observable raised when the engine has jsut compiled a shader
  30733. */
  30734. onAfterShaderCompilationObservable: Observable<Engine>;
  30735. /**
  30736. * Gets the audio engine
  30737. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30738. * @ignorenaming
  30739. */
  30740. static audioEngine: IAudioEngine;
  30741. /**
  30742. * Default AudioEngine factory responsible of creating the Audio Engine.
  30743. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  30744. */
  30745. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  30746. /**
  30747. * Default offline support factory responsible of creating a tool used to store data locally.
  30748. * By default, this will create a Database object if the workload has been embedded.
  30749. */
  30750. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  30751. private _loadingScreen;
  30752. private _pointerLockRequested;
  30753. private _dummyFramebuffer;
  30754. private _rescalePostProcess;
  30755. /** @hidden */
  30756. protected _alphaMode: number;
  30757. /** @hidden */
  30758. protected _alphaEquation: number;
  30759. private _deterministicLockstep;
  30760. private _lockstepMaxSteps;
  30761. protected readonly _supportsHardwareTextureRescaling: boolean;
  30762. private _fps;
  30763. private _deltaTime;
  30764. /** @hidden */ private _drawCalls: PerfCounter;
  30765. /**
  30766. * Turn this value on if you want to pause FPS computation when in background
  30767. */
  30768. disablePerformanceMonitorInBackground: boolean;
  30769. private _performanceMonitor;
  30770. /**
  30771. * Gets the performance monitor attached to this engine
  30772. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  30773. */
  30774. readonly performanceMonitor: PerformanceMonitor;
  30775. private _onFocus;
  30776. private _onBlur;
  30777. private _onCanvasPointerOut;
  30778. private _onCanvasBlur;
  30779. private _onCanvasFocus;
  30780. private _onFullscreenChange;
  30781. private _onPointerLockChange;
  30782. /**
  30783. * Creates a new engine
  30784. * @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
  30785. * @param antialias defines enable antialiasing (default: false)
  30786. * @param options defines further options to be sent to the getContext() function
  30787. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30788. */
  30789. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30790. /**
  30791. * Gets current aspect ratio
  30792. * @param viewportOwner defines the camera to use to get the aspect ratio
  30793. * @param useScreen defines if screen size must be used (or the current render target if any)
  30794. * @returns a number defining the aspect ratio
  30795. */
  30796. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  30797. /**
  30798. * Gets current screen aspect ratio
  30799. * @returns a number defining the aspect ratio
  30800. */
  30801. getScreenAspectRatio(): number;
  30802. /**
  30803. * Gets host document
  30804. * @returns the host document object
  30805. */
  30806. getHostDocument(): Document;
  30807. /**
  30808. * Gets the client rect of the HTML canvas attached with the current webGL context
  30809. * @returns a client rectanglee
  30810. */
  30811. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  30812. /**
  30813. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  30814. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30815. * @returns true if engine is in deterministic lock step mode
  30816. */
  30817. isDeterministicLockStep(): boolean;
  30818. /**
  30819. * Gets the max steps when engine is running in deterministic lock step
  30820. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30821. * @returns the max steps
  30822. */
  30823. getLockstepMaxSteps(): number;
  30824. /**
  30825. * Force the mipmap generation for the given render target texture
  30826. * @param texture defines the render target texture to use
  30827. */
  30828. generateMipMapsForCubemap(texture: InternalTexture): void;
  30829. /** States */
  30830. /**
  30831. * Set various states to the webGL context
  30832. * @param culling defines backface culling state
  30833. * @param zOffset defines the value to apply to zOffset (0 by default)
  30834. * @param force defines if states must be applied even if cache is up to date
  30835. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  30836. */
  30837. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  30838. /**
  30839. * Set the z offset to apply to current rendering
  30840. * @param value defines the offset to apply
  30841. */
  30842. setZOffset(value: number): void;
  30843. /**
  30844. * Gets the current value of the zOffset
  30845. * @returns the current zOffset state
  30846. */
  30847. getZOffset(): number;
  30848. /**
  30849. * Enable or disable depth buffering
  30850. * @param enable defines the state to set
  30851. */
  30852. setDepthBuffer(enable: boolean): void;
  30853. /**
  30854. * Gets a boolean indicating if depth writing is enabled
  30855. * @returns the current depth writing state
  30856. */
  30857. getDepthWrite(): boolean;
  30858. /**
  30859. * Enable or disable depth writing
  30860. * @param enable defines the state to set
  30861. */
  30862. setDepthWrite(enable: boolean): void;
  30863. /**
  30864. * Enable or disable color writing
  30865. * @param enable defines the state to set
  30866. */
  30867. setColorWrite(enable: boolean): void;
  30868. /**
  30869. * Gets a boolean indicating if color writing is enabled
  30870. * @returns the current color writing state
  30871. */
  30872. getColorWrite(): boolean;
  30873. /**
  30874. * Sets alpha constants used by some alpha blending modes
  30875. * @param r defines the red component
  30876. * @param g defines the green component
  30877. * @param b defines the blue component
  30878. * @param a defines the alpha component
  30879. */
  30880. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  30881. /**
  30882. * Sets the current alpha mode
  30883. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  30884. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  30885. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  30886. */
  30887. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  30888. /**
  30889. * Gets the current alpha mode
  30890. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  30891. * @returns the current alpha mode
  30892. */
  30893. getAlphaMode(): number;
  30894. /**
  30895. * Sets the current alpha equation
  30896. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  30897. */
  30898. setAlphaEquation(equation: number): void;
  30899. /**
  30900. * Gets the current alpha equation.
  30901. * @returns the current alpha equation
  30902. */
  30903. getAlphaEquation(): number;
  30904. /**
  30905. * Gets a boolean indicating if stencil buffer is enabled
  30906. * @returns the current stencil buffer state
  30907. */
  30908. getStencilBuffer(): boolean;
  30909. /**
  30910. * Enable or disable the stencil buffer
  30911. * @param enable defines if the stencil buffer must be enabled or disabled
  30912. */
  30913. setStencilBuffer(enable: boolean): void;
  30914. /**
  30915. * Gets the current stencil mask
  30916. * @returns a number defining the new stencil mask to use
  30917. */
  30918. getStencilMask(): number;
  30919. /**
  30920. * Sets the current stencil mask
  30921. * @param mask defines the new stencil mask to use
  30922. */
  30923. setStencilMask(mask: number): void;
  30924. /**
  30925. * Gets the current stencil function
  30926. * @returns a number defining the stencil function to use
  30927. */
  30928. getStencilFunction(): number;
  30929. /**
  30930. * Gets the current stencil reference value
  30931. * @returns a number defining the stencil reference value to use
  30932. */
  30933. getStencilFunctionReference(): number;
  30934. /**
  30935. * Gets the current stencil mask
  30936. * @returns a number defining the stencil mask to use
  30937. */
  30938. getStencilFunctionMask(): number;
  30939. /**
  30940. * Sets the current stencil function
  30941. * @param stencilFunc defines the new stencil function to use
  30942. */
  30943. setStencilFunction(stencilFunc: number): void;
  30944. /**
  30945. * Sets the current stencil reference
  30946. * @param reference defines the new stencil reference to use
  30947. */
  30948. setStencilFunctionReference(reference: number): void;
  30949. /**
  30950. * Sets the current stencil mask
  30951. * @param mask defines the new stencil mask to use
  30952. */
  30953. setStencilFunctionMask(mask: number): void;
  30954. /**
  30955. * Gets the current stencil operation when stencil fails
  30956. * @returns a number defining stencil operation to use when stencil fails
  30957. */
  30958. getStencilOperationFail(): number;
  30959. /**
  30960. * Gets the current stencil operation when depth fails
  30961. * @returns a number defining stencil operation to use when depth fails
  30962. */
  30963. getStencilOperationDepthFail(): number;
  30964. /**
  30965. * Gets the current stencil operation when stencil passes
  30966. * @returns a number defining stencil operation to use when stencil passes
  30967. */
  30968. getStencilOperationPass(): number;
  30969. /**
  30970. * Sets the stencil operation to use when stencil fails
  30971. * @param operation defines the stencil operation to use when stencil fails
  30972. */
  30973. setStencilOperationFail(operation: number): void;
  30974. /**
  30975. * Sets the stencil operation to use when depth fails
  30976. * @param operation defines the stencil operation to use when depth fails
  30977. */
  30978. setStencilOperationDepthFail(operation: number): void;
  30979. /**
  30980. * Sets the stencil operation to use when stencil passes
  30981. * @param operation defines the stencil operation to use when stencil passes
  30982. */
  30983. setStencilOperationPass(operation: number): void;
  30984. /**
  30985. * Sets a boolean indicating if the dithering state is enabled or disabled
  30986. * @param value defines the dithering state
  30987. */
  30988. setDitheringState(value: boolean): void;
  30989. /**
  30990. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  30991. * @param value defines the rasterizer state
  30992. */
  30993. setRasterizerState(value: boolean): void;
  30994. /**
  30995. * Gets the current depth function
  30996. * @returns a number defining the depth function
  30997. */
  30998. getDepthFunction(): Nullable<number>;
  30999. /**
  31000. * Sets the current depth function
  31001. * @param depthFunc defines the function to use
  31002. */
  31003. setDepthFunction(depthFunc: number): void;
  31004. /**
  31005. * Sets the current depth function to GREATER
  31006. */
  31007. setDepthFunctionToGreater(): void;
  31008. /**
  31009. * Sets the current depth function to GEQUAL
  31010. */
  31011. setDepthFunctionToGreaterOrEqual(): void;
  31012. /**
  31013. * Sets the current depth function to LESS
  31014. */
  31015. setDepthFunctionToLess(): void;
  31016. /**
  31017. * Sets the current depth function to LEQUAL
  31018. */
  31019. setDepthFunctionToLessOrEqual(): void;
  31020. private _cachedStencilBuffer;
  31021. private _cachedStencilFunction;
  31022. private _cachedStencilMask;
  31023. private _cachedStencilOperationPass;
  31024. private _cachedStencilOperationFail;
  31025. private _cachedStencilOperationDepthFail;
  31026. private _cachedStencilReference;
  31027. /**
  31028. * Caches the the state of the stencil buffer
  31029. */
  31030. cacheStencilState(): void;
  31031. /**
  31032. * Restores the state of the stencil buffer
  31033. */
  31034. restoreStencilState(): void;
  31035. /**
  31036. * Directly set the WebGL Viewport
  31037. * @param x defines the x coordinate of the viewport (in screen space)
  31038. * @param y defines the y coordinate of the viewport (in screen space)
  31039. * @param width defines the width of the viewport (in screen space)
  31040. * @param height defines the height of the viewport (in screen space)
  31041. * @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
  31042. */
  31043. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31044. /**
  31045. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31046. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31047. * @param y defines the y-coordinate of the corner of the clear rectangle
  31048. * @param width defines the width of the clear rectangle
  31049. * @param height defines the height of the clear rectangle
  31050. * @param clearColor defines the clear color
  31051. */
  31052. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31053. /**
  31054. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31055. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31056. * @param y defines the y-coordinate of the corner of the clear rectangle
  31057. * @param width defines the width of the clear rectangle
  31058. * @param height defines the height of the clear rectangle
  31059. */
  31060. enableScissor(x: number, y: number, width: number, height: number): void;
  31061. /**
  31062. * Disable previously set scissor test rectangle
  31063. */
  31064. disableScissor(): void;
  31065. protected _reportDrawCall(): void;
  31066. /**
  31067. * Initializes a webVR display and starts listening to display change events
  31068. * The onVRDisplayChangedObservable will be notified upon these changes
  31069. * @returns The onVRDisplayChangedObservable
  31070. */
  31071. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31072. /** @hidden */ private _prepareVRComponent(): void;
  31073. /** @hidden */ private _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  31074. /** @hidden */ private _submitVRFrame(): void;
  31075. /**
  31076. * Call this function to leave webVR mode
  31077. * Will do nothing if webVR is not supported or if there is no webVR device
  31078. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31079. */
  31080. disableVR(): void;
  31081. /**
  31082. * Gets a boolean indicating that the system is in VR mode and is presenting
  31083. * @returns true if VR mode is engaged
  31084. */
  31085. isVRPresenting(): boolean;
  31086. /** @hidden */ private _requestVRFrame(): void;
  31087. /** @hidden */ private _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31088. /**
  31089. * Gets the source code of the vertex shader associated with a specific webGL program
  31090. * @param program defines the program to use
  31091. * @returns a string containing the source code of the vertex shader associated with the program
  31092. */
  31093. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  31094. /**
  31095. * Gets the source code of the fragment shader associated with a specific webGL program
  31096. * @param program defines the program to use
  31097. * @returns a string containing the source code of the fragment shader associated with the program
  31098. */
  31099. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  31100. /**
  31101. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31102. * @param x defines the x coordinate of the rectangle where pixels must be read
  31103. * @param y defines the y coordinate of the rectangle where pixels must be read
  31104. * @param width defines the width of the rectangle where pixels must be read
  31105. * @param height defines the height of the rectangle where pixels must be read
  31106. * @returns a Uint8Array containing RGBA colors
  31107. */
  31108. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  31109. /**
  31110. * Sets a depth stencil texture from a render target to the according uniform.
  31111. * @param channel The texture channel
  31112. * @param uniform The uniform to set
  31113. * @param texture The render target texture containing the depth stencil texture to apply
  31114. */
  31115. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  31116. /**
  31117. * Sets a texture to the webGL context from a postprocess
  31118. * @param channel defines the channel to use
  31119. * @param postProcess defines the source postprocess
  31120. */
  31121. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  31122. /**
  31123. * Binds the output of the passed in post process to the texture channel specified
  31124. * @param channel The channel the texture should be bound to
  31125. * @param postProcess The post process which's output should be bound
  31126. */
  31127. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  31128. /** @hidden */ private _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  31129. protected _rebuildBuffers(): void; private _renderLoop(): void;
  31130. /**
  31131. * Toggle full screen mode
  31132. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31133. */
  31134. switchFullscreen(requestPointerLock: boolean): void;
  31135. /**
  31136. * Enters full screen mode
  31137. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31138. */
  31139. enterFullscreen(requestPointerLock: boolean): void;
  31140. /**
  31141. * Exits full screen mode
  31142. */
  31143. exitFullscreen(): void;
  31144. /**
  31145. * Enters Pointerlock mode
  31146. */
  31147. enterPointerlock(): void;
  31148. /**
  31149. * Exits Pointerlock mode
  31150. */
  31151. exitPointerlock(): void;
  31152. /**
  31153. * Begin a new frame
  31154. */
  31155. beginFrame(): void;
  31156. /**
  31157. * Enf the current frame
  31158. */
  31159. endFrame(): void;
  31160. resize(): void;
  31161. /**
  31162. * Set the compressed texture format to use, based on the formats you have, and the formats
  31163. * supported by the hardware / browser.
  31164. *
  31165. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31166. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31167. * to API arguments needed to compressed textures. This puts the burden on the container
  31168. * generator to house the arcane code for determining these for current & future formats.
  31169. *
  31170. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31171. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31172. *
  31173. * Note: The result of this call is not taken into account when a texture is base64.
  31174. *
  31175. * @param formatsAvailable defines the list of those format families you have created
  31176. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31177. *
  31178. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31179. * @returns The extension selected.
  31180. */
  31181. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31182. /**
  31183. * Force a specific size of the canvas
  31184. * @param width defines the new canvas' width
  31185. * @param height defines the new canvas' height
  31186. */
  31187. setSize(width: number, height: number): void; private _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31188. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31189. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram; private _releaseTexture(texture: InternalTexture): void;
  31190. /**
  31191. * @hidden
  31192. * Rescales a texture
  31193. * @param source input texutre
  31194. * @param destination destination texture
  31195. * @param scene scene to use to render the resize
  31196. * @param internalFormat format to use when resizing
  31197. * @param onComplete callback to be called when resize has completed
  31198. */ private _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31199. /**
  31200. * Gets the current framerate
  31201. * @returns a number representing the framerate
  31202. */
  31203. getFps(): number;
  31204. /**
  31205. * Gets the time spent between current and previous frame
  31206. * @returns a number representing the delta time in ms
  31207. */
  31208. getDeltaTime(): number;
  31209. private _measureFps;
  31210. /**
  31211. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31212. * @param renderTarget The render target to set the frame buffer for
  31213. */
  31214. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  31215. /**
  31216. * Update a dynamic index buffer
  31217. * @param indexBuffer defines the target index buffer
  31218. * @param indices defines the data to update
  31219. * @param offset defines the offset in the target index buffer where update should start
  31220. */
  31221. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31222. /**
  31223. * Updates the sample count of a render target texture
  31224. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31225. * @param texture defines the texture to update
  31226. * @param samples defines the sample count to set
  31227. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31228. */
  31229. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  31230. /** @hidden */ private _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  31231. dispose(): void;
  31232. private _disableTouchAction;
  31233. /**
  31234. * Display the loading screen
  31235. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31236. */
  31237. displayLoadingUI(): void;
  31238. /**
  31239. * Hide the loading screen
  31240. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31241. */
  31242. hideLoadingUI(): void;
  31243. /**
  31244. * Gets the current loading screen object
  31245. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31246. */
  31247. /**
  31248. * Sets the current loading screen object
  31249. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31250. */
  31251. loadingScreen: ILoadingScreen;
  31252. /**
  31253. * Sets the current loading screen text
  31254. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31255. */
  31256. loadingUIText: string;
  31257. /**
  31258. * Sets the current loading screen background color
  31259. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31260. */
  31261. loadingUIBackgroundColor: string;
  31262. /** Pointerlock and fullscreen */
  31263. /**
  31264. * Ask the browser to promote the current element to pointerlock mode
  31265. * @param element defines the DOM element to promote
  31266. */ private static _RequestPointerlock(element: HTMLElement): void;
  31267. /**
  31268. * Asks the browser to exit pointerlock mode
  31269. */ private static _ExitPointerlock(): void;
  31270. /**
  31271. * Ask the browser to promote the current element to fullscreen rendering mode
  31272. * @param element defines the DOM element to promote
  31273. */ private static _RequestFullscreen(element: HTMLElement): void;
  31274. /**
  31275. * Asks the browser to exit fullscreen mode
  31276. */ private static _ExitFullscreen(): void;
  31277. }
  31278. }
  31279. declare module BABYLON {
  31280. /**
  31281. * The engine store class is responsible to hold all the instances of Engine and Scene created
  31282. * during the life time of the application.
  31283. */
  31284. export class EngineStore {
  31285. /** Gets the list of created engines */
  31286. static Instances: Engine[];
  31287. /** @hidden */ private static _LastCreatedScene: Nullable<Scene>;
  31288. /**
  31289. * Gets the latest created engine
  31290. */
  31291. static readonly LastCreatedEngine: Nullable<Engine>;
  31292. /**
  31293. * Gets the latest created scene
  31294. */
  31295. static readonly LastCreatedScene: Nullable<Scene>;
  31296. /**
  31297. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31298. * @ignorenaming
  31299. */
  31300. static UseFallbackTexture: boolean;
  31301. /**
  31302. * Texture content used if a texture cannot loaded
  31303. * @ignorenaming
  31304. */
  31305. static FallbackTexture: string;
  31306. }
  31307. }
  31308. declare module BABYLON {
  31309. /**
  31310. * Helper class that provides a small promise polyfill
  31311. */
  31312. export class PromisePolyfill {
  31313. /**
  31314. * Static function used to check if the polyfill is required
  31315. * If this is the case then the function will inject the polyfill to window.Promise
  31316. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31317. */
  31318. static Apply(force?: boolean): void;
  31319. }
  31320. }
  31321. declare module BABYLON {
  31322. /**
  31323. * Interface for screenshot methods with describe argument called `size` as object with options
  31324. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  31325. */
  31326. export interface IScreenshotSize {
  31327. /**
  31328. * number in pixels for canvas height
  31329. */
  31330. height?: number;
  31331. /**
  31332. * multiplier allowing render at a higher or lower resolution
  31333. * If value is defined then height and width will be ignored and taken from camera
  31334. */
  31335. precision?: number;
  31336. /**
  31337. * number in pixels for canvas width
  31338. */
  31339. width?: number;
  31340. }
  31341. }
  31342. declare module BABYLON {
  31343. interface IColor4Like {
  31344. r: float;
  31345. g: float;
  31346. b: float;
  31347. a: float;
  31348. }
  31349. /**
  31350. * Class containing a set of static utilities functions
  31351. */
  31352. export class Tools {
  31353. /**
  31354. * Gets or sets the base URL to use to load assets
  31355. */
  31356. static BaseUrl: string;
  31357. /**
  31358. * Enable/Disable Custom HTTP Request Headers globally.
  31359. * default = false
  31360. * @see CustomRequestHeaders
  31361. */
  31362. static UseCustomRequestHeaders: boolean;
  31363. /**
  31364. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31365. * i.e. when loading files, where the server/service expects an Authorization header
  31366. */
  31367. static CustomRequestHeaders: {
  31368. [key: string]: string;
  31369. };
  31370. /**
  31371. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31372. */
  31373. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31374. /**
  31375. * Default behaviour for cors in the application.
  31376. * It can be a string if the expected behavior is identical in the entire app.
  31377. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31378. */
  31379. static CorsBehavior: string | ((url: string | string[]) => string);
  31380. /**
  31381. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31382. * @ignorenaming
  31383. */
  31384. static UseFallbackTexture: boolean;
  31385. /**
  31386. * Use this object to register external classes like custom textures or material
  31387. * to allow the laoders to instantiate them
  31388. */
  31389. static RegisteredExternalClasses: {
  31390. [key: string]: Object;
  31391. };
  31392. /**
  31393. * Texture content used if a texture cannot loaded
  31394. * @ignorenaming
  31395. */
  31396. static fallbackTexture: string;
  31397. /**
  31398. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31399. * @param u defines the coordinate on X axis
  31400. * @param v defines the coordinate on Y axis
  31401. * @param width defines the width of the source data
  31402. * @param height defines the height of the source data
  31403. * @param pixels defines the source byte array
  31404. * @param color defines the output color
  31405. */
  31406. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  31407. /**
  31408. * Interpolates between a and b via alpha
  31409. * @param a The lower value (returned when alpha = 0)
  31410. * @param b The upper value (returned when alpha = 1)
  31411. * @param alpha The interpolation-factor
  31412. * @return The mixed value
  31413. */
  31414. static Mix(a: number, b: number, alpha: number): number;
  31415. /**
  31416. * Tries to instantiate a new object from a given class name
  31417. * @param className defines the class name to instantiate
  31418. * @returns the new object or null if the system was not able to do the instantiation
  31419. */
  31420. static Instantiate(className: string): any;
  31421. /**
  31422. * Provides a slice function that will work even on IE
  31423. * @param data defines the array to slice
  31424. * @param start defines the start of the data (optional)
  31425. * @param end defines the end of the data (optional)
  31426. * @returns the new sliced array
  31427. */
  31428. static Slice<T>(data: T, start?: number, end?: number): T;
  31429. /**
  31430. * Polyfill for setImmediate
  31431. * @param action defines the action to execute after the current execution block
  31432. */
  31433. static SetImmediate(action: () => void): void;
  31434. /**
  31435. * Function indicating if a number is an exponent of 2
  31436. * @param value defines the value to test
  31437. * @returns true if the value is an exponent of 2
  31438. */
  31439. static IsExponentOfTwo(value: number): boolean;
  31440. private static _tmpFloatArray;
  31441. /**
  31442. * Returns the nearest 32-bit single precision float representation of a Number
  31443. * @param value A Number. If the parameter is of a different type, it will get converted
  31444. * to a number or to NaN if it cannot be converted
  31445. * @returns number
  31446. */
  31447. static FloatRound(value: number): number;
  31448. /**
  31449. * Extracts the filename from a path
  31450. * @param path defines the path to use
  31451. * @returns the filename
  31452. */
  31453. static GetFilename(path: string): string;
  31454. /**
  31455. * Extracts the "folder" part of a path (everything before the filename).
  31456. * @param uri The URI to extract the info from
  31457. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31458. * @returns The "folder" part of the path
  31459. */
  31460. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31461. /**
  31462. * Extracts text content from a DOM element hierarchy
  31463. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31464. */
  31465. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31466. /**
  31467. * Convert an angle in radians to degrees
  31468. * @param angle defines the angle to convert
  31469. * @returns the angle in degrees
  31470. */
  31471. static ToDegrees(angle: number): number;
  31472. /**
  31473. * Convert an angle in degrees to radians
  31474. * @param angle defines the angle to convert
  31475. * @returns the angle in radians
  31476. */
  31477. static ToRadians(angle: number): number;
  31478. /**
  31479. * Returns an array if obj is not an array
  31480. * @param obj defines the object to evaluate as an array
  31481. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31482. * @returns either obj directly if obj is an array or a new array containing obj
  31483. */
  31484. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31485. /**
  31486. * Gets the pointer prefix to use
  31487. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31488. */
  31489. static GetPointerPrefix(): string;
  31490. /**
  31491. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31492. * @param url define the url we are trying
  31493. * @param element define the dom element where to configure the cors policy
  31494. */
  31495. static SetCorsBehavior(url: string | string[], element: {
  31496. crossOrigin: string | null;
  31497. }): void;
  31498. /**
  31499. * Removes unwanted characters from an url
  31500. * @param url defines the url to clean
  31501. * @returns the cleaned url
  31502. */
  31503. static CleanUrl(url: string): string;
  31504. /**
  31505. * Gets or sets a function used to pre-process url before using them to load assets
  31506. */
  31507. static PreprocessUrl: (url: string) => string;
  31508. /**
  31509. * Loads an image as an HTMLImageElement.
  31510. * @param input url string, ArrayBuffer, or Blob to load
  31511. * @param onLoad callback called when the image successfully loads
  31512. * @param onError callback called when the image fails to load
  31513. * @param offlineProvider offline provider for caching
  31514. * @param mimeType optional mime type
  31515. * @returns the HTMLImageElement of the loaded image
  31516. */
  31517. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  31518. /**
  31519. * Loads a file from a url
  31520. * @param url url string, ArrayBuffer, or Blob to load
  31521. * @param onSuccess callback called when the file successfully loads
  31522. * @param onProgress callback called while file is loading (if the server supports this mode)
  31523. * @param offlineProvider defines the offline provider for caching
  31524. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31525. * @param onError callback called when the file fails to load
  31526. * @returns a file request object
  31527. */
  31528. 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;
  31529. /**
  31530. * Loads a file from a url
  31531. * @param url the file url to load
  31532. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  31533. */
  31534. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  31535. /**
  31536. * Load a script (identified by an url). When the url returns, the
  31537. * content of this file is added into a new script element, attached to the DOM (body element)
  31538. * @param scriptUrl defines the url of the script to laod
  31539. * @param onSuccess defines the callback called when the script is loaded
  31540. * @param onError defines the callback to call if an error occurs
  31541. * @param scriptId defines the id of the script element
  31542. */
  31543. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31544. /**
  31545. * Load an asynchronous script (identified by an url). When the url returns, the
  31546. * content of this file is added into a new script element, attached to the DOM (body element)
  31547. * @param scriptUrl defines the url of the script to laod
  31548. * @param scriptId defines the id of the script element
  31549. * @returns a promise request object
  31550. */
  31551. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  31552. /**
  31553. * Loads a file from a blob
  31554. * @param fileToLoad defines the blob to use
  31555. * @param callback defines the callback to call when data is loaded
  31556. * @param progressCallback defines the callback to call during loading process
  31557. * @returns a file request object
  31558. */
  31559. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31560. /**
  31561. * Reads a file from a File object
  31562. * @param file defines the file to load
  31563. * @param onSuccess defines the callback to call when data is loaded
  31564. * @param onProgress defines the callback to call during loading process
  31565. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31566. * @param onError defines the callback to call when an error occurs
  31567. * @returns a file request object
  31568. */
  31569. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  31570. /**
  31571. * Creates a data url from a given string content
  31572. * @param content defines the content to convert
  31573. * @returns the new data url link
  31574. */
  31575. static FileAsURL(content: string): string;
  31576. /**
  31577. * Format the given number to a specific decimal format
  31578. * @param value defines the number to format
  31579. * @param decimals defines the number of decimals to use
  31580. * @returns the formatted string
  31581. */
  31582. static Format(value: number, decimals?: number): string;
  31583. /**
  31584. * Tries to copy an object by duplicating every property
  31585. * @param source defines the source object
  31586. * @param destination defines the target object
  31587. * @param doNotCopyList defines a list of properties to avoid
  31588. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31589. */
  31590. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31591. /**
  31592. * Gets a boolean indicating if the given object has no own property
  31593. * @param obj defines the object to test
  31594. * @returns true if object has no own property
  31595. */
  31596. static IsEmpty(obj: any): boolean;
  31597. /**
  31598. * Function used to register events at window level
  31599. * @param windowElement defines the Window object to use
  31600. * @param events defines the events to register
  31601. */
  31602. static RegisterTopRootEvents(windowElement: Window, events: {
  31603. name: string;
  31604. handler: Nullable<(e: FocusEvent) => any>;
  31605. }[]): void;
  31606. /**
  31607. * Function used to unregister events from window level
  31608. * @param windowElement defines the Window object to use
  31609. * @param events defines the events to unregister
  31610. */
  31611. static UnregisterTopRootEvents(windowElement: Window, events: {
  31612. name: string;
  31613. handler: Nullable<(e: FocusEvent) => any>;
  31614. }[]): void;
  31615. /**
  31616. * @ignore
  31617. */ private static _ScreenshotCanvas: HTMLCanvasElement;
  31618. /**
  31619. * Dumps the current bound framebuffer
  31620. * @param width defines the rendering width
  31621. * @param height defines the rendering height
  31622. * @param engine defines the hosting engine
  31623. * @param successCallback defines the callback triggered once the data are available
  31624. * @param mimeType defines the mime type of the result
  31625. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31626. */
  31627. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31628. /**
  31629. * Converts the canvas data to blob.
  31630. * This acts as a polyfill for browsers not supporting the to blob function.
  31631. * @param canvas Defines the canvas to extract the data from
  31632. * @param successCallback Defines the callback triggered once the data are available
  31633. * @param mimeType Defines the mime type of the result
  31634. */
  31635. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31636. /**
  31637. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31638. * @param successCallback defines the callback triggered once the data are available
  31639. * @param mimeType defines the mime type of the result
  31640. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31641. */
  31642. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31643. /**
  31644. * Downloads a blob in the browser
  31645. * @param blob defines the blob to download
  31646. * @param fileName defines the name of the downloaded file
  31647. */
  31648. static Download(blob: Blob, fileName: string): void;
  31649. /**
  31650. * Captures a screenshot of the current rendering
  31651. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31652. * @param engine defines the rendering engine
  31653. * @param camera defines the source camera
  31654. * @param size This parameter can be set to a single number or to an object with the
  31655. * following (optional) properties: precision, width, height. If a single number is passed,
  31656. * it will be used for both width and height. If an object is passed, the screenshot size
  31657. * will be derived from the parameters. The precision property is a multiplier allowing
  31658. * rendering at a higher or lower resolution
  31659. * @param successCallback defines the callback receives a single parameter which contains the
  31660. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31661. * src parameter of an <img> to display it
  31662. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31663. * Check your browser for supported MIME types
  31664. */
  31665. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  31666. /**
  31667. * Captures a screenshot of the current rendering
  31668. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31669. * @param engine defines the rendering engine
  31670. * @param camera defines the source camera
  31671. * @param size This parameter can be set to a single number or to an object with the
  31672. * following (optional) properties: precision, width, height. If a single number is passed,
  31673. * it will be used for both width and height. If an object is passed, the screenshot size
  31674. * will be derived from the parameters. The precision property is a multiplier allowing
  31675. * rendering at a higher or lower resolution
  31676. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31677. * Check your browser for supported MIME types
  31678. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  31679. * to the src parameter of an <img> to display it
  31680. */
  31681. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  31682. /**
  31683. * Generates an image screenshot from the specified camera.
  31684. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31685. * @param engine The engine to use for rendering
  31686. * @param camera The camera to use for rendering
  31687. * @param size This parameter can be set to a single number or to an object with the
  31688. * following (optional) properties: precision, width, height. If a single number is passed,
  31689. * it will be used for both width and height. If an object is passed, the screenshot size
  31690. * will be derived from the parameters. The precision property is a multiplier allowing
  31691. * rendering at a higher or lower resolution
  31692. * @param successCallback The callback receives a single parameter which contains the
  31693. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31694. * src parameter of an <img> to display it
  31695. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31696. * Check your browser for supported MIME types
  31697. * @param samples Texture samples (default: 1)
  31698. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31699. * @param fileName A name for for the downloaded file.
  31700. */
  31701. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31702. /**
  31703. * Generates an image screenshot from the specified camera.
  31704. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31705. * @param engine The engine to use for rendering
  31706. * @param camera The camera to use for rendering
  31707. * @param size This parameter can be set to a single number or to an object with the
  31708. * following (optional) properties: precision, width, height. If a single number is passed,
  31709. * it will be used for both width and height. If an object is passed, the screenshot size
  31710. * will be derived from the parameters. The precision property is a multiplier allowing
  31711. * rendering at a higher or lower resolution
  31712. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31713. * Check your browser for supported MIME types
  31714. * @param samples Texture samples (default: 1)
  31715. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31716. * @param fileName A name for for the downloaded file.
  31717. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  31718. * to the src parameter of an <img> to display it
  31719. */
  31720. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  31721. /**
  31722. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31723. * Be aware Math.random() could cause collisions, but:
  31724. * "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"
  31725. * @returns a pseudo random id
  31726. */
  31727. static RandomId(): string;
  31728. /**
  31729. * Test if the given uri is a base64 string
  31730. * @param uri The uri to test
  31731. * @return True if the uri is a base64 string or false otherwise
  31732. */
  31733. static IsBase64(uri: string): boolean;
  31734. /**
  31735. * Decode the given base64 uri.
  31736. * @param uri The uri to decode
  31737. * @return The decoded base64 data.
  31738. */
  31739. static DecodeBase64(uri: string): ArrayBuffer;
  31740. /**
  31741. * Gets the absolute url.
  31742. * @param url the input url
  31743. * @return the absolute url
  31744. */
  31745. static GetAbsoluteUrl(url: string): string;
  31746. /**
  31747. * No log
  31748. */
  31749. static readonly NoneLogLevel: number;
  31750. /**
  31751. * Only message logs
  31752. */
  31753. static readonly MessageLogLevel: number;
  31754. /**
  31755. * Only warning logs
  31756. */
  31757. static readonly WarningLogLevel: number;
  31758. /**
  31759. * Only error logs
  31760. */
  31761. static readonly ErrorLogLevel: number;
  31762. /**
  31763. * All logs
  31764. */
  31765. static readonly AllLogLevel: number;
  31766. /**
  31767. * Gets a value indicating the number of loading errors
  31768. * @ignorenaming
  31769. */
  31770. static readonly errorsCount: number;
  31771. /**
  31772. * Callback called when a new log is added
  31773. */
  31774. static OnNewCacheEntry: (entry: string) => void;
  31775. /**
  31776. * Log a message to the console
  31777. * @param message defines the message to log
  31778. */
  31779. static Log(message: string): void;
  31780. /**
  31781. * Write a warning message to the console
  31782. * @param message defines the message to log
  31783. */
  31784. static Warn(message: string): void;
  31785. /**
  31786. * Write an error message to the console
  31787. * @param message defines the message to log
  31788. */
  31789. static Error(message: string): void;
  31790. /**
  31791. * Gets current log cache (list of logs)
  31792. */
  31793. static readonly LogCache: string;
  31794. /**
  31795. * Clears the log cache
  31796. */
  31797. static ClearLogCache(): void;
  31798. /**
  31799. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31800. */
  31801. static LogLevels: number;
  31802. /**
  31803. * Checks if the window object exists
  31804. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31805. */
  31806. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31807. /**
  31808. * No performance log
  31809. */
  31810. static readonly PerformanceNoneLogLevel: number;
  31811. /**
  31812. * Use user marks to log performance
  31813. */
  31814. static readonly PerformanceUserMarkLogLevel: number;
  31815. /**
  31816. * Log performance to the console
  31817. */
  31818. static readonly PerformanceConsoleLogLevel: number;
  31819. private static _performance;
  31820. /**
  31821. * Sets the current performance log level
  31822. */
  31823. static PerformanceLogLevel: number;
  31824. private static _StartPerformanceCounterDisabled;
  31825. private static _EndPerformanceCounterDisabled;
  31826. private static _StartUserMark;
  31827. private static _EndUserMark;
  31828. private static _StartPerformanceConsole;
  31829. private static _EndPerformanceConsole;
  31830. /**
  31831. * Starts a performance counter
  31832. */
  31833. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31834. /**
  31835. * Ends a specific performance coutner
  31836. */
  31837. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31838. /**
  31839. * Gets either window.performance.now() if supported or Date.now() else
  31840. */
  31841. static readonly Now: number;
  31842. /**
  31843. * This method will return the name of the class used to create the instance of the given object.
  31844. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31845. * @param object the object to get the class name from
  31846. * @param isType defines if the object is actually a type
  31847. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31848. */
  31849. static GetClassName(object: any, isType?: boolean): string;
  31850. /**
  31851. * Gets the first element of an array satisfying a given predicate
  31852. * @param array defines the array to browse
  31853. * @param predicate defines the predicate to use
  31854. * @returns null if not found or the element
  31855. */
  31856. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31857. /**
  31858. * This method will return the name of the full name of the class, including its owning module (if any).
  31859. * 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).
  31860. * @param object the object to get the class name from
  31861. * @param isType defines if the object is actually a type
  31862. * @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.
  31863. * @ignorenaming
  31864. */
  31865. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31866. /**
  31867. * Returns a promise that resolves after the given amount of time.
  31868. * @param delay Number of milliseconds to delay
  31869. * @returns Promise that resolves after the given amount of time
  31870. */
  31871. static DelayAsync(delay: number): Promise<void>;
  31872. }
  31873. /**
  31874. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31875. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31876. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31877. * @param name The name of the class, case should be preserved
  31878. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31879. */
  31880. export function className(name: string, module?: string): (target: Object) => void;
  31881. /**
  31882. * An implementation of a loop for asynchronous functions.
  31883. */
  31884. export class AsyncLoop {
  31885. /**
  31886. * Defines the number of iterations for the loop
  31887. */
  31888. iterations: number;
  31889. /**
  31890. * Defines the current index of the loop.
  31891. */
  31892. index: number;
  31893. private _done;
  31894. private _fn;
  31895. private _successCallback;
  31896. /**
  31897. * Constructor.
  31898. * @param iterations the number of iterations.
  31899. * @param func the function to run each iteration
  31900. * @param successCallback the callback that will be called upon succesful execution
  31901. * @param offset starting offset.
  31902. */
  31903. constructor(
  31904. /**
  31905. * Defines the number of iterations for the loop
  31906. */
  31907. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31908. /**
  31909. * Execute the next iteration. Must be called after the last iteration was finished.
  31910. */
  31911. executeNext(): void;
  31912. /**
  31913. * Break the loop and run the success callback.
  31914. */
  31915. breakLoop(): void;
  31916. /**
  31917. * Create and run an async loop.
  31918. * @param iterations the number of iterations.
  31919. * @param fn the function to run each iteration
  31920. * @param successCallback the callback that will be called upon succesful execution
  31921. * @param offset starting offset.
  31922. * @returns the created async loop object
  31923. */
  31924. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31925. /**
  31926. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31927. * @param iterations total number of iterations
  31928. * @param syncedIterations number of synchronous iterations in each async iteration.
  31929. * @param fn the function to call each iteration.
  31930. * @param callback a success call back that will be called when iterating stops.
  31931. * @param breakFunction a break condition (optional)
  31932. * @param timeout timeout settings for the setTimeout function. default - 0.
  31933. * @returns the created async loop object
  31934. */
  31935. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31936. }
  31937. }
  31938. declare module BABYLON {
  31939. /**
  31940. * This class implement a typical dictionary using a string as key and the generic type T as value.
  31941. * The underlying implementation relies on an associative array to ensure the best performances.
  31942. * The value can be anything including 'null' but except 'undefined'
  31943. */
  31944. export class StringDictionary<T> {
  31945. /**
  31946. * This will clear this dictionary and copy the content from the 'source' one.
  31947. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  31948. * @param source the dictionary to take the content from and copy to this dictionary
  31949. */
  31950. copyFrom(source: StringDictionary<T>): void;
  31951. /**
  31952. * Get a value based from its key
  31953. * @param key the given key to get the matching value from
  31954. * @return the value if found, otherwise undefined is returned
  31955. */
  31956. get(key: string): T | undefined;
  31957. /**
  31958. * Get a value from its key or add it if it doesn't exist.
  31959. * This method will ensure you that a given key/data will be present in the dictionary.
  31960. * @param key the given key to get the matching value from
  31961. * @param factory the factory that will create the value if the key is not present in the dictionary.
  31962. * The factory will only be invoked if there's no data for the given key.
  31963. * @return the value corresponding to the key.
  31964. */
  31965. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  31966. /**
  31967. * Get a value from its key if present in the dictionary otherwise add it
  31968. * @param key the key to get the value from
  31969. * @param val if there's no such key/value pair in the dictionary add it with this value
  31970. * @return the value corresponding to the key
  31971. */
  31972. getOrAdd(key: string, val: T): T;
  31973. /**
  31974. * Check if there's a given key in the dictionary
  31975. * @param key the key to check for
  31976. * @return true if the key is present, false otherwise
  31977. */
  31978. contains(key: string): boolean;
  31979. /**
  31980. * Add a new key and its corresponding value
  31981. * @param key the key to add
  31982. * @param value the value corresponding to the key
  31983. * @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
  31984. */
  31985. add(key: string, value: T): boolean;
  31986. /**
  31987. * Update a specific value associated to a key
  31988. * @param key defines the key to use
  31989. * @param value defines the value to store
  31990. * @returns true if the value was updated (or false if the key was not found)
  31991. */
  31992. set(key: string, value: T): boolean;
  31993. /**
  31994. * Get the element of the given key and remove it from the dictionary
  31995. * @param key defines the key to search
  31996. * @returns the value associated with the key or null if not found
  31997. */
  31998. getAndRemove(key: string): Nullable<T>;
  31999. /**
  32000. * Remove a key/value from the dictionary.
  32001. * @param key the key to remove
  32002. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  32003. */
  32004. remove(key: string): boolean;
  32005. /**
  32006. * Clear the whole content of the dictionary
  32007. */
  32008. clear(): void;
  32009. /**
  32010. * Gets the current count
  32011. */
  32012. readonly count: number;
  32013. /**
  32014. * Execute a callback on each key/val of the dictionary.
  32015. * Note that you can remove any element in this dictionary in the callback implementation
  32016. * @param callback the callback to execute on a given key/value pair
  32017. */
  32018. forEach(callback: (key: string, val: T) => void): void;
  32019. /**
  32020. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  32021. * If the callback returns null or undefined the method will iterate to the next key/value pair
  32022. * Note that you can remove any element in this dictionary in the callback implementation
  32023. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  32024. * @returns the first item
  32025. */
  32026. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  32027. private _count;
  32028. private _data;
  32029. }
  32030. }
  32031. declare module BABYLON {
  32032. /** @hidden */
  32033. export interface ICollisionCoordinator {
  32034. createCollider(): Collider;
  32035. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32036. init(scene: Scene): void;
  32037. }
  32038. /** @hidden */
  32039. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32040. private _scene;
  32041. private _scaledPosition;
  32042. private _scaledVelocity;
  32043. private _finalPosition;
  32044. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32045. createCollider(): Collider;
  32046. init(scene: Scene): void;
  32047. private _collideWithWorld;
  32048. }
  32049. }
  32050. declare module BABYLON {
  32051. /**
  32052. * Class used to manage all inputs for the scene.
  32053. */
  32054. export class InputManager {
  32055. /** The distance in pixel that you have to move to prevent some events */
  32056. static DragMovementThreshold: number;
  32057. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32058. static LongPressDelay: number;
  32059. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32060. static DoubleClickDelay: number;
  32061. /** If you need to check double click without raising a single click at first click, enable this flag */
  32062. static ExclusiveDoubleClickMode: boolean;
  32063. private _wheelEventName;
  32064. private _onPointerMove;
  32065. private _onPointerDown;
  32066. private _onPointerUp;
  32067. private _initClickEvent;
  32068. private _initActionManager;
  32069. private _delayedSimpleClick;
  32070. private _delayedSimpleClickTimeout;
  32071. private _previousDelayedSimpleClickTimeout;
  32072. private _meshPickProceed;
  32073. private _previousButtonPressed;
  32074. private _currentPickResult;
  32075. private _previousPickResult;
  32076. private _totalPointersPressed;
  32077. private _doubleClickOccured;
  32078. private _pointerOverMesh;
  32079. private _pickedDownMesh;
  32080. private _pickedUpMesh;
  32081. private _pointerX;
  32082. private _pointerY;
  32083. private _unTranslatedPointerX;
  32084. private _unTranslatedPointerY;
  32085. private _startingPointerPosition;
  32086. private _previousStartingPointerPosition;
  32087. private _startingPointerTime;
  32088. private _previousStartingPointerTime;
  32089. private _pointerCaptures;
  32090. private _onKeyDown;
  32091. private _onKeyUp;
  32092. private _onCanvasFocusObserver;
  32093. private _onCanvasBlurObserver;
  32094. private _scene;
  32095. /**
  32096. * Creates a new InputManager
  32097. * @param scene defines the hosting scene
  32098. */
  32099. constructor(scene: Scene);
  32100. /**
  32101. * Gets the mesh that is currently under the pointer
  32102. */
  32103. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32104. /**
  32105. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32106. */
  32107. readonly unTranslatedPointer: Vector2;
  32108. /**
  32109. * Gets or sets the current on-screen X position of the pointer
  32110. */
  32111. pointerX: number;
  32112. /**
  32113. * Gets or sets the current on-screen Y position of the pointer
  32114. */
  32115. pointerY: number;
  32116. private _updatePointerPosition;
  32117. private _processPointerMove;
  32118. private _setRayOnPointerInfo;
  32119. private _checkPrePointerObservable;
  32120. /**
  32121. * Use this method to simulate a pointer move on a mesh
  32122. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32123. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32124. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32125. */
  32126. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32127. /**
  32128. * Use this method to simulate a pointer down on a mesh
  32129. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32130. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32131. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32132. */
  32133. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32134. private _processPointerDown;
  32135. /** @hidden */ private _isPointerSwiping(): boolean;
  32136. /**
  32137. * Use this method to simulate a pointer up on a mesh
  32138. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32139. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32140. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32141. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32142. */
  32143. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32144. private _processPointerUp;
  32145. /**
  32146. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32147. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32148. * @returns true if the pointer was captured
  32149. */
  32150. isPointerCaptured(pointerId?: number): boolean;
  32151. /**
  32152. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32153. * @param attachUp defines if you want to attach events to pointerup
  32154. * @param attachDown defines if you want to attach events to pointerdown
  32155. * @param attachMove defines if you want to attach events to pointermove
  32156. */
  32157. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32158. /**
  32159. * Detaches all event handlers
  32160. */
  32161. detachControl(): void;
  32162. /**
  32163. * Force the value of meshUnderPointer
  32164. * @param mesh defines the mesh to use
  32165. */
  32166. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32167. /**
  32168. * Gets the mesh under the pointer
  32169. * @returns a Mesh or null if no mesh is under the pointer
  32170. */
  32171. getPointerOverMesh(): Nullable<AbstractMesh>;
  32172. }
  32173. }
  32174. declare module BABYLON {
  32175. /**
  32176. * Helper class used to generate session unique ID
  32177. */
  32178. export class UniqueIdGenerator {
  32179. private static _UniqueIdCounter;
  32180. /**
  32181. * Gets an unique (relatively to the current scene) Id
  32182. */
  32183. static readonly UniqueId: number;
  32184. }
  32185. }
  32186. declare module BABYLON {
  32187. /**
  32188. * This class defines the direct association between an animation and a target
  32189. */
  32190. export class TargetedAnimation {
  32191. /**
  32192. * Animation to perform
  32193. */
  32194. animation: Animation;
  32195. /**
  32196. * Target to animate
  32197. */
  32198. target: any;
  32199. /**
  32200. * Serialize the object
  32201. * @returns the JSON object representing the current entity
  32202. */
  32203. serialize(): any;
  32204. }
  32205. /**
  32206. * Use this class to create coordinated animations on multiple targets
  32207. */
  32208. export class AnimationGroup implements IDisposable {
  32209. /** The name of the animation group */
  32210. name: string;
  32211. private _scene;
  32212. private _targetedAnimations;
  32213. private _animatables;
  32214. private _from;
  32215. private _to;
  32216. private _isStarted;
  32217. private _isPaused;
  32218. private _speedRatio;
  32219. private _loopAnimation;
  32220. /**
  32221. * Gets or sets the unique id of the node
  32222. */
  32223. uniqueId: number;
  32224. /**
  32225. * This observable will notify when one animation have ended
  32226. */
  32227. onAnimationEndObservable: Observable<TargetedAnimation>;
  32228. /**
  32229. * Observer raised when one animation loops
  32230. */
  32231. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32232. /**
  32233. * This observable will notify when all animations have ended.
  32234. */
  32235. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32236. /**
  32237. * This observable will notify when all animations have paused.
  32238. */
  32239. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32240. /**
  32241. * This observable will notify when all animations are playing.
  32242. */
  32243. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32244. /**
  32245. * Gets the first frame
  32246. */
  32247. readonly from: number;
  32248. /**
  32249. * Gets the last frame
  32250. */
  32251. readonly to: number;
  32252. /**
  32253. * Define if the animations are started
  32254. */
  32255. readonly isStarted: boolean;
  32256. /**
  32257. * Gets a value indicating that the current group is playing
  32258. */
  32259. readonly isPlaying: boolean;
  32260. /**
  32261. * Gets or sets the speed ratio to use for all animations
  32262. */
  32263. /**
  32264. * Gets or sets the speed ratio to use for all animations
  32265. */
  32266. speedRatio: number;
  32267. /**
  32268. * Gets or sets if all animations should loop or not
  32269. */
  32270. loopAnimation: boolean;
  32271. /**
  32272. * Gets the targeted animations for this animation group
  32273. */
  32274. readonly targetedAnimations: Array<TargetedAnimation>;
  32275. /**
  32276. * returning the list of animatables controlled by this animation group.
  32277. */
  32278. readonly animatables: Array<Animatable>;
  32279. /**
  32280. * Instantiates a new Animation Group.
  32281. * This helps managing several animations at once.
  32282. * @see http://doc.babylonjs.com/how_to/group
  32283. * @param name Defines the name of the group
  32284. * @param scene Defines the scene the group belongs to
  32285. */
  32286. constructor(
  32287. /** The name of the animation group */
  32288. name: string, scene?: Nullable<Scene>);
  32289. /**
  32290. * Add an animation (with its target) in the group
  32291. * @param animation defines the animation we want to add
  32292. * @param target defines the target of the animation
  32293. * @returns the TargetedAnimation object
  32294. */
  32295. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32296. /**
  32297. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32298. * It can add constant keys at begin or end
  32299. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32300. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32301. * @returns the animation group
  32302. */
  32303. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32304. /**
  32305. * Start all animations on given targets
  32306. * @param loop defines if animations must loop
  32307. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32308. * @param from defines the from key (optional)
  32309. * @param to defines the to key (optional)
  32310. * @returns the current animation group
  32311. */
  32312. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32313. /**
  32314. * Pause all animations
  32315. * @returns the animation group
  32316. */
  32317. pause(): AnimationGroup;
  32318. /**
  32319. * Play all animations to initial state
  32320. * This function will start() the animations if they were not started or will restart() them if they were paused
  32321. * @param loop defines if animations must loop
  32322. * @returns the animation group
  32323. */
  32324. play(loop?: boolean): AnimationGroup;
  32325. /**
  32326. * Reset all animations to initial state
  32327. * @returns the animation group
  32328. */
  32329. reset(): AnimationGroup;
  32330. /**
  32331. * Restart animations from key 0
  32332. * @returns the animation group
  32333. */
  32334. restart(): AnimationGroup;
  32335. /**
  32336. * Stop all animations
  32337. * @returns the animation group
  32338. */
  32339. stop(): AnimationGroup;
  32340. /**
  32341. * Set animation weight for all animatables
  32342. * @param weight defines the weight to use
  32343. * @return the animationGroup
  32344. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32345. */
  32346. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32347. /**
  32348. * Synchronize and normalize all animatables with a source animatable
  32349. * @param root defines the root animatable to synchronize with
  32350. * @return the animationGroup
  32351. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32352. */
  32353. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32354. /**
  32355. * Goes to a specific frame in this animation group
  32356. * @param frame the frame number to go to
  32357. * @return the animationGroup
  32358. */
  32359. goToFrame(frame: number): AnimationGroup;
  32360. /**
  32361. * Dispose all associated resources
  32362. */
  32363. dispose(): void;
  32364. private _checkAnimationGroupEnded;
  32365. /**
  32366. * Clone the current animation group and returns a copy
  32367. * @param newName defines the name of the new group
  32368. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32369. * @returns the new aniamtion group
  32370. */
  32371. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32372. /**
  32373. * Serializes the animationGroup to an object
  32374. * @returns Serialized object
  32375. */
  32376. serialize(): any;
  32377. /**
  32378. * Returns a new AnimationGroup object parsed from the source provided.
  32379. * @param parsedAnimationGroup defines the source
  32380. * @param scene defines the scene that will receive the animationGroup
  32381. * @returns a new AnimationGroup
  32382. */
  32383. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32384. /**
  32385. * Returns the string "AnimationGroup"
  32386. * @returns "AnimationGroup"
  32387. */
  32388. getClassName(): string;
  32389. /**
  32390. * Creates a detailled string about the object
  32391. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32392. * @returns a string representing the object
  32393. */
  32394. toString(fullDetails?: boolean): string;
  32395. }
  32396. }
  32397. declare module BABYLON {
  32398. /**
  32399. * Define an interface for all classes that will hold resources
  32400. */
  32401. export interface IDisposable {
  32402. /**
  32403. * Releases all held resources
  32404. */
  32405. dispose(): void;
  32406. }
  32407. /** Interface defining initialization parameters for Scene class */
  32408. export interface SceneOptions {
  32409. /**
  32410. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32411. * It will improve performance when the number of geometries becomes important.
  32412. */
  32413. useGeometryUniqueIdsMap?: boolean;
  32414. /**
  32415. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32416. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32417. */
  32418. useMaterialMeshMap?: boolean;
  32419. /**
  32420. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32421. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32422. */
  32423. useClonedMeshhMap?: boolean;
  32424. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32425. virtual?: boolean;
  32426. }
  32427. /**
  32428. * Represents a scene to be rendered by the engine.
  32429. * @see http://doc.babylonjs.com/features/scene
  32430. */
  32431. export class Scene extends AbstractScene implements IAnimatable {
  32432. /** The fog is deactivated */
  32433. static readonly FOGMODE_NONE: number;
  32434. /** The fog density is following an exponential function */
  32435. static readonly FOGMODE_EXP: number;
  32436. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32437. static readonly FOGMODE_EXP2: number;
  32438. /** The fog density is following a linear function. */
  32439. static readonly FOGMODE_LINEAR: number;
  32440. /**
  32441. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32442. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32443. */
  32444. static MinDeltaTime: number;
  32445. /**
  32446. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32447. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32448. */
  32449. static MaxDeltaTime: number;
  32450. /**
  32451. * Factory used to create the default material.
  32452. * @param name The name of the material to create
  32453. * @param scene The scene to create the material for
  32454. * @returns The default material
  32455. */
  32456. static DefaultMaterialFactory(scene: Scene): Material;
  32457. /**
  32458. * Factory used to create the a collision coordinator.
  32459. * @returns The collision coordinator
  32460. */
  32461. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32462. /** @hidden */ private _inputManager: InputManager;
  32463. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32464. cameraToUseForPointers: Nullable<Camera>;
  32465. /** @hidden */ protected readonly _isScene: boolean;
  32466. /**
  32467. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32468. */
  32469. autoClear: boolean;
  32470. /**
  32471. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32472. */
  32473. autoClearDepthAndStencil: boolean;
  32474. /**
  32475. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32476. */
  32477. clearColor: Color4;
  32478. /**
  32479. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32480. */
  32481. ambientColor: Color3;
  32482. /**
  32483. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32484. * It should only be one of the following (if not the default embedded one):
  32485. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32486. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32487. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32488. * The material properties need to be setup according to the type of texture in use.
  32489. */
  32490. environmentBRDFTexture: BaseTexture;
  32491. /** @hidden */
  32492. protected _environmentTexture: Nullable<BaseTexture>;
  32493. /**
  32494. * Texture used in all pbr material as the reflection texture.
  32495. * As in the majority of the scene they are the same (exception for multi room and so on),
  32496. * this is easier to reference from here than from all the materials.
  32497. */
  32498. /**
  32499. * Texture used in all pbr material as the reflection texture.
  32500. * As in the majority of the scene they are the same (exception for multi room and so on),
  32501. * this is easier to set here than in all the materials.
  32502. */
  32503. environmentTexture: Nullable<BaseTexture>;
  32504. /** @hidden */
  32505. protected _environmentIntensity: number;
  32506. /**
  32507. * Intensity of the environment in all pbr material.
  32508. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32509. * As in the majority of the scene they are the same (exception for multi room and so on),
  32510. * this is easier to reference from here than from all the materials.
  32511. */
  32512. /**
  32513. * Intensity of the environment in all pbr material.
  32514. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32515. * As in the majority of the scene they are the same (exception for multi room and so on),
  32516. * this is easier to set here than in all the materials.
  32517. */
  32518. environmentIntensity: number;
  32519. /** @hidden */
  32520. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32521. /**
  32522. * Default image processing configuration used either in the rendering
  32523. * Forward main pass or through the imageProcessingPostProcess if present.
  32524. * As in the majority of the scene they are the same (exception for multi camera),
  32525. * this is easier to reference from here than from all the materials and post process.
  32526. *
  32527. * No setter as we it is a shared configuration, you can set the values instead.
  32528. */
  32529. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32530. private _forceWireframe;
  32531. /**
  32532. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32533. */
  32534. forceWireframe: boolean;
  32535. private _forcePointsCloud;
  32536. /**
  32537. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32538. */
  32539. forcePointsCloud: boolean;
  32540. /**
  32541. * Gets or sets the active clipplane 1
  32542. */
  32543. clipPlane: Nullable<Plane>;
  32544. /**
  32545. * Gets or sets the active clipplane 2
  32546. */
  32547. clipPlane2: Nullable<Plane>;
  32548. /**
  32549. * Gets or sets the active clipplane 3
  32550. */
  32551. clipPlane3: Nullable<Plane>;
  32552. /**
  32553. * Gets or sets the active clipplane 4
  32554. */
  32555. clipPlane4: Nullable<Plane>;
  32556. /**
  32557. * Gets or sets a boolean indicating if animations are enabled
  32558. */
  32559. animationsEnabled: boolean;
  32560. private _animationPropertiesOverride;
  32561. /**
  32562. * Gets or sets the animation properties override
  32563. */
  32564. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32565. /**
  32566. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32567. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32568. */
  32569. useConstantAnimationDeltaTime: boolean;
  32570. /**
  32571. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32572. * Please note that it requires to run a ray cast through the scene on every frame
  32573. */
  32574. constantlyUpdateMeshUnderPointer: boolean;
  32575. /**
  32576. * Defines the HTML cursor to use when hovering over interactive elements
  32577. */
  32578. hoverCursor: string;
  32579. /**
  32580. * Defines the HTML default cursor to use (empty by default)
  32581. */
  32582. defaultCursor: string;
  32583. /**
  32584. * Defines wether cursors are handled by the scene.
  32585. */
  32586. doNotHandleCursors: boolean;
  32587. /**
  32588. * This is used to call preventDefault() on pointer down
  32589. * in order to block unwanted artifacts like system double clicks
  32590. */
  32591. preventDefaultOnPointerDown: boolean;
  32592. /**
  32593. * This is used to call preventDefault() on pointer up
  32594. * in order to block unwanted artifacts like system double clicks
  32595. */
  32596. preventDefaultOnPointerUp: boolean;
  32597. /**
  32598. * Gets or sets user defined metadata
  32599. */
  32600. metadata: any;
  32601. /**
  32602. * For internal use only. Please do not use.
  32603. */
  32604. reservedDataStore: any;
  32605. /**
  32606. * Gets the name of the plugin used to load this scene (null by default)
  32607. */
  32608. loadingPluginName: string;
  32609. /**
  32610. * Use this array to add regular expressions used to disable offline support for specific urls
  32611. */
  32612. disableOfflineSupportExceptionRules: RegExp[];
  32613. /**
  32614. * An event triggered when the scene is disposed.
  32615. */
  32616. onDisposeObservable: Observable<Scene>;
  32617. private _onDisposeObserver;
  32618. /** Sets a function to be executed when this scene is disposed. */
  32619. onDispose: () => void;
  32620. /**
  32621. * An event triggered before rendering the scene (right after animations and physics)
  32622. */
  32623. onBeforeRenderObservable: Observable<Scene>;
  32624. private _onBeforeRenderObserver;
  32625. /** Sets a function to be executed before rendering this scene */
  32626. beforeRender: Nullable<() => void>;
  32627. /**
  32628. * An event triggered after rendering the scene
  32629. */
  32630. onAfterRenderObservable: Observable<Scene>;
  32631. /**
  32632. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  32633. */
  32634. onAfterRenderCameraObservable: Observable<Camera>;
  32635. private _onAfterRenderObserver;
  32636. /** Sets a function to be executed after rendering this scene */
  32637. afterRender: Nullable<() => void>;
  32638. /**
  32639. * An event triggered before animating the scene
  32640. */
  32641. onBeforeAnimationsObservable: Observable<Scene>;
  32642. /**
  32643. * An event triggered after animations processing
  32644. */
  32645. onAfterAnimationsObservable: Observable<Scene>;
  32646. /**
  32647. * An event triggered before draw calls are ready to be sent
  32648. */
  32649. onBeforeDrawPhaseObservable: Observable<Scene>;
  32650. /**
  32651. * An event triggered after draw calls have been sent
  32652. */
  32653. onAfterDrawPhaseObservable: Observable<Scene>;
  32654. /**
  32655. * An event triggered when the scene is ready
  32656. */
  32657. onReadyObservable: Observable<Scene>;
  32658. /**
  32659. * An event triggered before rendering a camera
  32660. */
  32661. onBeforeCameraRenderObservable: Observable<Camera>;
  32662. private _onBeforeCameraRenderObserver;
  32663. /** Sets a function to be executed before rendering a camera*/
  32664. beforeCameraRender: () => void;
  32665. /**
  32666. * An event triggered after rendering a camera
  32667. */
  32668. onAfterCameraRenderObservable: Observable<Camera>;
  32669. private _onAfterCameraRenderObserver;
  32670. /** Sets a function to be executed after rendering a camera*/
  32671. afterCameraRender: () => void;
  32672. /**
  32673. * An event triggered when active meshes evaluation is about to start
  32674. */
  32675. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32676. /**
  32677. * An event triggered when active meshes evaluation is done
  32678. */
  32679. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32680. /**
  32681. * An event triggered when particles rendering is about to start
  32682. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32683. */
  32684. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32685. /**
  32686. * An event triggered when particles rendering is done
  32687. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32688. */
  32689. onAfterParticlesRenderingObservable: Observable<Scene>;
  32690. /**
  32691. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32692. */
  32693. onDataLoadedObservable: Observable<Scene>;
  32694. /**
  32695. * An event triggered when a camera is created
  32696. */
  32697. onNewCameraAddedObservable: Observable<Camera>;
  32698. /**
  32699. * An event triggered when a camera is removed
  32700. */
  32701. onCameraRemovedObservable: Observable<Camera>;
  32702. /**
  32703. * An event triggered when a light is created
  32704. */
  32705. onNewLightAddedObservable: Observable<Light>;
  32706. /**
  32707. * An event triggered when a light is removed
  32708. */
  32709. onLightRemovedObservable: Observable<Light>;
  32710. /**
  32711. * An event triggered when a geometry is created
  32712. */
  32713. onNewGeometryAddedObservable: Observable<Geometry>;
  32714. /**
  32715. * An event triggered when a geometry is removed
  32716. */
  32717. onGeometryRemovedObservable: Observable<Geometry>;
  32718. /**
  32719. * An event triggered when a transform node is created
  32720. */
  32721. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32722. /**
  32723. * An event triggered when a transform node is removed
  32724. */
  32725. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32726. /**
  32727. * An event triggered when a mesh is created
  32728. */
  32729. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32730. /**
  32731. * An event triggered when a mesh is removed
  32732. */
  32733. onMeshRemovedObservable: Observable<AbstractMesh>;
  32734. /**
  32735. * An event triggered when a skeleton is created
  32736. */
  32737. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32738. /**
  32739. * An event triggered when a skeleton is removed
  32740. */
  32741. onSkeletonRemovedObservable: Observable<Skeleton>;
  32742. /**
  32743. * An event triggered when a material is created
  32744. */
  32745. onNewMaterialAddedObservable: Observable<Material>;
  32746. /**
  32747. * An event triggered when a material is removed
  32748. */
  32749. onMaterialRemovedObservable: Observable<Material>;
  32750. /**
  32751. * An event triggered when a texture is created
  32752. */
  32753. onNewTextureAddedObservable: Observable<BaseTexture>;
  32754. /**
  32755. * An event triggered when a texture is removed
  32756. */
  32757. onTextureRemovedObservable: Observable<BaseTexture>;
  32758. /**
  32759. * An event triggered when render targets are about to be rendered
  32760. * Can happen multiple times per frame.
  32761. */
  32762. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32763. /**
  32764. * An event triggered when render targets were rendered.
  32765. * Can happen multiple times per frame.
  32766. */
  32767. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32768. /**
  32769. * An event triggered before calculating deterministic simulation step
  32770. */
  32771. onBeforeStepObservable: Observable<Scene>;
  32772. /**
  32773. * An event triggered after calculating deterministic simulation step
  32774. */
  32775. onAfterStepObservable: Observable<Scene>;
  32776. /**
  32777. * An event triggered when the activeCamera property is updated
  32778. */
  32779. onActiveCameraChanged: Observable<Scene>;
  32780. /**
  32781. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32782. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32783. * 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)
  32784. */
  32785. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32786. /**
  32787. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32788. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32789. * 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)
  32790. */
  32791. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32792. /**
  32793. * This Observable will when a mesh has been imported into the scene.
  32794. */
  32795. onMeshImportedObservable: Observable<AbstractMesh>;
  32796. /**
  32797. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32798. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32799. */
  32800. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32801. /** @hidden */ private _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32802. /**
  32803. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32804. */
  32805. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32806. /**
  32807. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32808. */
  32809. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32810. /**
  32811. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32812. */
  32813. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32814. /** Callback called when a pointer move is detected */
  32815. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32816. /** Callback called when a pointer down is detected */
  32817. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32818. /** Callback called when a pointer up is detected */
  32819. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32820. /** Callback called when a pointer pick is detected */
  32821. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32822. /**
  32823. * 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).
  32824. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32825. */
  32826. onPrePointerObservable: Observable<PointerInfoPre>;
  32827. /**
  32828. * Observable event triggered each time an input event is received from the rendering canvas
  32829. */
  32830. onPointerObservable: Observable<PointerInfo>;
  32831. /**
  32832. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32833. */
  32834. readonly unTranslatedPointer: Vector2;
  32835. /**
  32836. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  32837. */
  32838. static DragMovementThreshold: number;
  32839. /**
  32840. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  32841. */
  32842. static LongPressDelay: number;
  32843. /**
  32844. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  32845. */
  32846. static DoubleClickDelay: number;
  32847. /** If you need to check double click without raising a single click at first click, enable this flag */
  32848. static ExclusiveDoubleClickMode: boolean;
  32849. /** @hidden */ private _mirroredCameraPosition: Nullable<Vector3>;
  32850. /**
  32851. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32852. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32853. */
  32854. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32855. /**
  32856. * Observable event triggered each time an keyboard event is received from the hosting window
  32857. */
  32858. onKeyboardObservable: Observable<KeyboardInfo>;
  32859. private _useRightHandedSystem;
  32860. /**
  32861. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32862. */
  32863. useRightHandedSystem: boolean;
  32864. private _timeAccumulator;
  32865. private _currentStepId;
  32866. private _currentInternalStep;
  32867. /**
  32868. * Sets the step Id used by deterministic lock step
  32869. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32870. * @param newStepId defines the step Id
  32871. */
  32872. setStepId(newStepId: number): void;
  32873. /**
  32874. * Gets the step Id used by deterministic lock step
  32875. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32876. * @returns the step Id
  32877. */
  32878. getStepId(): number;
  32879. /**
  32880. * Gets the internal step used by deterministic lock step
  32881. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32882. * @returns the internal step
  32883. */
  32884. getInternalStep(): number;
  32885. private _fogEnabled;
  32886. /**
  32887. * Gets or sets a boolean indicating if fog is enabled on this scene
  32888. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32889. * (Default is true)
  32890. */
  32891. fogEnabled: boolean;
  32892. private _fogMode;
  32893. /**
  32894. * Gets or sets the fog mode to use
  32895. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32896. * | mode | value |
  32897. * | --- | --- |
  32898. * | FOGMODE_NONE | 0 |
  32899. * | FOGMODE_EXP | 1 |
  32900. * | FOGMODE_EXP2 | 2 |
  32901. * | FOGMODE_LINEAR | 3 |
  32902. */
  32903. fogMode: number;
  32904. /**
  32905. * Gets or sets the fog color to use
  32906. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32907. * (Default is Color3(0.2, 0.2, 0.3))
  32908. */
  32909. fogColor: Color3;
  32910. /**
  32911. * Gets or sets the fog density to use
  32912. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32913. * (Default is 0.1)
  32914. */
  32915. fogDensity: number;
  32916. /**
  32917. * Gets or sets the fog start distance to use
  32918. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32919. * (Default is 0)
  32920. */
  32921. fogStart: number;
  32922. /**
  32923. * Gets or sets the fog end distance to use
  32924. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32925. * (Default is 1000)
  32926. */
  32927. fogEnd: number;
  32928. private _shadowsEnabled;
  32929. /**
  32930. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32931. */
  32932. shadowsEnabled: boolean;
  32933. private _lightsEnabled;
  32934. /**
  32935. * Gets or sets a boolean indicating if lights are enabled on this scene
  32936. */
  32937. lightsEnabled: boolean;
  32938. /** All of the active cameras added to this scene. */
  32939. activeCameras: Camera[];
  32940. /** @hidden */ private _activeCamera: Nullable<Camera>;
  32941. /** Gets or sets the current active camera */
  32942. activeCamera: Nullable<Camera>;
  32943. private _defaultMaterial;
  32944. /** The default material used on meshes when no material is affected */
  32945. /** The default material used on meshes when no material is affected */
  32946. defaultMaterial: Material;
  32947. private _texturesEnabled;
  32948. /**
  32949. * Gets or sets a boolean indicating if textures are enabled on this scene
  32950. */
  32951. texturesEnabled: boolean;
  32952. /**
  32953. * Gets or sets a boolean indicating if particles are enabled on this scene
  32954. */
  32955. particlesEnabled: boolean;
  32956. /**
  32957. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32958. */
  32959. spritesEnabled: boolean;
  32960. private _skeletonsEnabled;
  32961. /**
  32962. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32963. */
  32964. skeletonsEnabled: boolean;
  32965. /**
  32966. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32967. */
  32968. lensFlaresEnabled: boolean;
  32969. /**
  32970. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32971. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32972. */
  32973. collisionsEnabled: boolean;
  32974. private _collisionCoordinator;
  32975. /** @hidden */
  32976. readonly collisionCoordinator: ICollisionCoordinator;
  32977. /**
  32978. * Defines the gravity applied to this scene (used only for collisions)
  32979. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32980. */
  32981. gravity: Vector3;
  32982. /**
  32983. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32984. */
  32985. postProcessesEnabled: boolean;
  32986. /**
  32987. * The list of postprocesses added to the scene
  32988. */
  32989. postProcesses: PostProcess[];
  32990. /**
  32991. * Gets the current postprocess manager
  32992. */
  32993. postProcessManager: PostProcessManager;
  32994. /**
  32995. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32996. */
  32997. renderTargetsEnabled: boolean;
  32998. /**
  32999. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33000. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33001. */
  33002. dumpNextRenderTargets: boolean;
  33003. /**
  33004. * The list of user defined render targets added to the scene
  33005. */
  33006. customRenderTargets: RenderTargetTexture[];
  33007. /**
  33008. * Defines if texture loading must be delayed
  33009. * If true, textures will only be loaded when they need to be rendered
  33010. */
  33011. useDelayedTextureLoading: boolean;
  33012. /**
  33013. * Gets the list of meshes imported to the scene through SceneLoader
  33014. */
  33015. importedMeshesFiles: String[];
  33016. /**
  33017. * Gets or sets a boolean indicating if probes are enabled on this scene
  33018. */
  33019. probesEnabled: boolean;
  33020. /**
  33021. * Gets or sets the current offline provider to use to store scene data
  33022. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33023. */
  33024. offlineProvider: IOfflineProvider;
  33025. /**
  33026. * Gets or sets the action manager associated with the scene
  33027. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33028. */
  33029. actionManager: AbstractActionManager;
  33030. private _meshesForIntersections;
  33031. /**
  33032. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33033. */
  33034. proceduralTexturesEnabled: boolean;
  33035. private _engine;
  33036. private _totalVertices;
  33037. /** @hidden */ private _activeIndices: PerfCounter;
  33038. /** @hidden */ private _activeParticles: PerfCounter;
  33039. /** @hidden */ private _activeBones: PerfCounter;
  33040. private _animationRatio;
  33041. /** @hidden */ private _animationTimeLast: number;
  33042. /** @hidden */ private _animationTime: number;
  33043. /**
  33044. * Gets or sets a general scale for animation speed
  33045. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33046. */
  33047. animationTimeScale: number;
  33048. /** @hidden */ private _cachedMaterial: Nullable<Material>;
  33049. /** @hidden */ private _cachedEffect: Nullable<Effect>;
  33050. /** @hidden */ private _cachedVisibility: Nullable<number>;
  33051. private _renderId;
  33052. private _frameId;
  33053. private _executeWhenReadyTimeoutId;
  33054. private _intermediateRendering;
  33055. private _viewUpdateFlag;
  33056. private _projectionUpdateFlag;
  33057. /** @hidden */ private _toBeDisposed: Nullable<IDisposable>[];
  33058. private _activeRequests;
  33059. /** @hidden */ private _pendingData: any[];
  33060. private _isDisposed;
  33061. /**
  33062. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33063. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33064. */
  33065. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33066. private _activeMeshes;
  33067. private _processedMaterials;
  33068. private _renderTargets;
  33069. /** @hidden */ private _activeParticleSystems: SmartArray<IParticleSystem>;
  33070. private _activeSkeletons;
  33071. private _softwareSkinnedMeshes;
  33072. private _renderingManager;
  33073. /** @hidden */ private _activeAnimatables: Animatable[];
  33074. private _transformMatrix;
  33075. private _sceneUbo;
  33076. /** @hidden */ private _viewMatrix: Matrix;
  33077. private _projectionMatrix;
  33078. /** @hidden */ private _forcedViewPosition: Nullable<Vector3>;
  33079. /** @hidden */ private _frustumPlanes: Plane[];
  33080. /**
  33081. * Gets the list of frustum planes (built from the active camera)
  33082. */
  33083. readonly frustumPlanes: Plane[];
  33084. /**
  33085. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33086. * This is useful if there are more lights that the maximum simulteanous authorized
  33087. */
  33088. requireLightSorting: boolean;
  33089. /** @hidden */
  33090. readonly useMaterialMeshMap: boolean;
  33091. /** @hidden */
  33092. readonly useClonedMeshhMap: boolean;
  33093. private _externalData;
  33094. private _uid;
  33095. /**
  33096. * @hidden
  33097. * Backing store of defined scene components.
  33098. */ private _components: ISceneComponent[];
  33099. /**
  33100. * @hidden
  33101. * Backing store of defined scene components.
  33102. */ private _serializableComponents: ISceneSerializableComponent[];
  33103. /**
  33104. * List of components to register on the next registration step.
  33105. */
  33106. private _transientComponents;
  33107. /**
  33108. * Registers the transient components if needed.
  33109. */
  33110. private _registerTransientComponents;
  33111. /**
  33112. * @hidden
  33113. * Add a component to the scene.
  33114. * Note that the ccomponent could be registered on th next frame if this is called after
  33115. * the register component stage.
  33116. * @param component Defines the component to add to the scene
  33117. */ private _addComponent(component: ISceneComponent): void;
  33118. /**
  33119. * @hidden
  33120. * Gets a component from the scene.
  33121. * @param name defines the name of the component to retrieve
  33122. * @returns the component or null if not present
  33123. */ private _getComponent(name: string): Nullable<ISceneComponent>;
  33124. /**
  33125. * @hidden
  33126. * Defines the actions happening before camera updates.
  33127. */ private _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33128. /**
  33129. * @hidden
  33130. * Defines the actions happening before clear the canvas.
  33131. */ private _beforeClearStage: Stage<SimpleStageAction>;
  33132. /**
  33133. * @hidden
  33134. * Defines the actions when collecting render targets for the frame.
  33135. */ private _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33136. /**
  33137. * @hidden
  33138. * Defines the actions happening for one camera in the frame.
  33139. */ private _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33140. /**
  33141. * @hidden
  33142. * Defines the actions happening during the per mesh ready checks.
  33143. */ private _isReadyForMeshStage: Stage<MeshStageAction>;
  33144. /**
  33145. * @hidden
  33146. * Defines the actions happening before evaluate active mesh checks.
  33147. */ private _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33148. /**
  33149. * @hidden
  33150. * Defines the actions happening during the evaluate sub mesh checks.
  33151. */ private _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33152. /**
  33153. * @hidden
  33154. * Defines the actions happening during the active mesh stage.
  33155. */ private _activeMeshStage: Stage<ActiveMeshStageAction>;
  33156. /**
  33157. * @hidden
  33158. * Defines the actions happening during the per camera render target step.
  33159. */ private _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33160. /**
  33161. * @hidden
  33162. * Defines the actions happening just before the active camera is drawing.
  33163. */ private _beforeCameraDrawStage: Stage<CameraStageAction>;
  33164. /**
  33165. * @hidden
  33166. * Defines the actions happening just before a render target is drawing.
  33167. */ private _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33168. /**
  33169. * @hidden
  33170. * Defines the actions happening just before a rendering group is drawing.
  33171. */ private _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33172. /**
  33173. * @hidden
  33174. * Defines the actions happening just before a mesh is drawing.
  33175. */ private _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33176. /**
  33177. * @hidden
  33178. * Defines the actions happening just after a mesh has been drawn.
  33179. */ private _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33180. /**
  33181. * @hidden
  33182. * Defines the actions happening just after a rendering group has been drawn.
  33183. */ private _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33184. /**
  33185. * @hidden
  33186. * Defines the actions happening just after the active camera has been drawn.
  33187. */ private _afterCameraDrawStage: Stage<CameraStageAction>;
  33188. /**
  33189. * @hidden
  33190. * Defines the actions happening just after a render target has been drawn.
  33191. */ private _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33192. /**
  33193. * @hidden
  33194. * Defines the actions happening just after rendering all cameras and computing intersections.
  33195. */ private _afterRenderStage: Stage<SimpleStageAction>;
  33196. /**
  33197. * @hidden
  33198. * Defines the actions happening when a pointer move event happens.
  33199. */ private _pointerMoveStage: Stage<PointerMoveStageAction>;
  33200. /**
  33201. * @hidden
  33202. * Defines the actions happening when a pointer down event happens.
  33203. */ private _pointerDownStage: Stage<PointerUpDownStageAction>;
  33204. /**
  33205. * @hidden
  33206. * Defines the actions happening when a pointer up event happens.
  33207. */ private _pointerUpStage: Stage<PointerUpDownStageAction>;
  33208. /**
  33209. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33210. */
  33211. private geometriesByUniqueId;
  33212. /**
  33213. * Creates a new Scene
  33214. * @param engine defines the engine to use to render this scene
  33215. * @param options defines the scene options
  33216. */
  33217. constructor(engine: Engine, options?: SceneOptions);
  33218. /**
  33219. * Gets a string idenfifying the name of the class
  33220. * @returns "Scene" string
  33221. */
  33222. getClassName(): string;
  33223. private _defaultMeshCandidates;
  33224. /**
  33225. * @hidden
  33226. */ private _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33227. private _defaultSubMeshCandidates;
  33228. /**
  33229. * @hidden
  33230. */ private _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33231. /**
  33232. * Sets the default candidate providers for the scene.
  33233. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33234. * and getCollidingSubMeshCandidates to their default function
  33235. */
  33236. setDefaultCandidateProviders(): void;
  33237. /**
  33238. * Gets the mesh that is currently under the pointer
  33239. */
  33240. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33241. /**
  33242. * Gets or sets the current on-screen X position of the pointer
  33243. */
  33244. pointerX: number;
  33245. /**
  33246. * Gets or sets the current on-screen Y position of the pointer
  33247. */
  33248. pointerY: number;
  33249. /**
  33250. * Gets the cached material (ie. the latest rendered one)
  33251. * @returns the cached material
  33252. */
  33253. getCachedMaterial(): Nullable<Material>;
  33254. /**
  33255. * Gets the cached effect (ie. the latest rendered one)
  33256. * @returns the cached effect
  33257. */
  33258. getCachedEffect(): Nullable<Effect>;
  33259. /**
  33260. * Gets the cached visibility state (ie. the latest rendered one)
  33261. * @returns the cached visibility state
  33262. */
  33263. getCachedVisibility(): Nullable<number>;
  33264. /**
  33265. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33266. * @param material defines the current material
  33267. * @param effect defines the current effect
  33268. * @param visibility defines the current visibility state
  33269. * @returns true if one parameter is not cached
  33270. */
  33271. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33272. /**
  33273. * Gets the engine associated with the scene
  33274. * @returns an Engine
  33275. */
  33276. getEngine(): Engine;
  33277. /**
  33278. * Gets the total number of vertices rendered per frame
  33279. * @returns the total number of vertices rendered per frame
  33280. */
  33281. getTotalVertices(): number;
  33282. /**
  33283. * Gets the performance counter for total vertices
  33284. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33285. */
  33286. readonly totalVerticesPerfCounter: PerfCounter;
  33287. /**
  33288. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33289. * @returns the total number of active indices rendered per frame
  33290. */
  33291. getActiveIndices(): number;
  33292. /**
  33293. * Gets the performance counter for active indices
  33294. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33295. */
  33296. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33297. /**
  33298. * Gets the total number of active particles rendered per frame
  33299. * @returns the total number of active particles rendered per frame
  33300. */
  33301. getActiveParticles(): number;
  33302. /**
  33303. * Gets the performance counter for active particles
  33304. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33305. */
  33306. readonly activeParticlesPerfCounter: PerfCounter;
  33307. /**
  33308. * Gets the total number of active bones rendered per frame
  33309. * @returns the total number of active bones rendered per frame
  33310. */
  33311. getActiveBones(): number;
  33312. /**
  33313. * Gets the performance counter for active bones
  33314. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33315. */
  33316. readonly activeBonesPerfCounter: PerfCounter;
  33317. /**
  33318. * Gets the array of active meshes
  33319. * @returns an array of AbstractMesh
  33320. */
  33321. getActiveMeshes(): SmartArray<AbstractMesh>;
  33322. /**
  33323. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33324. * @returns a number
  33325. */
  33326. getAnimationRatio(): number;
  33327. /**
  33328. * Gets an unique Id for the current render phase
  33329. * @returns a number
  33330. */
  33331. getRenderId(): number;
  33332. /**
  33333. * Gets an unique Id for the current frame
  33334. * @returns a number
  33335. */
  33336. getFrameId(): number;
  33337. /** Call this function if you want to manually increment the render Id*/
  33338. incrementRenderId(): void;
  33339. private _createUbo;
  33340. /**
  33341. * Use this method to simulate a pointer move on a mesh
  33342. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33343. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33344. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33345. * @returns the current scene
  33346. */
  33347. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33348. /**
  33349. * Use this method to simulate a pointer down on a mesh
  33350. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33351. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33352. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33353. * @returns the current scene
  33354. */
  33355. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33356. /**
  33357. * Use this method to simulate a pointer up on a mesh
  33358. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33359. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33360. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33361. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33362. * @returns the current scene
  33363. */
  33364. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33365. /**
  33366. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33367. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33368. * @returns true if the pointer was captured
  33369. */
  33370. isPointerCaptured(pointerId?: number): boolean;
  33371. /**
  33372. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33373. * @param attachUp defines if you want to attach events to pointerup
  33374. * @param attachDown defines if you want to attach events to pointerdown
  33375. * @param attachMove defines if you want to attach events to pointermove
  33376. */
  33377. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33378. /** Detaches all event handlers*/
  33379. detachControl(): void;
  33380. /**
  33381. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33382. * Delay loaded resources are not taking in account
  33383. * @return true if all required resources are ready
  33384. */
  33385. isReady(): boolean;
  33386. /** Resets all cached information relative to material (including effect and visibility) */
  33387. resetCachedMaterial(): void;
  33388. /**
  33389. * Registers a function to be called before every frame render
  33390. * @param func defines the function to register
  33391. */
  33392. registerBeforeRender(func: () => void): void;
  33393. /**
  33394. * Unregisters a function called before every frame render
  33395. * @param func defines the function to unregister
  33396. */
  33397. unregisterBeforeRender(func: () => void): void;
  33398. /**
  33399. * Registers a function to be called after every frame render
  33400. * @param func defines the function to register
  33401. */
  33402. registerAfterRender(func: () => void): void;
  33403. /**
  33404. * Unregisters a function called after every frame render
  33405. * @param func defines the function to unregister
  33406. */
  33407. unregisterAfterRender(func: () => void): void;
  33408. private _executeOnceBeforeRender;
  33409. /**
  33410. * The provided function will run before render once and will be disposed afterwards.
  33411. * A timeout delay can be provided so that the function will be executed in N ms.
  33412. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33413. * @param func The function to be executed.
  33414. * @param timeout optional delay in ms
  33415. */
  33416. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33417. /** @hidden */ private _addPendingData(data: any): void;
  33418. /** @hidden */ private _removePendingData(data: any): void;
  33419. /**
  33420. * Returns the number of items waiting to be loaded
  33421. * @returns the number of items waiting to be loaded
  33422. */
  33423. getWaitingItemsCount(): number;
  33424. /**
  33425. * Returns a boolean indicating if the scene is still loading data
  33426. */
  33427. readonly isLoading: boolean;
  33428. /**
  33429. * Registers a function to be executed when the scene is ready
  33430. * @param {Function} func - the function to be executed
  33431. */
  33432. executeWhenReady(func: () => void): void;
  33433. /**
  33434. * Returns a promise that resolves when the scene is ready
  33435. * @returns A promise that resolves when the scene is ready
  33436. */
  33437. whenReadyAsync(): Promise<void>;
  33438. /** @hidden */ private _checkIsReady(): void;
  33439. /**
  33440. * Gets all animatable attached to the scene
  33441. */
  33442. readonly animatables: Animatable[];
  33443. /**
  33444. * Resets the last animation time frame.
  33445. * Useful to override when animations start running when loading a scene for the first time.
  33446. */
  33447. resetLastAnimationTimeFrame(): void;
  33448. /**
  33449. * Gets the current view matrix
  33450. * @returns a Matrix
  33451. */
  33452. getViewMatrix(): Matrix;
  33453. /**
  33454. * Gets the current projection matrix
  33455. * @returns a Matrix
  33456. */
  33457. getProjectionMatrix(): Matrix;
  33458. /**
  33459. * Gets the current transform matrix
  33460. * @returns a Matrix made of View * Projection
  33461. */
  33462. getTransformMatrix(): Matrix;
  33463. /**
  33464. * Sets the current transform matrix
  33465. * @param viewL defines the View matrix to use
  33466. * @param projectionL defines the Projection matrix to use
  33467. * @param viewR defines the right View matrix to use (if provided)
  33468. * @param projectionR defines the right Projection matrix to use (if provided)
  33469. */
  33470. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33471. /**
  33472. * Gets the uniform buffer used to store scene data
  33473. * @returns a UniformBuffer
  33474. */
  33475. getSceneUniformBuffer(): UniformBuffer;
  33476. /**
  33477. * Gets an unique (relatively to the current scene) Id
  33478. * @returns an unique number for the scene
  33479. */
  33480. getUniqueId(): number;
  33481. /**
  33482. * Add a mesh to the list of scene's meshes
  33483. * @param newMesh defines the mesh to add
  33484. * @param recursive if all child meshes should also be added to the scene
  33485. */
  33486. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33487. /**
  33488. * Remove a mesh for the list of scene's meshes
  33489. * @param toRemove defines the mesh to remove
  33490. * @param recursive if all child meshes should also be removed from the scene
  33491. * @returns the index where the mesh was in the mesh list
  33492. */
  33493. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33494. /**
  33495. * Add a transform node to the list of scene's transform nodes
  33496. * @param newTransformNode defines the transform node to add
  33497. */
  33498. addTransformNode(newTransformNode: TransformNode): void;
  33499. /**
  33500. * Remove a transform node for the list of scene's transform nodes
  33501. * @param toRemove defines the transform node to remove
  33502. * @returns the index where the transform node was in the transform node list
  33503. */
  33504. removeTransformNode(toRemove: TransformNode): number;
  33505. /**
  33506. * Remove a skeleton for the list of scene's skeletons
  33507. * @param toRemove defines the skeleton to remove
  33508. * @returns the index where the skeleton was in the skeleton list
  33509. */
  33510. removeSkeleton(toRemove: Skeleton): number;
  33511. /**
  33512. * Remove a morph target for the list of scene's morph targets
  33513. * @param toRemove defines the morph target to remove
  33514. * @returns the index where the morph target was in the morph target list
  33515. */
  33516. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33517. /**
  33518. * Remove a light for the list of scene's lights
  33519. * @param toRemove defines the light to remove
  33520. * @returns the index where the light was in the light list
  33521. */
  33522. removeLight(toRemove: Light): number;
  33523. /**
  33524. * Remove a camera for the list of scene's cameras
  33525. * @param toRemove defines the camera to remove
  33526. * @returns the index where the camera was in the camera list
  33527. */
  33528. removeCamera(toRemove: Camera): number;
  33529. /**
  33530. * Remove a particle system for the list of scene's particle systems
  33531. * @param toRemove defines the particle system to remove
  33532. * @returns the index where the particle system was in the particle system list
  33533. */
  33534. removeParticleSystem(toRemove: IParticleSystem): number;
  33535. /**
  33536. * Remove a animation for the list of scene's animations
  33537. * @param toRemove defines the animation to remove
  33538. * @returns the index where the animation was in the animation list
  33539. */
  33540. removeAnimation(toRemove: Animation): number;
  33541. /**
  33542. * Will stop the animation of the given target
  33543. * @param target - the target
  33544. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33545. * @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)
  33546. */
  33547. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33548. /**
  33549. * Removes the given animation group from this scene.
  33550. * @param toRemove The animation group to remove
  33551. * @returns The index of the removed animation group
  33552. */
  33553. removeAnimationGroup(toRemove: AnimationGroup): number;
  33554. /**
  33555. * Removes the given multi-material from this scene.
  33556. * @param toRemove The multi-material to remove
  33557. * @returns The index of the removed multi-material
  33558. */
  33559. removeMultiMaterial(toRemove: MultiMaterial): number;
  33560. /**
  33561. * Removes the given material from this scene.
  33562. * @param toRemove The material to remove
  33563. * @returns The index of the removed material
  33564. */
  33565. removeMaterial(toRemove: Material): number;
  33566. /**
  33567. * Removes the given action manager from this scene.
  33568. * @param toRemove The action manager to remove
  33569. * @returns The index of the removed action manager
  33570. */
  33571. removeActionManager(toRemove: AbstractActionManager): number;
  33572. /**
  33573. * Removes the given texture from this scene.
  33574. * @param toRemove The texture to remove
  33575. * @returns The index of the removed texture
  33576. */
  33577. removeTexture(toRemove: BaseTexture): number;
  33578. /**
  33579. * Adds the given light to this scene
  33580. * @param newLight The light to add
  33581. */
  33582. addLight(newLight: Light): void;
  33583. /**
  33584. * Sorts the list list based on light priorities
  33585. */
  33586. sortLightsByPriority(): void;
  33587. /**
  33588. * Adds the given camera to this scene
  33589. * @param newCamera The camera to add
  33590. */
  33591. addCamera(newCamera: Camera): void;
  33592. /**
  33593. * Adds the given skeleton to this scene
  33594. * @param newSkeleton The skeleton to add
  33595. */
  33596. addSkeleton(newSkeleton: Skeleton): void;
  33597. /**
  33598. * Adds the given particle system to this scene
  33599. * @param newParticleSystem The particle system to add
  33600. */
  33601. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33602. /**
  33603. * Adds the given animation to this scene
  33604. * @param newAnimation The animation to add
  33605. */
  33606. addAnimation(newAnimation: Animation): void;
  33607. /**
  33608. * Adds the given animation group to this scene.
  33609. * @param newAnimationGroup The animation group to add
  33610. */
  33611. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33612. /**
  33613. * Adds the given multi-material to this scene
  33614. * @param newMultiMaterial The multi-material to add
  33615. */
  33616. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33617. /**
  33618. * Adds the given material to this scene
  33619. * @param newMaterial The material to add
  33620. */
  33621. addMaterial(newMaterial: Material): void;
  33622. /**
  33623. * Adds the given morph target to this scene
  33624. * @param newMorphTargetManager The morph target to add
  33625. */
  33626. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33627. /**
  33628. * Adds the given geometry to this scene
  33629. * @param newGeometry The geometry to add
  33630. */
  33631. addGeometry(newGeometry: Geometry): void;
  33632. /**
  33633. * Adds the given action manager to this scene
  33634. * @param newActionManager The action manager to add
  33635. */
  33636. addActionManager(newActionManager: AbstractActionManager): void;
  33637. /**
  33638. * Adds the given texture to this scene.
  33639. * @param newTexture The texture to add
  33640. */
  33641. addTexture(newTexture: BaseTexture): void;
  33642. /**
  33643. * Switch active camera
  33644. * @param newCamera defines the new active camera
  33645. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33646. */
  33647. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33648. /**
  33649. * sets the active camera of the scene using its ID
  33650. * @param id defines the camera's ID
  33651. * @return the new active camera or null if none found.
  33652. */
  33653. setActiveCameraByID(id: string): Nullable<Camera>;
  33654. /**
  33655. * sets the active camera of the scene using its name
  33656. * @param name defines the camera's name
  33657. * @returns the new active camera or null if none found.
  33658. */
  33659. setActiveCameraByName(name: string): Nullable<Camera>;
  33660. /**
  33661. * get an animation group using its name
  33662. * @param name defines the material's name
  33663. * @return the animation group or null if none found.
  33664. */
  33665. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33666. /**
  33667. * Get a material using its unique id
  33668. * @param uniqueId defines the material's unique id
  33669. * @return the material or null if none found.
  33670. */
  33671. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33672. /**
  33673. * get a material using its id
  33674. * @param id defines the material's ID
  33675. * @return the material or null if none found.
  33676. */
  33677. getMaterialByID(id: string): Nullable<Material>;
  33678. /**
  33679. * Gets a the last added material using a given id
  33680. * @param id defines the material's ID
  33681. * @return the last material with the given id or null if none found.
  33682. */
  33683. getLastMaterialByID(id: string): Nullable<Material>;
  33684. /**
  33685. * Gets a material using its name
  33686. * @param name defines the material's name
  33687. * @return the material or null if none found.
  33688. */
  33689. getMaterialByName(name: string): Nullable<Material>;
  33690. /**
  33691. * Get a texture using its unique id
  33692. * @param uniqueId defines the texture's unique id
  33693. * @return the texture or null if none found.
  33694. */
  33695. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  33696. /**
  33697. * Gets a camera using its id
  33698. * @param id defines the id to look for
  33699. * @returns the camera or null if not found
  33700. */
  33701. getCameraByID(id: string): Nullable<Camera>;
  33702. /**
  33703. * Gets a camera using its unique id
  33704. * @param uniqueId defines the unique id to look for
  33705. * @returns the camera or null if not found
  33706. */
  33707. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33708. /**
  33709. * Gets a camera using its name
  33710. * @param name defines the camera's name
  33711. * @return the camera or null if none found.
  33712. */
  33713. getCameraByName(name: string): Nullable<Camera>;
  33714. /**
  33715. * Gets a bone using its id
  33716. * @param id defines the bone's id
  33717. * @return the bone or null if not found
  33718. */
  33719. getBoneByID(id: string): Nullable<Bone>;
  33720. /**
  33721. * Gets a bone using its id
  33722. * @param name defines the bone's name
  33723. * @return the bone or null if not found
  33724. */
  33725. getBoneByName(name: string): Nullable<Bone>;
  33726. /**
  33727. * Gets a light node using its name
  33728. * @param name defines the the light's name
  33729. * @return the light or null if none found.
  33730. */
  33731. getLightByName(name: string): Nullable<Light>;
  33732. /**
  33733. * Gets a light node using its id
  33734. * @param id defines the light's id
  33735. * @return the light or null if none found.
  33736. */
  33737. getLightByID(id: string): Nullable<Light>;
  33738. /**
  33739. * Gets a light node using its scene-generated unique ID
  33740. * @param uniqueId defines the light's unique id
  33741. * @return the light or null if none found.
  33742. */
  33743. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33744. /**
  33745. * Gets a particle system by id
  33746. * @param id defines the particle system id
  33747. * @return the corresponding system or null if none found
  33748. */
  33749. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33750. /**
  33751. * Gets a geometry using its ID
  33752. * @param id defines the geometry's id
  33753. * @return the geometry or null if none found.
  33754. */
  33755. getGeometryByID(id: string): Nullable<Geometry>;
  33756. private _getGeometryByUniqueID;
  33757. /**
  33758. * Add a new geometry to this scene
  33759. * @param geometry defines the geometry to be added to the scene.
  33760. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33761. * @return a boolean defining if the geometry was added or not
  33762. */
  33763. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33764. /**
  33765. * Removes an existing geometry
  33766. * @param geometry defines the geometry to be removed from the scene
  33767. * @return a boolean defining if the geometry was removed or not
  33768. */
  33769. removeGeometry(geometry: Geometry): boolean;
  33770. /**
  33771. * Gets the list of geometries attached to the scene
  33772. * @returns an array of Geometry
  33773. */
  33774. getGeometries(): Geometry[];
  33775. /**
  33776. * Gets the first added mesh found of a given ID
  33777. * @param id defines the id to search for
  33778. * @return the mesh found or null if not found at all
  33779. */
  33780. getMeshByID(id: string): Nullable<AbstractMesh>;
  33781. /**
  33782. * Gets a list of meshes using their id
  33783. * @param id defines the id to search for
  33784. * @returns a list of meshes
  33785. */
  33786. getMeshesByID(id: string): Array<AbstractMesh>;
  33787. /**
  33788. * Gets the first added transform node found of a given ID
  33789. * @param id defines the id to search for
  33790. * @return the found transform node or null if not found at all.
  33791. */
  33792. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33793. /**
  33794. * Gets a transform node with its auto-generated unique id
  33795. * @param uniqueId efines the unique id to search for
  33796. * @return the found transform node or null if not found at all.
  33797. */
  33798. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33799. /**
  33800. * Gets a list of transform nodes using their id
  33801. * @param id defines the id to search for
  33802. * @returns a list of transform nodes
  33803. */
  33804. getTransformNodesByID(id: string): Array<TransformNode>;
  33805. /**
  33806. * Gets a mesh with its auto-generated unique id
  33807. * @param uniqueId defines the unique id to search for
  33808. * @return the found mesh or null if not found at all.
  33809. */
  33810. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33811. /**
  33812. * Gets a the last added mesh using a given id
  33813. * @param id defines the id to search for
  33814. * @return the found mesh or null if not found at all.
  33815. */
  33816. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33817. /**
  33818. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33819. * @param id defines the id to search for
  33820. * @return the found node or null if not found at all
  33821. */
  33822. getLastEntryByID(id: string): Nullable<Node>;
  33823. /**
  33824. * Gets a node (Mesh, Camera, Light) using a given id
  33825. * @param id defines the id to search for
  33826. * @return the found node or null if not found at all
  33827. */
  33828. getNodeByID(id: string): Nullable<Node>;
  33829. /**
  33830. * Gets a node (Mesh, Camera, Light) using a given name
  33831. * @param name defines the name to search for
  33832. * @return the found node or null if not found at all.
  33833. */
  33834. getNodeByName(name: string): Nullable<Node>;
  33835. /**
  33836. * Gets a mesh using a given name
  33837. * @param name defines the name to search for
  33838. * @return the found mesh or null if not found at all.
  33839. */
  33840. getMeshByName(name: string): Nullable<AbstractMesh>;
  33841. /**
  33842. * Gets a transform node using a given name
  33843. * @param name defines the name to search for
  33844. * @return the found transform node or null if not found at all.
  33845. */
  33846. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33847. /**
  33848. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33849. * @param id defines the id to search for
  33850. * @return the found skeleton or null if not found at all.
  33851. */
  33852. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33853. /**
  33854. * Gets a skeleton using a given auto generated unique id
  33855. * @param uniqueId defines the unique id to search for
  33856. * @return the found skeleton or null if not found at all.
  33857. */
  33858. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33859. /**
  33860. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33861. * @param id defines the id to search for
  33862. * @return the found skeleton or null if not found at all.
  33863. */
  33864. getSkeletonById(id: string): Nullable<Skeleton>;
  33865. /**
  33866. * Gets a skeleton using a given name
  33867. * @param name defines the name to search for
  33868. * @return the found skeleton or null if not found at all.
  33869. */
  33870. getSkeletonByName(name: string): Nullable<Skeleton>;
  33871. /**
  33872. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33873. * @param id defines the id to search for
  33874. * @return the found morph target manager or null if not found at all.
  33875. */
  33876. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33877. /**
  33878. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33879. * @param id defines the id to search for
  33880. * @return the found morph target or null if not found at all.
  33881. */
  33882. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33883. /**
  33884. * Gets a boolean indicating if the given mesh is active
  33885. * @param mesh defines the mesh to look for
  33886. * @returns true if the mesh is in the active list
  33887. */
  33888. isActiveMesh(mesh: AbstractMesh): boolean;
  33889. /**
  33890. * Return a unique id as a string which can serve as an identifier for the scene
  33891. */
  33892. readonly uid: string;
  33893. /**
  33894. * Add an externaly attached data from its key.
  33895. * This method call will fail and return false, if such key already exists.
  33896. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33897. * @param key the unique key that identifies the data
  33898. * @param data the data object to associate to the key for this Engine instance
  33899. * @return true if no such key were already present and the data was added successfully, false otherwise
  33900. */
  33901. addExternalData<T>(key: string, data: T): boolean;
  33902. /**
  33903. * Get an externaly attached data from its key
  33904. * @param key the unique key that identifies the data
  33905. * @return the associated data, if present (can be null), or undefined if not present
  33906. */
  33907. getExternalData<T>(key: string): Nullable<T>;
  33908. /**
  33909. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33910. * @param key the unique key that identifies the data
  33911. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33912. * @return the associated data, can be null if the factory returned null.
  33913. */
  33914. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33915. /**
  33916. * Remove an externaly attached data from the Engine instance
  33917. * @param key the unique key that identifies the data
  33918. * @return true if the data was successfully removed, false if it doesn't exist
  33919. */
  33920. removeExternalData(key: string): boolean;
  33921. private _evaluateSubMesh;
  33922. /**
  33923. * Clear the processed materials smart array preventing retention point in material dispose.
  33924. */
  33925. freeProcessedMaterials(): void;
  33926. private _preventFreeActiveMeshesAndRenderingGroups;
  33927. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33928. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33929. * when disposing several meshes in a row or a hierarchy of meshes.
  33930. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33931. */
  33932. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33933. /**
  33934. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33935. */
  33936. freeActiveMeshes(): void;
  33937. /**
  33938. * Clear the info related to rendering groups preventing retention points during dispose.
  33939. */
  33940. freeRenderingGroups(): void;
  33941. /** @hidden */ private _isInIntermediateRendering(): boolean;
  33942. /**
  33943. * Lambda returning the list of potentially active meshes.
  33944. */
  33945. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33946. /**
  33947. * Lambda returning the list of potentially active sub meshes.
  33948. */
  33949. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33950. /**
  33951. * Lambda returning the list of potentially intersecting sub meshes.
  33952. */
  33953. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33954. /**
  33955. * Lambda returning the list of potentially colliding sub meshes.
  33956. */
  33957. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33958. private _activeMeshesFrozen;
  33959. /**
  33960. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33961. * @returns the current scene
  33962. */
  33963. freezeActiveMeshes(): Scene;
  33964. /**
  33965. * Use this function to restart evaluating active meshes on every frame
  33966. * @returns the current scene
  33967. */
  33968. unfreezeActiveMeshes(): Scene;
  33969. private _evaluateActiveMeshes;
  33970. private _activeMesh;
  33971. /**
  33972. * Update the transform matrix to update from the current active camera
  33973. * @param force defines a boolean used to force the update even if cache is up to date
  33974. */
  33975. updateTransformMatrix(force?: boolean): void;
  33976. private _bindFrameBuffer;
  33977. /** @hidden */ private _allowPostProcessClearColor: boolean;
  33978. /** @hidden */ private _renderForCamera(camera: Camera, rigParent?: Camera): void;
  33979. private _processSubCameras;
  33980. private _checkIntersections;
  33981. /** @hidden */ private _advancePhysicsEngineStep(step: number): void;
  33982. /**
  33983. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33984. */
  33985. getDeterministicFrameTime: () => number;
  33986. /** @hidden */ private _animate(): void;
  33987. /** Execute all animations (for a frame) */
  33988. animate(): void;
  33989. /**
  33990. * Render the scene
  33991. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33992. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  33993. */
  33994. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  33995. /**
  33996. * Freeze all materials
  33997. * A frozen material will not be updatable but should be faster to render
  33998. */
  33999. freezeMaterials(): void;
  34000. /**
  34001. * Unfreeze all materials
  34002. * A frozen material will not be updatable but should be faster to render
  34003. */
  34004. unfreezeMaterials(): void;
  34005. /**
  34006. * Releases all held ressources
  34007. */
  34008. dispose(): void;
  34009. /**
  34010. * Gets if the scene is already disposed
  34011. */
  34012. readonly isDisposed: boolean;
  34013. /**
  34014. * Call this function to reduce memory footprint of the scene.
  34015. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34016. */
  34017. clearCachedVertexData(): void;
  34018. /**
  34019. * This function will remove the local cached buffer data from texture.
  34020. * It will save memory but will prevent the texture from being rebuilt
  34021. */
  34022. cleanCachedTextureBuffer(): void;
  34023. /**
  34024. * Get the world extend vectors with an optional filter
  34025. *
  34026. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34027. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34028. */
  34029. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34030. min: Vector3;
  34031. max: Vector3;
  34032. };
  34033. /**
  34034. * Creates a ray that can be used to pick in the scene
  34035. * @param x defines the x coordinate of the origin (on-screen)
  34036. * @param y defines the y coordinate of the origin (on-screen)
  34037. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34038. * @param camera defines the camera to use for the picking
  34039. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34040. * @returns a Ray
  34041. */
  34042. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34043. /**
  34044. * Creates a ray that can be used to pick in the scene
  34045. * @param x defines the x coordinate of the origin (on-screen)
  34046. * @param y defines the y coordinate of the origin (on-screen)
  34047. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34048. * @param result defines the ray where to store the picking ray
  34049. * @param camera defines the camera to use for the picking
  34050. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34051. * @returns the current scene
  34052. */
  34053. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34054. /**
  34055. * Creates a ray that can be used to pick in the scene
  34056. * @param x defines the x coordinate of the origin (on-screen)
  34057. * @param y defines the y coordinate of the origin (on-screen)
  34058. * @param camera defines the camera to use for the picking
  34059. * @returns a Ray
  34060. */
  34061. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34062. /**
  34063. * Creates a ray that can be used to pick in the scene
  34064. * @param x defines the x coordinate of the origin (on-screen)
  34065. * @param y defines the y coordinate of the origin (on-screen)
  34066. * @param result defines the ray where to store the picking ray
  34067. * @param camera defines the camera to use for the picking
  34068. * @returns the current scene
  34069. */
  34070. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34071. /** Launch a ray to try to pick a mesh in the scene
  34072. * @param x position on screen
  34073. * @param y position on screen
  34074. * @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
  34075. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34076. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34077. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34078. * @returns a PickingInfo
  34079. */
  34080. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34081. /** Use the given ray to pick a mesh in the scene
  34082. * @param ray The ray to use to pick meshes
  34083. * @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
  34084. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34085. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34086. * @returns a PickingInfo
  34087. */
  34088. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34089. /**
  34090. * Launch a ray to try to pick a mesh in the scene
  34091. * @param x X position on screen
  34092. * @param y Y position on screen
  34093. * @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
  34094. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34095. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34096. * @returns an array of PickingInfo
  34097. */
  34098. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34099. /**
  34100. * Launch a ray to try to pick a mesh in the scene
  34101. * @param ray Ray to use
  34102. * @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
  34103. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34104. * @returns an array of PickingInfo
  34105. */
  34106. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34107. /**
  34108. * Force the value of meshUnderPointer
  34109. * @param mesh defines the mesh to use
  34110. */
  34111. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34112. /**
  34113. * Gets the mesh under the pointer
  34114. * @returns a Mesh or null if no mesh is under the pointer
  34115. */
  34116. getPointerOverMesh(): Nullable<AbstractMesh>;
  34117. /** @hidden */ private _rebuildGeometries(): void;
  34118. /** @hidden */ private _rebuildTextures(): void;
  34119. private _getByTags;
  34120. /**
  34121. * Get a list of meshes by tags
  34122. * @param tagsQuery defines the tags query to use
  34123. * @param forEach defines a predicate used to filter results
  34124. * @returns an array of Mesh
  34125. */
  34126. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34127. /**
  34128. * Get a list of cameras by tags
  34129. * @param tagsQuery defines the tags query to use
  34130. * @param forEach defines a predicate used to filter results
  34131. * @returns an array of Camera
  34132. */
  34133. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34134. /**
  34135. * Get a list of lights by tags
  34136. * @param tagsQuery defines the tags query to use
  34137. * @param forEach defines a predicate used to filter results
  34138. * @returns an array of Light
  34139. */
  34140. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34141. /**
  34142. * Get a list of materials by tags
  34143. * @param tagsQuery defines the tags query to use
  34144. * @param forEach defines a predicate used to filter results
  34145. * @returns an array of Material
  34146. */
  34147. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34148. /**
  34149. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34150. * This allowed control for front to back rendering or reversly depending of the special needs.
  34151. *
  34152. * @param renderingGroupId The rendering group id corresponding to its index
  34153. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34154. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34155. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34156. */
  34157. 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;
  34158. /**
  34159. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34160. *
  34161. * @param renderingGroupId The rendering group id corresponding to its index
  34162. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34163. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34164. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34165. */
  34166. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34167. /**
  34168. * Gets the current auto clear configuration for one rendering group of the rendering
  34169. * manager.
  34170. * @param index the rendering group index to get the information for
  34171. * @returns The auto clear setup for the requested rendering group
  34172. */
  34173. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34174. private _blockMaterialDirtyMechanism;
  34175. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34176. blockMaterialDirtyMechanism: boolean;
  34177. /**
  34178. * Will flag all materials as dirty to trigger new shader compilation
  34179. * @param flag defines the flag used to specify which material part must be marked as dirty
  34180. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34181. */
  34182. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34183. /** @hidden */ private _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  34184. /** @hidden */ private _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34185. /** @hidden */ private _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  34186. /** @hidden */ private _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  34187. /** @hidden */ private _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34188. /** @hidden */ private _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34189. }
  34190. }
  34191. declare module BABYLON {
  34192. /**
  34193. * Set of assets to keep when moving a scene into an asset container.
  34194. */
  34195. export class KeepAssets extends AbstractScene {
  34196. }
  34197. /**
  34198. * Container with a set of assets that can be added or removed from a scene.
  34199. */
  34200. export class AssetContainer extends AbstractScene {
  34201. /**
  34202. * The scene the AssetContainer belongs to.
  34203. */
  34204. scene: Scene;
  34205. /**
  34206. * Instantiates an AssetContainer.
  34207. * @param scene The scene the AssetContainer belongs to.
  34208. */
  34209. constructor(scene: Scene);
  34210. /**
  34211. * Adds all the assets from the container to the scene.
  34212. */
  34213. addAllToScene(): void;
  34214. /**
  34215. * Removes all the assets in the container from the scene
  34216. */
  34217. removeAllFromScene(): void;
  34218. /**
  34219. * Disposes all the assets in the container
  34220. */
  34221. dispose(): void;
  34222. private _moveAssets;
  34223. /**
  34224. * Removes all the assets contained in the scene and adds them to the container.
  34225. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34226. */
  34227. moveAllFromScene(keepAssets?: KeepAssets): void;
  34228. /**
  34229. * 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.
  34230. * @returns the root mesh
  34231. */
  34232. createRootMesh(): Mesh;
  34233. }
  34234. }
  34235. declare module BABYLON {
  34236. /**
  34237. * Defines how the parser contract is defined.
  34238. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34239. */
  34240. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34241. /**
  34242. * Defines how the individual parser contract is defined.
  34243. * These parser can parse an individual asset
  34244. */
  34245. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34246. /**
  34247. * Base class of the scene acting as a container for the different elements composing a scene.
  34248. * This class is dynamically extended by the different components of the scene increasing
  34249. * flexibility and reducing coupling
  34250. */
  34251. export abstract class AbstractScene {
  34252. /**
  34253. * Stores the list of available parsers in the application.
  34254. */
  34255. private static _BabylonFileParsers;
  34256. /**
  34257. * Stores the list of available individual parsers in the application.
  34258. */
  34259. private static _IndividualBabylonFileParsers;
  34260. /**
  34261. * Adds a parser in the list of available ones
  34262. * @param name Defines the name of the parser
  34263. * @param parser Defines the parser to add
  34264. */
  34265. static AddParser(name: string, parser: BabylonFileParser): void;
  34266. /**
  34267. * Gets a general parser from the list of avaialble ones
  34268. * @param name Defines the name of the parser
  34269. * @returns the requested parser or null
  34270. */
  34271. static GetParser(name: string): Nullable<BabylonFileParser>;
  34272. /**
  34273. * Adds n individual parser in the list of available ones
  34274. * @param name Defines the name of the parser
  34275. * @param parser Defines the parser to add
  34276. */
  34277. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34278. /**
  34279. * Gets an individual parser from the list of avaialble ones
  34280. * @param name Defines the name of the parser
  34281. * @returns the requested parser or null
  34282. */
  34283. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34284. /**
  34285. * Parser json data and populate both a scene and its associated container object
  34286. * @param jsonData Defines the data to parse
  34287. * @param scene Defines the scene to parse the data for
  34288. * @param container Defines the container attached to the parsing sequence
  34289. * @param rootUrl Defines the root url of the data
  34290. */
  34291. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34292. /**
  34293. * Gets the list of root nodes (ie. nodes with no parent)
  34294. */
  34295. rootNodes: Node[];
  34296. /** All of the cameras added to this scene
  34297. * @see http://doc.babylonjs.com/babylon101/cameras
  34298. */
  34299. cameras: Camera[];
  34300. /**
  34301. * All of the lights added to this scene
  34302. * @see http://doc.babylonjs.com/babylon101/lights
  34303. */
  34304. lights: Light[];
  34305. /**
  34306. * All of the (abstract) meshes added to this scene
  34307. */
  34308. meshes: AbstractMesh[];
  34309. /**
  34310. * The list of skeletons added to the scene
  34311. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34312. */
  34313. skeletons: Skeleton[];
  34314. /**
  34315. * All of the particle systems added to this scene
  34316. * @see http://doc.babylonjs.com/babylon101/particles
  34317. */
  34318. particleSystems: IParticleSystem[];
  34319. /**
  34320. * Gets a list of Animations associated with the scene
  34321. */
  34322. animations: Animation[];
  34323. /**
  34324. * All of the animation groups added to this scene
  34325. * @see http://doc.babylonjs.com/how_to/group
  34326. */
  34327. animationGroups: AnimationGroup[];
  34328. /**
  34329. * All of the multi-materials added to this scene
  34330. * @see http://doc.babylonjs.com/how_to/multi_materials
  34331. */
  34332. multiMaterials: MultiMaterial[];
  34333. /**
  34334. * All of the materials added to this scene
  34335. * In the context of a Scene, it is not supposed to be modified manually.
  34336. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34337. * Note also that the order of the Material wihin the array is not significant and might change.
  34338. * @see http://doc.babylonjs.com/babylon101/materials
  34339. */
  34340. materials: Material[];
  34341. /**
  34342. * The list of morph target managers added to the scene
  34343. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34344. */
  34345. morphTargetManagers: MorphTargetManager[];
  34346. /**
  34347. * The list of geometries used in the scene.
  34348. */
  34349. geometries: Geometry[];
  34350. /**
  34351. * All of the tranform nodes added to this scene
  34352. * In the context of a Scene, it is not supposed to be modified manually.
  34353. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34354. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34355. * @see http://doc.babylonjs.com/how_to/transformnode
  34356. */
  34357. transformNodes: TransformNode[];
  34358. /**
  34359. * ActionManagers available on the scene.
  34360. */
  34361. actionManagers: AbstractActionManager[];
  34362. /**
  34363. * Textures to keep.
  34364. */
  34365. textures: BaseTexture[];
  34366. /**
  34367. * Environment texture for the scene
  34368. */
  34369. environmentTexture: Nullable<BaseTexture>;
  34370. }
  34371. }
  34372. declare module BABYLON {
  34373. /**
  34374. * Interface used to define options for Sound class
  34375. */
  34376. export interface ISoundOptions {
  34377. /**
  34378. * Does the sound autoplay once loaded.
  34379. */
  34380. autoplay?: boolean;
  34381. /**
  34382. * Does the sound loop after it finishes playing once.
  34383. */
  34384. loop?: boolean;
  34385. /**
  34386. * Sound's volume
  34387. */
  34388. volume?: number;
  34389. /**
  34390. * Is it a spatial sound?
  34391. */
  34392. spatialSound?: boolean;
  34393. /**
  34394. * Maximum distance to hear that sound
  34395. */
  34396. maxDistance?: number;
  34397. /**
  34398. * Uses user defined attenuation function
  34399. */
  34400. useCustomAttenuation?: boolean;
  34401. /**
  34402. * Define the roll off factor of spatial sounds.
  34403. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34404. */
  34405. rolloffFactor?: number;
  34406. /**
  34407. * Define the reference distance the sound should be heard perfectly.
  34408. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34409. */
  34410. refDistance?: number;
  34411. /**
  34412. * Define the distance attenuation model the sound will follow.
  34413. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34414. */
  34415. distanceModel?: string;
  34416. /**
  34417. * Defines the playback speed (1 by default)
  34418. */
  34419. playbackRate?: number;
  34420. /**
  34421. * Defines if the sound is from a streaming source
  34422. */
  34423. streaming?: boolean;
  34424. /**
  34425. * Defines an optional length (in seconds) inside the sound file
  34426. */
  34427. length?: number;
  34428. /**
  34429. * Defines an optional offset (in seconds) inside the sound file
  34430. */
  34431. offset?: number;
  34432. /**
  34433. * If true, URLs will not be required to state the audio file codec to use.
  34434. */
  34435. skipCodecCheck?: boolean;
  34436. }
  34437. /**
  34438. * Defines a sound that can be played in the application.
  34439. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34440. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34441. */
  34442. export class Sound {
  34443. /**
  34444. * The name of the sound in the scene.
  34445. */
  34446. name: string;
  34447. /**
  34448. * Does the sound autoplay once loaded.
  34449. */
  34450. autoplay: boolean;
  34451. /**
  34452. * Does the sound loop after it finishes playing once.
  34453. */
  34454. loop: boolean;
  34455. /**
  34456. * Does the sound use a custom attenuation curve to simulate the falloff
  34457. * happening when the source gets further away from the camera.
  34458. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34459. */
  34460. useCustomAttenuation: boolean;
  34461. /**
  34462. * The sound track id this sound belongs to.
  34463. */
  34464. soundTrackId: number;
  34465. /**
  34466. * Is this sound currently played.
  34467. */
  34468. isPlaying: boolean;
  34469. /**
  34470. * Is this sound currently paused.
  34471. */
  34472. isPaused: boolean;
  34473. /**
  34474. * Does this sound enables spatial sound.
  34475. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34476. */
  34477. spatialSound: boolean;
  34478. /**
  34479. * Define the reference distance the sound should be heard perfectly.
  34480. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34481. */
  34482. refDistance: number;
  34483. /**
  34484. * Define the roll off factor of spatial sounds.
  34485. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34486. */
  34487. rolloffFactor: number;
  34488. /**
  34489. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34490. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34491. */
  34492. maxDistance: number;
  34493. /**
  34494. * Define the distance attenuation model the sound will follow.
  34495. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34496. */
  34497. distanceModel: string;
  34498. /**
  34499. * @hidden
  34500. * Back Compat
  34501. **/
  34502. onended: () => any;
  34503. /**
  34504. * Observable event when the current playing sound finishes.
  34505. */
  34506. onEndedObservable: Observable<Sound>;
  34507. private _panningModel;
  34508. private _playbackRate;
  34509. private _streaming;
  34510. private _startTime;
  34511. private _startOffset;
  34512. private _position;
  34513. /** @hidden */ private _positionInEmitterSpace: boolean;
  34514. private _localDirection;
  34515. private _volume;
  34516. private _isReadyToPlay;
  34517. private _isDirectional;
  34518. private _readyToPlayCallback;
  34519. private _audioBuffer;
  34520. private _soundSource;
  34521. private _streamingSource;
  34522. private _soundPanner;
  34523. private _soundGain;
  34524. private _inputAudioNode;
  34525. private _outputAudioNode;
  34526. private _coneInnerAngle;
  34527. private _coneOuterAngle;
  34528. private _coneOuterGain;
  34529. private _scene;
  34530. private _connectedTransformNode;
  34531. private _customAttenuationFunction;
  34532. private _registerFunc;
  34533. private _isOutputConnected;
  34534. private _htmlAudioElement;
  34535. private _urlType;
  34536. private _length?;
  34537. private _offset?;
  34538. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  34539. /**
  34540. * Create a sound and attach it to a scene
  34541. * @param name Name of your sound
  34542. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34543. * @param scene defines the scene the sound belongs to
  34544. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34545. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34546. */
  34547. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  34548. /**
  34549. * Release the sound and its associated resources
  34550. */
  34551. dispose(): void;
  34552. /**
  34553. * Gets if the sounds is ready to be played or not.
  34554. * @returns true if ready, otherwise false
  34555. */
  34556. isReady(): boolean;
  34557. private _soundLoaded;
  34558. /**
  34559. * Sets the data of the sound from an audiobuffer
  34560. * @param audioBuffer The audioBuffer containing the data
  34561. */
  34562. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34563. /**
  34564. * Updates the current sounds options such as maxdistance, loop...
  34565. * @param options A JSON object containing values named as the object properties
  34566. */
  34567. updateOptions(options: ISoundOptions): void;
  34568. private _createSpatialParameters;
  34569. private _updateSpatialParameters;
  34570. /**
  34571. * Switch the panning model to HRTF:
  34572. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34573. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34574. */
  34575. switchPanningModelToHRTF(): void;
  34576. /**
  34577. * Switch the panning model to Equal Power:
  34578. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34579. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34580. */
  34581. switchPanningModelToEqualPower(): void;
  34582. private _switchPanningModel;
  34583. /**
  34584. * Connect this sound to a sound track audio node like gain...
  34585. * @param soundTrackAudioNode the sound track audio node to connect to
  34586. */
  34587. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34588. /**
  34589. * Transform this sound into a directional source
  34590. * @param coneInnerAngle Size of the inner cone in degree
  34591. * @param coneOuterAngle Size of the outer cone in degree
  34592. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34593. */
  34594. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34595. /**
  34596. * Gets or sets the inner angle for the directional cone.
  34597. */
  34598. /**
  34599. * Gets or sets the inner angle for the directional cone.
  34600. */
  34601. directionalConeInnerAngle: number;
  34602. /**
  34603. * Gets or sets the outer angle for the directional cone.
  34604. */
  34605. /**
  34606. * Gets or sets the outer angle for the directional cone.
  34607. */
  34608. directionalConeOuterAngle: number;
  34609. /**
  34610. * Sets the position of the emitter if spatial sound is enabled
  34611. * @param newPosition Defines the new posisiton
  34612. */
  34613. setPosition(newPosition: Vector3): void;
  34614. /**
  34615. * Sets the local direction of the emitter if spatial sound is enabled
  34616. * @param newLocalDirection Defines the new local direction
  34617. */
  34618. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34619. private _updateDirection;
  34620. /** @hidden */
  34621. updateDistanceFromListener(): void;
  34622. /**
  34623. * Sets a new custom attenuation function for the sound.
  34624. * @param callback Defines the function used for the attenuation
  34625. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34626. */
  34627. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34628. /**
  34629. * Play the sound
  34630. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34631. * @param offset (optional) Start the sound at a specific time in seconds
  34632. * @param length (optional) Sound duration (in seconds)
  34633. */
  34634. play(time?: number, offset?: number, length?: number): void;
  34635. private _onended;
  34636. /**
  34637. * Stop the sound
  34638. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34639. */
  34640. stop(time?: number): void;
  34641. /**
  34642. * Put the sound in pause
  34643. */
  34644. pause(): void;
  34645. /**
  34646. * Sets a dedicated volume for this sounds
  34647. * @param newVolume Define the new volume of the sound
  34648. * @param time Define time for gradual change to new volume
  34649. */
  34650. setVolume(newVolume: number, time?: number): void;
  34651. /**
  34652. * Set the sound play back rate
  34653. * @param newPlaybackRate Define the playback rate the sound should be played at
  34654. */
  34655. setPlaybackRate(newPlaybackRate: number): void;
  34656. /**
  34657. * Gets the volume of the sound.
  34658. * @returns the volume of the sound
  34659. */
  34660. getVolume(): number;
  34661. /**
  34662. * Attach the sound to a dedicated mesh
  34663. * @param transformNode The transform node to connect the sound with
  34664. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34665. */
  34666. attachToMesh(transformNode: TransformNode): void;
  34667. /**
  34668. * Detach the sound from the previously attached mesh
  34669. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34670. */
  34671. detachFromMesh(): void;
  34672. private _onRegisterAfterWorldMatrixUpdate;
  34673. /**
  34674. * Clone the current sound in the scene.
  34675. * @returns the new sound clone
  34676. */
  34677. clone(): Nullable<Sound>;
  34678. /**
  34679. * Gets the current underlying audio buffer containing the data
  34680. * @returns the audio buffer
  34681. */
  34682. getAudioBuffer(): Nullable<AudioBuffer>;
  34683. /**
  34684. * Serializes the Sound in a JSON representation
  34685. * @returns the JSON representation of the sound
  34686. */
  34687. serialize(): any;
  34688. /**
  34689. * Parse a JSON representation of a sound to innstantiate in a given scene
  34690. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34691. * @param scene Define the scene the new parsed sound should be created in
  34692. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34693. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34694. * @returns the newly parsed sound
  34695. */
  34696. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34697. }
  34698. }
  34699. declare module BABYLON {
  34700. /**
  34701. * This defines an action helpful to play a defined sound on a triggered action.
  34702. */
  34703. export class PlaySoundAction extends Action {
  34704. private _sound;
  34705. /**
  34706. * Instantiate the action
  34707. * @param triggerOptions defines the trigger options
  34708. * @param sound defines the sound to play
  34709. * @param condition defines the trigger related conditions
  34710. */
  34711. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34712. /** @hidden */ private _prepare(): void;
  34713. /**
  34714. * Execute the action and play the sound.
  34715. */
  34716. execute(): void;
  34717. /**
  34718. * Serializes the actions and its related information.
  34719. * @param parent defines the object to serialize in
  34720. * @returns the serialized object
  34721. */
  34722. serialize(parent: any): any;
  34723. }
  34724. /**
  34725. * This defines an action helpful to stop a defined sound on a triggered action.
  34726. */
  34727. export class StopSoundAction extends Action {
  34728. private _sound;
  34729. /**
  34730. * Instantiate the action
  34731. * @param triggerOptions defines the trigger options
  34732. * @param sound defines the sound to stop
  34733. * @param condition defines the trigger related conditions
  34734. */
  34735. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34736. /** @hidden */ private _prepare(): void;
  34737. /**
  34738. * Execute the action and stop the sound.
  34739. */
  34740. execute(): void;
  34741. /**
  34742. * Serializes the actions and its related information.
  34743. * @param parent defines the object to serialize in
  34744. * @returns the serialized object
  34745. */
  34746. serialize(parent: any): any;
  34747. }
  34748. }
  34749. declare module BABYLON {
  34750. /**
  34751. * This defines an action responsible to change the value of a property
  34752. * by interpolating between its current value and the newly set one once triggered.
  34753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34754. */
  34755. export class InterpolateValueAction extends Action {
  34756. /**
  34757. * Defines the path of the property where the value should be interpolated
  34758. */
  34759. propertyPath: string;
  34760. /**
  34761. * Defines the target value at the end of the interpolation.
  34762. */
  34763. value: any;
  34764. /**
  34765. * Defines the time it will take for the property to interpolate to the value.
  34766. */
  34767. duration: number;
  34768. /**
  34769. * Defines if the other scene animations should be stopped when the action has been triggered
  34770. */
  34771. stopOtherAnimations?: boolean;
  34772. /**
  34773. * Defines a callback raised once the interpolation animation has been done.
  34774. */
  34775. onInterpolationDone?: () => void;
  34776. /**
  34777. * Observable triggered once the interpolation animation has been done.
  34778. */
  34779. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34780. private _target;
  34781. private _effectiveTarget;
  34782. private _property;
  34783. /**
  34784. * Instantiate the action
  34785. * @param triggerOptions defines the trigger options
  34786. * @param target defines the object containing the value to interpolate
  34787. * @param propertyPath defines the path to the property in the target object
  34788. * @param value defines the target value at the end of the interpolation
  34789. * @param duration deines the time it will take for the property to interpolate to the value.
  34790. * @param condition defines the trigger related conditions
  34791. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34792. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34793. */
  34794. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34795. /** @hidden */ private _prepare(): void;
  34796. /**
  34797. * Execute the action starts the value interpolation.
  34798. */
  34799. execute(): void;
  34800. /**
  34801. * Serializes the actions and its related information.
  34802. * @param parent defines the object to serialize in
  34803. * @returns the serialized object
  34804. */
  34805. serialize(parent: any): any;
  34806. }
  34807. }
  34808. declare module BABYLON {
  34809. /**
  34810. * Options allowed during the creation of a sound track.
  34811. */
  34812. export interface ISoundTrackOptions {
  34813. /**
  34814. * The volume the sound track should take during creation
  34815. */
  34816. volume?: number;
  34817. /**
  34818. * Define if the sound track is the main sound track of the scene
  34819. */
  34820. mainTrack?: boolean;
  34821. }
  34822. /**
  34823. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34824. * It will be also used in a future release to apply effects on a specific track.
  34825. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34826. */
  34827. export class SoundTrack {
  34828. /**
  34829. * The unique identifier of the sound track in the scene.
  34830. */
  34831. id: number;
  34832. /**
  34833. * The list of sounds included in the sound track.
  34834. */
  34835. soundCollection: Array<Sound>;
  34836. private _outputAudioNode;
  34837. private _scene;
  34838. private _isMainTrack;
  34839. private _connectedAnalyser;
  34840. private _options;
  34841. private _isInitialized;
  34842. /**
  34843. * Creates a new sound track.
  34844. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34845. * @param scene Define the scene the sound track belongs to
  34846. * @param options
  34847. */
  34848. constructor(scene: Scene, options?: ISoundTrackOptions);
  34849. private _initializeSoundTrackAudioGraph;
  34850. /**
  34851. * Release the sound track and its associated resources
  34852. */
  34853. dispose(): void;
  34854. /**
  34855. * Adds a sound to this sound track
  34856. * @param sound define the cound to add
  34857. * @ignoreNaming
  34858. */
  34859. AddSound(sound: Sound): void;
  34860. /**
  34861. * Removes a sound to this sound track
  34862. * @param sound define the cound to remove
  34863. * @ignoreNaming
  34864. */
  34865. RemoveSound(sound: Sound): void;
  34866. /**
  34867. * Set a global volume for the full sound track.
  34868. * @param newVolume Define the new volume of the sound track
  34869. */
  34870. setVolume(newVolume: number): void;
  34871. /**
  34872. * Switch the panning model to HRTF:
  34873. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34874. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34875. */
  34876. switchPanningModelToHRTF(): void;
  34877. /**
  34878. * Switch the panning model to Equal Power:
  34879. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34880. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34881. */
  34882. switchPanningModelToEqualPower(): void;
  34883. /**
  34884. * Connect the sound track to an audio analyser allowing some amazing
  34885. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34886. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34887. * @param analyser The analyser to connect to the engine
  34888. */
  34889. connectToAnalyser(analyser: Analyser): void;
  34890. }
  34891. }
  34892. declare module BABYLON {
  34893. interface AbstractScene {
  34894. /**
  34895. * The list of sounds used in the scene.
  34896. */
  34897. sounds: Nullable<Array<Sound>>;
  34898. }
  34899. interface Scene {
  34900. /**
  34901. * @hidden
  34902. * Backing field
  34903. */ private _mainSoundTrack: SoundTrack;
  34904. /**
  34905. * The main sound track played by the scene.
  34906. * It cotains your primary collection of sounds.
  34907. */
  34908. mainSoundTrack: SoundTrack;
  34909. /**
  34910. * The list of sound tracks added to the scene
  34911. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34912. */
  34913. soundTracks: Nullable<Array<SoundTrack>>;
  34914. /**
  34915. * Gets a sound using a given name
  34916. * @param name defines the name to search for
  34917. * @return the found sound or null if not found at all.
  34918. */
  34919. getSoundByName(name: string): Nullable<Sound>;
  34920. /**
  34921. * Gets or sets if audio support is enabled
  34922. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34923. */
  34924. audioEnabled: boolean;
  34925. /**
  34926. * Gets or sets if audio will be output to headphones
  34927. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34928. */
  34929. headphone: boolean;
  34930. /**
  34931. * Gets or sets custom audio listener position provider
  34932. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34933. */
  34934. audioListenerPositionProvider: Nullable<() => Vector3>;
  34935. }
  34936. /**
  34937. * Defines the sound scene component responsible to manage any sounds
  34938. * in a given scene.
  34939. */
  34940. export class AudioSceneComponent implements ISceneSerializableComponent {
  34941. /**
  34942. * The component name helpfull to identify the component in the list of scene components.
  34943. */
  34944. readonly name: string;
  34945. /**
  34946. * The scene the component belongs to.
  34947. */
  34948. scene: Scene;
  34949. private _audioEnabled;
  34950. /**
  34951. * Gets whether audio is enabled or not.
  34952. * Please use related enable/disable method to switch state.
  34953. */
  34954. readonly audioEnabled: boolean;
  34955. private _headphone;
  34956. /**
  34957. * Gets whether audio is outputing to headphone or not.
  34958. * Please use the according Switch methods to change output.
  34959. */
  34960. readonly headphone: boolean;
  34961. private _audioListenerPositionProvider;
  34962. /**
  34963. * Gets the current audio listener position provider
  34964. */
  34965. /**
  34966. * Sets a custom listener position for all sounds in the scene
  34967. * By default, this is the position of the first active camera
  34968. */
  34969. audioListenerPositionProvider: Nullable<() => Vector3>;
  34970. /**
  34971. * Creates a new instance of the component for the given scene
  34972. * @param scene Defines the scene to register the component in
  34973. */
  34974. constructor(scene: Scene);
  34975. /**
  34976. * Registers the component in a given scene
  34977. */
  34978. register(): void;
  34979. /**
  34980. * Rebuilds the elements related to this component in case of
  34981. * context lost for instance.
  34982. */
  34983. rebuild(): void;
  34984. /**
  34985. * Serializes the component data to the specified json object
  34986. * @param serializationObject The object to serialize to
  34987. */
  34988. serialize(serializationObject: any): void;
  34989. /**
  34990. * Adds all the elements from the container to the scene
  34991. * @param container the container holding the elements
  34992. */
  34993. addFromContainer(container: AbstractScene): void;
  34994. /**
  34995. * Removes all the elements in the container from the scene
  34996. * @param container contains the elements to remove
  34997. * @param dispose if the removed element should be disposed (default: false)
  34998. */
  34999. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35000. /**
  35001. * Disposes the component and the associated ressources.
  35002. */
  35003. dispose(): void;
  35004. /**
  35005. * Disables audio in the associated scene.
  35006. */
  35007. disableAudio(): void;
  35008. /**
  35009. * Enables audio in the associated scene.
  35010. */
  35011. enableAudio(): void;
  35012. /**
  35013. * Switch audio to headphone output.
  35014. */
  35015. switchAudioModeForHeadphones(): void;
  35016. /**
  35017. * Switch audio to normal speakers.
  35018. */
  35019. switchAudioModeForNormalSpeakers(): void;
  35020. private _afterRender;
  35021. }
  35022. }
  35023. declare module BABYLON {
  35024. /**
  35025. * Wraps one or more Sound objects and selects one with random weight for playback.
  35026. */
  35027. export class WeightedSound {
  35028. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35029. loop: boolean;
  35030. private _coneInnerAngle;
  35031. private _coneOuterAngle;
  35032. private _volume;
  35033. /** A Sound is currently playing. */
  35034. isPlaying: boolean;
  35035. /** A Sound is currently paused. */
  35036. isPaused: boolean;
  35037. private _sounds;
  35038. private _weights;
  35039. private _currentIndex?;
  35040. /**
  35041. * Creates a new WeightedSound from the list of sounds given.
  35042. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35043. * @param sounds Array of Sounds that will be selected from.
  35044. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35045. */
  35046. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35047. /**
  35048. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35049. */
  35050. /**
  35051. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35052. */
  35053. directionalConeInnerAngle: number;
  35054. /**
  35055. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35056. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35057. */
  35058. /**
  35059. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35060. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35061. */
  35062. directionalConeOuterAngle: number;
  35063. /**
  35064. * Playback volume.
  35065. */
  35066. /**
  35067. * Playback volume.
  35068. */
  35069. volume: number;
  35070. private _onended;
  35071. /**
  35072. * Suspend playback
  35073. */
  35074. pause(): void;
  35075. /**
  35076. * Stop playback
  35077. */
  35078. stop(): void;
  35079. /**
  35080. * Start playback.
  35081. * @param startOffset Position the clip head at a specific time in seconds.
  35082. */
  35083. play(startOffset?: number): void;
  35084. }
  35085. }
  35086. declare module BABYLON {
  35087. /**
  35088. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35089. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35090. */
  35091. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35092. /**
  35093. * Gets the name of the behavior.
  35094. */
  35095. readonly name: string;
  35096. /**
  35097. * The easing function used by animations
  35098. */
  35099. static EasingFunction: BackEase;
  35100. /**
  35101. * The easing mode used by animations
  35102. */
  35103. static EasingMode: number;
  35104. /**
  35105. * The duration of the animation, in milliseconds
  35106. */
  35107. transitionDuration: number;
  35108. /**
  35109. * Length of the distance animated by the transition when lower radius is reached
  35110. */
  35111. lowerRadiusTransitionRange: number;
  35112. /**
  35113. * Length of the distance animated by the transition when upper radius is reached
  35114. */
  35115. upperRadiusTransitionRange: number;
  35116. private _autoTransitionRange;
  35117. /**
  35118. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35119. */
  35120. /**
  35121. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35122. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35123. */
  35124. autoTransitionRange: boolean;
  35125. private _attachedCamera;
  35126. private _onAfterCheckInputsObserver;
  35127. private _onMeshTargetChangedObserver;
  35128. /**
  35129. * Initializes the behavior.
  35130. */
  35131. init(): void;
  35132. /**
  35133. * Attaches the behavior to its arc rotate camera.
  35134. * @param camera Defines the camera to attach the behavior to
  35135. */
  35136. attach(camera: ArcRotateCamera): void;
  35137. /**
  35138. * Detaches the behavior from its current arc rotate camera.
  35139. */
  35140. detach(): void;
  35141. private _radiusIsAnimating;
  35142. private _radiusBounceTransition;
  35143. private _animatables;
  35144. private _cachedWheelPrecision;
  35145. /**
  35146. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35147. * @param radiusLimit The limit to check against.
  35148. * @return Bool to indicate if at limit.
  35149. */
  35150. private _isRadiusAtLimit;
  35151. /**
  35152. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35153. * @param radiusDelta The delta by which to animate to. Can be negative.
  35154. */
  35155. private _applyBoundRadiusAnimation;
  35156. /**
  35157. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35158. */
  35159. protected _clearAnimationLocks(): void;
  35160. /**
  35161. * Stops and removes all animations that have been applied to the camera
  35162. */
  35163. stopAllAnimations(): void;
  35164. }
  35165. }
  35166. declare module BABYLON {
  35167. /**
  35168. * 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.
  35169. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35170. */
  35171. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35172. /**
  35173. * Gets the name of the behavior.
  35174. */
  35175. readonly name: string;
  35176. private _mode;
  35177. private _radiusScale;
  35178. private _positionScale;
  35179. private _defaultElevation;
  35180. private _elevationReturnTime;
  35181. private _elevationReturnWaitTime;
  35182. private _zoomStopsAnimation;
  35183. private _framingTime;
  35184. /**
  35185. * The easing function used by animations
  35186. */
  35187. static EasingFunction: ExponentialEase;
  35188. /**
  35189. * The easing mode used by animations
  35190. */
  35191. static EasingMode: number;
  35192. /**
  35193. * Sets the current mode used by the behavior
  35194. */
  35195. /**
  35196. * Gets current mode used by the behavior.
  35197. */
  35198. mode: number;
  35199. /**
  35200. * Sets the scale applied to the radius (1 by default)
  35201. */
  35202. /**
  35203. * Gets the scale applied to the radius
  35204. */
  35205. radiusScale: number;
  35206. /**
  35207. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35208. */
  35209. /**
  35210. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35211. */
  35212. positionScale: number;
  35213. /**
  35214. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35215. * behaviour is triggered, in radians.
  35216. */
  35217. /**
  35218. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35219. * behaviour is triggered, in radians.
  35220. */
  35221. defaultElevation: number;
  35222. /**
  35223. * Sets the time (in milliseconds) taken to return to the default beta position.
  35224. * Negative value indicates camera should not return to default.
  35225. */
  35226. /**
  35227. * Gets the time (in milliseconds) taken to return to the default beta position.
  35228. * Negative value indicates camera should not return to default.
  35229. */
  35230. elevationReturnTime: number;
  35231. /**
  35232. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35233. */
  35234. /**
  35235. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35236. */
  35237. elevationReturnWaitTime: number;
  35238. /**
  35239. * Sets the flag that indicates if user zooming should stop animation.
  35240. */
  35241. /**
  35242. * Gets the flag that indicates if user zooming should stop animation.
  35243. */
  35244. zoomStopsAnimation: boolean;
  35245. /**
  35246. * Sets the transition time when framing the mesh, in milliseconds
  35247. */
  35248. /**
  35249. * Gets the transition time when framing the mesh, in milliseconds
  35250. */
  35251. framingTime: number;
  35252. /**
  35253. * Define if the behavior should automatically change the configured
  35254. * camera limits and sensibilities.
  35255. */
  35256. autoCorrectCameraLimitsAndSensibility: boolean;
  35257. private _onPrePointerObservableObserver;
  35258. private _onAfterCheckInputsObserver;
  35259. private _onMeshTargetChangedObserver;
  35260. private _attachedCamera;
  35261. private _isPointerDown;
  35262. private _lastInteractionTime;
  35263. /**
  35264. * Initializes the behavior.
  35265. */
  35266. init(): void;
  35267. /**
  35268. * Attaches the behavior to its arc rotate camera.
  35269. * @param camera Defines the camera to attach the behavior to
  35270. */
  35271. attach(camera: ArcRotateCamera): void;
  35272. /**
  35273. * Detaches the behavior from its current arc rotate camera.
  35274. */
  35275. detach(): void;
  35276. private _animatables;
  35277. private _betaIsAnimating;
  35278. private _betaTransition;
  35279. private _radiusTransition;
  35280. private _vectorTransition;
  35281. /**
  35282. * Targets the given mesh and updates zoom level accordingly.
  35283. * @param mesh The mesh to target.
  35284. * @param radius Optional. If a cached radius position already exists, overrides default.
  35285. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35286. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35287. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35288. */
  35289. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35290. /**
  35291. * Targets the given mesh with its children and updates zoom level accordingly.
  35292. * @param mesh The mesh to target.
  35293. * @param radius Optional. If a cached radius position already exists, overrides default.
  35294. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35295. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35296. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35297. */
  35298. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35299. /**
  35300. * Targets the given meshes with their children and updates zoom level accordingly.
  35301. * @param meshes The mesh to target.
  35302. * @param radius Optional. If a cached radius position already exists, overrides default.
  35303. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35304. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35305. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35306. */
  35307. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35308. /**
  35309. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35310. * @param minimumWorld Determines the smaller position of the bounding box extend
  35311. * @param maximumWorld Determines the bigger position of the bounding box extend
  35312. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35313. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35314. */
  35315. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35316. /**
  35317. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35318. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35319. * frustum width.
  35320. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35321. * to fully enclose the mesh in the viewing frustum.
  35322. */
  35323. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35324. /**
  35325. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35326. * is automatically returned to its default position (expected to be above ground plane).
  35327. */
  35328. private _maintainCameraAboveGround;
  35329. /**
  35330. * Returns the frustum slope based on the canvas ratio and camera FOV
  35331. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35332. */
  35333. private _getFrustumSlope;
  35334. /**
  35335. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35336. */
  35337. private _clearAnimationLocks;
  35338. /**
  35339. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35340. */
  35341. private _applyUserInteraction;
  35342. /**
  35343. * Stops and removes all animations that have been applied to the camera
  35344. */
  35345. stopAllAnimations(): void;
  35346. /**
  35347. * Gets a value indicating if the user is moving the camera
  35348. */
  35349. readonly isUserIsMoving: boolean;
  35350. /**
  35351. * The camera can move all the way towards the mesh.
  35352. */
  35353. static IgnoreBoundsSizeMode: number;
  35354. /**
  35355. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35356. */
  35357. static FitFrustumSidesMode: number;
  35358. }
  35359. }
  35360. declare module BABYLON {
  35361. /**
  35362. * Base class for Camera Pointer Inputs.
  35363. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35364. * for example usage.
  35365. */
  35366. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35367. /**
  35368. * Defines the camera the input is attached to.
  35369. */
  35370. abstract camera: Camera;
  35371. /**
  35372. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35373. */
  35374. protected _altKey: boolean;
  35375. protected _ctrlKey: boolean;
  35376. protected _metaKey: boolean;
  35377. protected _shiftKey: boolean;
  35378. /**
  35379. * Which mouse buttons were pressed at time of last mouse event.
  35380. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35381. */
  35382. protected _buttonsPressed: number;
  35383. /**
  35384. * Defines the buttons associated with the input to handle camera move.
  35385. */
  35386. buttons: number[];
  35387. /**
  35388. * Attach the input controls to a specific dom element to get the input from.
  35389. * @param element Defines the element the controls should be listened from
  35390. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35391. */
  35392. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35393. /**
  35394. * Detach the current controls from the specified dom element.
  35395. * @param element Defines the element to stop listening the inputs from
  35396. */
  35397. detachControl(element: Nullable<HTMLElement>): void;
  35398. /**
  35399. * Gets the class name of the current input.
  35400. * @returns the class name
  35401. */
  35402. getClassName(): string;
  35403. /**
  35404. * Get the friendly name associated with the input class.
  35405. * @returns the input friendly name
  35406. */
  35407. getSimpleName(): string;
  35408. /**
  35409. * Called on pointer POINTERDOUBLETAP event.
  35410. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35411. */
  35412. protected onDoubleTap(type: string): void;
  35413. /**
  35414. * Called on pointer POINTERMOVE event if only a single touch is active.
  35415. * Override this method to provide functionality.
  35416. */
  35417. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35418. /**
  35419. * Called on pointer POINTERMOVE event if multiple touches are active.
  35420. * Override this method to provide functionality.
  35421. */
  35422. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35423. /**
  35424. * Called on JS contextmenu event.
  35425. * Override this method to provide functionality.
  35426. */
  35427. protected onContextMenu(evt: PointerEvent): void;
  35428. /**
  35429. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35430. * press.
  35431. * Override this method to provide functionality.
  35432. */
  35433. protected onButtonDown(evt: PointerEvent): void;
  35434. /**
  35435. * Called each time a new POINTERUP event occurs. Ie, for each button
  35436. * release.
  35437. * Override this method to provide functionality.
  35438. */
  35439. protected onButtonUp(evt: PointerEvent): void;
  35440. /**
  35441. * Called when window becomes inactive.
  35442. * Override this method to provide functionality.
  35443. */
  35444. protected onLostFocus(): void;
  35445. private _pointerInput;
  35446. private _observer;
  35447. private _onLostFocus;
  35448. private pointA;
  35449. private pointB;
  35450. }
  35451. }
  35452. declare module BABYLON {
  35453. /**
  35454. * Manage the pointers inputs to control an arc rotate camera.
  35455. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35456. */
  35457. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35458. /**
  35459. * Defines the camera the input is attached to.
  35460. */
  35461. camera: ArcRotateCamera;
  35462. /**
  35463. * Gets the class name of the current input.
  35464. * @returns the class name
  35465. */
  35466. getClassName(): string;
  35467. /**
  35468. * Defines the buttons associated with the input to handle camera move.
  35469. */
  35470. buttons: number[];
  35471. /**
  35472. * Defines the pointer angular sensibility along the X axis or how fast is
  35473. * the camera rotating.
  35474. */
  35475. angularSensibilityX: number;
  35476. /**
  35477. * Defines the pointer angular sensibility along the Y axis or how fast is
  35478. * the camera rotating.
  35479. */
  35480. angularSensibilityY: number;
  35481. /**
  35482. * Defines the pointer pinch precision or how fast is the camera zooming.
  35483. */
  35484. pinchPrecision: number;
  35485. /**
  35486. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35487. * from 0.
  35488. * It defines the percentage of current camera.radius to use as delta when
  35489. * pinch zoom is used.
  35490. */
  35491. pinchDeltaPercentage: number;
  35492. /**
  35493. * Defines the pointer panning sensibility or how fast is the camera moving.
  35494. */
  35495. panningSensibility: number;
  35496. /**
  35497. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35498. */
  35499. multiTouchPanning: boolean;
  35500. /**
  35501. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35502. * zoom (pinch) through multitouch.
  35503. */
  35504. multiTouchPanAndZoom: boolean;
  35505. /**
  35506. * Revers pinch action direction.
  35507. */
  35508. pinchInwards: boolean;
  35509. private _isPanClick;
  35510. private _twoFingerActivityCount;
  35511. private _isPinching;
  35512. /**
  35513. * Called on pointer POINTERMOVE event if only a single touch is active.
  35514. */
  35515. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35516. /**
  35517. * Called on pointer POINTERDOUBLETAP event.
  35518. */
  35519. protected onDoubleTap(type: string): void;
  35520. /**
  35521. * Called on pointer POINTERMOVE event if multiple touches are active.
  35522. */
  35523. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35524. /**
  35525. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35526. * press.
  35527. */
  35528. protected onButtonDown(evt: PointerEvent): void;
  35529. /**
  35530. * Called each time a new POINTERUP event occurs. Ie, for each button
  35531. * release.
  35532. */
  35533. protected onButtonUp(evt: PointerEvent): void;
  35534. /**
  35535. * Called when window becomes inactive.
  35536. */
  35537. protected onLostFocus(): void;
  35538. }
  35539. }
  35540. declare module BABYLON {
  35541. /**
  35542. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35543. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35544. */
  35545. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35546. /**
  35547. * Defines the camera the input is attached to.
  35548. */
  35549. camera: ArcRotateCamera;
  35550. /**
  35551. * Defines the list of key codes associated with the up action (increase alpha)
  35552. */
  35553. keysUp: number[];
  35554. /**
  35555. * Defines the list of key codes associated with the down action (decrease alpha)
  35556. */
  35557. keysDown: number[];
  35558. /**
  35559. * Defines the list of key codes associated with the left action (increase beta)
  35560. */
  35561. keysLeft: number[];
  35562. /**
  35563. * Defines the list of key codes associated with the right action (decrease beta)
  35564. */
  35565. keysRight: number[];
  35566. /**
  35567. * Defines the list of key codes associated with the reset action.
  35568. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35569. */
  35570. keysReset: number[];
  35571. /**
  35572. * Defines the panning sensibility of the inputs.
  35573. * (How fast is the camera paning)
  35574. */
  35575. panningSensibility: number;
  35576. /**
  35577. * Defines the zooming sensibility of the inputs.
  35578. * (How fast is the camera zooming)
  35579. */
  35580. zoomingSensibility: number;
  35581. /**
  35582. * Defines wether maintaining the alt key down switch the movement mode from
  35583. * orientation to zoom.
  35584. */
  35585. useAltToZoom: boolean;
  35586. /**
  35587. * Rotation speed of the camera
  35588. */
  35589. angularSpeed: number;
  35590. private _keys;
  35591. private _ctrlPressed;
  35592. private _altPressed;
  35593. private _onCanvasBlurObserver;
  35594. private _onKeyboardObserver;
  35595. private _engine;
  35596. private _scene;
  35597. /**
  35598. * Attach the input controls to a specific dom element to get the input from.
  35599. * @param element Defines the element the controls should be listened from
  35600. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35601. */
  35602. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35603. /**
  35604. * Detach the current controls from the specified dom element.
  35605. * @param element Defines the element to stop listening the inputs from
  35606. */
  35607. detachControl(element: Nullable<HTMLElement>): void;
  35608. /**
  35609. * Update the current camera state depending on the inputs that have been used this frame.
  35610. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35611. */
  35612. checkInputs(): void;
  35613. /**
  35614. * Gets the class name of the current intput.
  35615. * @returns the class name
  35616. */
  35617. getClassName(): string;
  35618. /**
  35619. * Get the friendly name associated with the input class.
  35620. * @returns the input friendly name
  35621. */
  35622. getSimpleName(): string;
  35623. }
  35624. }
  35625. declare module BABYLON {
  35626. /**
  35627. * Manage the mouse wheel inputs to control an arc rotate camera.
  35628. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35629. */
  35630. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35631. /**
  35632. * Defines the camera the input is attached to.
  35633. */
  35634. camera: ArcRotateCamera;
  35635. /**
  35636. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35637. */
  35638. wheelPrecision: number;
  35639. /**
  35640. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35641. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35642. */
  35643. wheelDeltaPercentage: number;
  35644. private _wheel;
  35645. private _observer;
  35646. private computeDeltaFromMouseWheelLegacyEvent;
  35647. /**
  35648. * Attach the input controls to a specific dom element to get the input from.
  35649. * @param element Defines the element the controls should be listened from
  35650. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35651. */
  35652. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35653. /**
  35654. * Detach the current controls from the specified dom element.
  35655. * @param element Defines the element to stop listening the inputs from
  35656. */
  35657. detachControl(element: Nullable<HTMLElement>): void;
  35658. /**
  35659. * Gets the class name of the current intput.
  35660. * @returns the class name
  35661. */
  35662. getClassName(): string;
  35663. /**
  35664. * Get the friendly name associated with the input class.
  35665. * @returns the input friendly name
  35666. */
  35667. getSimpleName(): string;
  35668. }
  35669. }
  35670. declare module BABYLON {
  35671. /**
  35672. * Default Inputs manager for the ArcRotateCamera.
  35673. * It groups all the default supported inputs for ease of use.
  35674. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35675. */
  35676. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35677. /**
  35678. * Instantiates a new ArcRotateCameraInputsManager.
  35679. * @param camera Defines the camera the inputs belong to
  35680. */
  35681. constructor(camera: ArcRotateCamera);
  35682. /**
  35683. * Add mouse wheel input support to the input manager.
  35684. * @returns the current input manager
  35685. */
  35686. addMouseWheel(): ArcRotateCameraInputsManager;
  35687. /**
  35688. * Add pointers input support to the input manager.
  35689. * @returns the current input manager
  35690. */
  35691. addPointers(): ArcRotateCameraInputsManager;
  35692. /**
  35693. * Add keyboard input support to the input manager.
  35694. * @returns the current input manager
  35695. */
  35696. addKeyboard(): ArcRotateCameraInputsManager;
  35697. }
  35698. }
  35699. declare module BABYLON {
  35700. /**
  35701. * This represents an orbital type of camera.
  35702. *
  35703. * 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.
  35704. * 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.
  35705. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35706. */
  35707. export class ArcRotateCamera extends TargetCamera {
  35708. /**
  35709. * Defines the rotation angle of the camera along the longitudinal axis.
  35710. */
  35711. alpha: number;
  35712. /**
  35713. * Defines the rotation angle of the camera along the latitudinal axis.
  35714. */
  35715. beta: number;
  35716. /**
  35717. * Defines the radius of the camera from it s target point.
  35718. */
  35719. radius: number;
  35720. protected _target: Vector3;
  35721. protected _targetHost: Nullable<AbstractMesh>;
  35722. /**
  35723. * Defines the target point of the camera.
  35724. * The camera looks towards it form the radius distance.
  35725. */
  35726. target: Vector3;
  35727. /**
  35728. * Define the current local position of the camera in the scene
  35729. */
  35730. position: Vector3;
  35731. protected _upVector: Vector3;
  35732. protected _upToYMatrix: Matrix;
  35733. protected _YToUpMatrix: Matrix;
  35734. /**
  35735. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35736. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35737. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35738. */
  35739. upVector: Vector3;
  35740. /**
  35741. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35742. */
  35743. setMatUp(): void;
  35744. /**
  35745. * Current inertia value on the longitudinal axis.
  35746. * The bigger this number the longer it will take for the camera to stop.
  35747. */
  35748. inertialAlphaOffset: number;
  35749. /**
  35750. * Current inertia value on the latitudinal axis.
  35751. * The bigger this number the longer it will take for the camera to stop.
  35752. */
  35753. inertialBetaOffset: number;
  35754. /**
  35755. * Current inertia value on the radius axis.
  35756. * The bigger this number the longer it will take for the camera to stop.
  35757. */
  35758. inertialRadiusOffset: number;
  35759. /**
  35760. * Minimum allowed angle on the longitudinal axis.
  35761. * This can help limiting how the Camera is able to move in the scene.
  35762. */
  35763. lowerAlphaLimit: Nullable<number>;
  35764. /**
  35765. * Maximum allowed angle on the longitudinal axis.
  35766. * This can help limiting how the Camera is able to move in the scene.
  35767. */
  35768. upperAlphaLimit: Nullable<number>;
  35769. /**
  35770. * Minimum allowed angle on the latitudinal axis.
  35771. * This can help limiting how the Camera is able to move in the scene.
  35772. */
  35773. lowerBetaLimit: number;
  35774. /**
  35775. * Maximum allowed angle on the latitudinal axis.
  35776. * This can help limiting how the Camera is able to move in the scene.
  35777. */
  35778. upperBetaLimit: number;
  35779. /**
  35780. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35781. * This can help limiting how the Camera is able to move in the scene.
  35782. */
  35783. lowerRadiusLimit: Nullable<number>;
  35784. /**
  35785. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35786. * This can help limiting how the Camera is able to move in the scene.
  35787. */
  35788. upperRadiusLimit: Nullable<number>;
  35789. /**
  35790. * Defines the current inertia value used during panning of the camera along the X axis.
  35791. */
  35792. inertialPanningX: number;
  35793. /**
  35794. * Defines the current inertia value used during panning of the camera along the Y axis.
  35795. */
  35796. inertialPanningY: number;
  35797. /**
  35798. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35799. * Basically if your fingers moves away from more than this distance you will be considered
  35800. * in pinch mode.
  35801. */
  35802. pinchToPanMaxDistance: number;
  35803. /**
  35804. * Defines the maximum distance the camera can pan.
  35805. * This could help keeping the cammera always in your scene.
  35806. */
  35807. panningDistanceLimit: Nullable<number>;
  35808. /**
  35809. * Defines the target of the camera before paning.
  35810. */
  35811. panningOriginTarget: Vector3;
  35812. /**
  35813. * Defines the value of the inertia used during panning.
  35814. * 0 would mean stop inertia and one would mean no decelleration at all.
  35815. */
  35816. panningInertia: number;
  35817. /**
  35818. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35819. */
  35820. angularSensibilityX: number;
  35821. /**
  35822. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35823. */
  35824. angularSensibilityY: number;
  35825. /**
  35826. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35827. */
  35828. pinchPrecision: number;
  35829. /**
  35830. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35831. * It will be used instead of pinchDeltaPrecision if different from 0.
  35832. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35833. */
  35834. pinchDeltaPercentage: number;
  35835. /**
  35836. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35837. */
  35838. panningSensibility: number;
  35839. /**
  35840. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35841. */
  35842. keysUp: number[];
  35843. /**
  35844. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35845. */
  35846. keysDown: number[];
  35847. /**
  35848. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35849. */
  35850. keysLeft: number[];
  35851. /**
  35852. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35853. */
  35854. keysRight: number[];
  35855. /**
  35856. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35857. */
  35858. wheelPrecision: number;
  35859. /**
  35860. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35861. * It will be used instead of pinchDeltaPrecision if different from 0.
  35862. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35863. */
  35864. wheelDeltaPercentage: number;
  35865. /**
  35866. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35867. */
  35868. zoomOnFactor: number;
  35869. /**
  35870. * Defines a screen offset for the camera position.
  35871. */
  35872. targetScreenOffset: Vector2;
  35873. /**
  35874. * Allows the camera to be completely reversed.
  35875. * If false the camera can not arrive upside down.
  35876. */
  35877. allowUpsideDown: boolean;
  35878. /**
  35879. * Define if double tap/click is used to restore the previously saved state of the camera.
  35880. */
  35881. useInputToRestoreState: boolean;
  35882. /** @hidden */ private _viewMatrix: Matrix;
  35883. /** @hidden */ private _useCtrlForPanning: boolean;
  35884. /** @hidden */ private _panningMouseButton: number;
  35885. /**
  35886. * Defines the input associated to the camera.
  35887. */
  35888. inputs: ArcRotateCameraInputsManager;
  35889. /** @hidden */ private _reset: () => void;
  35890. /**
  35891. * Defines the allowed panning axis.
  35892. */
  35893. panningAxis: Vector3;
  35894. protected _localDirection: Vector3;
  35895. protected _transformedDirection: Vector3;
  35896. private _bouncingBehavior;
  35897. /**
  35898. * Gets the bouncing behavior of the camera if it has been enabled.
  35899. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35900. */
  35901. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35902. /**
  35903. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35904. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35905. */
  35906. useBouncingBehavior: boolean;
  35907. private _framingBehavior;
  35908. /**
  35909. * Gets the framing behavior of the camera if it has been enabled.
  35910. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35911. */
  35912. readonly framingBehavior: Nullable<FramingBehavior>;
  35913. /**
  35914. * Defines if the framing behavior of the camera is enabled on the camera.
  35915. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35916. */
  35917. useFramingBehavior: boolean;
  35918. private _autoRotationBehavior;
  35919. /**
  35920. * Gets the auto rotation behavior of the camera if it has been enabled.
  35921. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35922. */
  35923. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35924. /**
  35925. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35926. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35927. */
  35928. useAutoRotationBehavior: boolean;
  35929. /**
  35930. * Observable triggered when the mesh target has been changed on the camera.
  35931. */
  35932. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35933. /**
  35934. * Event raised when the camera is colliding with a mesh.
  35935. */
  35936. onCollide: (collidedMesh: AbstractMesh) => void;
  35937. /**
  35938. * Defines whether the camera should check collision with the objects oh the scene.
  35939. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35940. */
  35941. checkCollisions: boolean;
  35942. /**
  35943. * Defines the collision radius of the camera.
  35944. * This simulates a sphere around the camera.
  35945. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35946. */
  35947. collisionRadius: Vector3;
  35948. protected _collider: Collider;
  35949. protected _previousPosition: Vector3;
  35950. protected _collisionVelocity: Vector3;
  35951. protected _newPosition: Vector3;
  35952. protected _previousAlpha: number;
  35953. protected _previousBeta: number;
  35954. protected _previousRadius: number;
  35955. protected _collisionTriggered: boolean;
  35956. protected _targetBoundingCenter: Nullable<Vector3>;
  35957. private _computationVector;
  35958. /**
  35959. * Instantiates a new ArcRotateCamera in a given scene
  35960. * @param name Defines the name of the camera
  35961. * @param alpha Defines the camera rotation along the logitudinal axis
  35962. * @param beta Defines the camera rotation along the latitudinal axis
  35963. * @param radius Defines the camera distance from its target
  35964. * @param target Defines the camera target
  35965. * @param scene Defines the scene the camera belongs to
  35966. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35967. */
  35968. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35969. /** @hidden */ private _initCache(): void;
  35970. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  35971. protected _getTargetPosition(): Vector3;
  35972. private _storedAlpha;
  35973. private _storedBeta;
  35974. private _storedRadius;
  35975. private _storedTarget;
  35976. private _storedTargetScreenOffset;
  35977. /**
  35978. * Stores the current state of the camera (alpha, beta, radius and target)
  35979. * @returns the camera itself
  35980. */
  35981. storeState(): Camera;
  35982. /**
  35983. * @hidden
  35984. * Restored camera state. You must call storeState() first
  35985. */ private _restoreStateValues(): boolean;
  35986. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  35987. /**
  35988. * Attached controls to the current camera.
  35989. * @param element Defines the element the controls should be listened from
  35990. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35991. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35992. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35993. */
  35994. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35995. /**
  35996. * Detach the current controls from the camera.
  35997. * The camera will stop reacting to inputs.
  35998. * @param element Defines the element to stop listening the inputs from
  35999. */
  36000. detachControl(element: HTMLElement): void;
  36001. /** @hidden */ private _checkInputs(): void;
  36002. protected _checkLimits(): void;
  36003. /**
  36004. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36005. */
  36006. rebuildAnglesAndRadius(): void;
  36007. /**
  36008. * Use a position to define the current camera related information like alpha, beta and radius
  36009. * @param position Defines the position to set the camera at
  36010. */
  36011. setPosition(position: Vector3): void;
  36012. /**
  36013. * Defines the target the camera should look at.
  36014. * This will automatically adapt alpha beta and radius to fit within the new target.
  36015. * @param target Defines the new target as a Vector or a mesh
  36016. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36017. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36018. */
  36019. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36020. /** @hidden */ private _getViewMatrix(): Matrix;
  36021. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36022. /**
  36023. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36024. * @param meshes Defines the mesh to zoom on
  36025. * @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)
  36026. */
  36027. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36028. /**
  36029. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36030. * The target will be changed but the radius
  36031. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36032. * @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)
  36033. */
  36034. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36035. min: Vector3;
  36036. max: Vector3;
  36037. distance: number;
  36038. }, doNotUpdateMaxZ?: boolean): void;
  36039. /**
  36040. * @override
  36041. * Override Camera.createRigCamera
  36042. */
  36043. createRigCamera(name: string, cameraIndex: number): Camera;
  36044. /**
  36045. * @hidden
  36046. * @override
  36047. * Override Camera._updateRigCameras
  36048. */ private _updateRigCameras(): void;
  36049. /**
  36050. * Destroy the camera and release the current resources hold by it.
  36051. */
  36052. dispose(): void;
  36053. /**
  36054. * Gets the current object class name.
  36055. * @return the class name
  36056. */
  36057. getClassName(): string;
  36058. }
  36059. }
  36060. declare module BABYLON {
  36061. /**
  36062. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36063. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36064. */
  36065. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36066. /**
  36067. * Gets the name of the behavior.
  36068. */
  36069. readonly name: string;
  36070. private _zoomStopsAnimation;
  36071. private _idleRotationSpeed;
  36072. private _idleRotationWaitTime;
  36073. private _idleRotationSpinupTime;
  36074. /**
  36075. * Sets the flag that indicates if user zooming should stop animation.
  36076. */
  36077. /**
  36078. * Gets the flag that indicates if user zooming should stop animation.
  36079. */
  36080. zoomStopsAnimation: boolean;
  36081. /**
  36082. * Sets the default speed at which the camera rotates around the model.
  36083. */
  36084. /**
  36085. * Gets the default speed at which the camera rotates around the model.
  36086. */
  36087. idleRotationSpeed: number;
  36088. /**
  36089. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36090. */
  36091. /**
  36092. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36093. */
  36094. idleRotationWaitTime: number;
  36095. /**
  36096. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36097. */
  36098. /**
  36099. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36100. */
  36101. idleRotationSpinupTime: number;
  36102. /**
  36103. * Gets a value indicating if the camera is currently rotating because of this behavior
  36104. */
  36105. readonly rotationInProgress: boolean;
  36106. private _onPrePointerObservableObserver;
  36107. private _onAfterCheckInputsObserver;
  36108. private _attachedCamera;
  36109. private _isPointerDown;
  36110. private _lastFrameTime;
  36111. private _lastInteractionTime;
  36112. private _cameraRotationSpeed;
  36113. /**
  36114. * Initializes the behavior.
  36115. */
  36116. init(): void;
  36117. /**
  36118. * Attaches the behavior to its arc rotate camera.
  36119. * @param camera Defines the camera to attach the behavior to
  36120. */
  36121. attach(camera: ArcRotateCamera): void;
  36122. /**
  36123. * Detaches the behavior from its current arc rotate camera.
  36124. */
  36125. detach(): void;
  36126. /**
  36127. * Returns true if user is scrolling.
  36128. * @return true if user is scrolling.
  36129. */
  36130. private _userIsZooming;
  36131. private _lastFrameRadius;
  36132. private _shouldAnimationStopForInteraction;
  36133. /**
  36134. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36135. */
  36136. private _applyUserInteraction;
  36137. private _userIsMoving;
  36138. }
  36139. }
  36140. declare module BABYLON {
  36141. /**
  36142. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36143. */
  36144. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36145. private ui;
  36146. /**
  36147. * The name of the behavior
  36148. */
  36149. name: string;
  36150. /**
  36151. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36152. */
  36153. distanceAwayFromFace: number;
  36154. /**
  36155. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36156. */
  36157. distanceAwayFromBottomOfFace: number;
  36158. private _faceVectors;
  36159. private _target;
  36160. private _scene;
  36161. private _onRenderObserver;
  36162. private _tmpMatrix;
  36163. private _tmpVector;
  36164. /**
  36165. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36166. * @param ui The transform node that should be attched to the mesh
  36167. */
  36168. constructor(ui: TransformNode);
  36169. /**
  36170. * Initializes the behavior
  36171. */
  36172. init(): void;
  36173. private _closestFace;
  36174. private _zeroVector;
  36175. private _lookAtTmpMatrix;
  36176. private _lookAtToRef;
  36177. /**
  36178. * Attaches the AttachToBoxBehavior to the passed in mesh
  36179. * @param target The mesh that the specified node will be attached to
  36180. */
  36181. attach(target: Mesh): void;
  36182. /**
  36183. * Detaches the behavior from the mesh
  36184. */
  36185. detach(): void;
  36186. }
  36187. }
  36188. declare module BABYLON {
  36189. /**
  36190. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36191. */
  36192. export class FadeInOutBehavior implements Behavior<Mesh> {
  36193. /**
  36194. * Time in milliseconds to delay before fading in (Default: 0)
  36195. */
  36196. delay: number;
  36197. /**
  36198. * Time in milliseconds for the mesh to fade in (Default: 300)
  36199. */
  36200. fadeInTime: number;
  36201. private _millisecondsPerFrame;
  36202. private _hovered;
  36203. private _hoverValue;
  36204. private _ownerNode;
  36205. /**
  36206. * Instatiates the FadeInOutBehavior
  36207. */
  36208. constructor();
  36209. /**
  36210. * The name of the behavior
  36211. */
  36212. readonly name: string;
  36213. /**
  36214. * Initializes the behavior
  36215. */
  36216. init(): void;
  36217. /**
  36218. * Attaches the fade behavior on the passed in mesh
  36219. * @param ownerNode The mesh that will be faded in/out once attached
  36220. */
  36221. attach(ownerNode: Mesh): void;
  36222. /**
  36223. * Detaches the behavior from the mesh
  36224. */
  36225. detach(): void;
  36226. /**
  36227. * Triggers the mesh to begin fading in or out
  36228. * @param value if the object should fade in or out (true to fade in)
  36229. */
  36230. fadeIn(value: boolean): void;
  36231. private _update;
  36232. private _setAllVisibility;
  36233. }
  36234. }
  36235. declare module BABYLON {
  36236. /**
  36237. * Class containing a set of static utilities functions for managing Pivots
  36238. * @hidden
  36239. */
  36240. export class PivotTools {
  36241. private static _PivotCached;
  36242. private static _OldPivotPoint;
  36243. private static _PivotTranslation;
  36244. private static _PivotTmpVector;
  36245. /** @hidden */ private static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36246. /** @hidden */ private static _RestorePivotPoint(mesh: AbstractMesh): void;
  36247. }
  36248. }
  36249. declare module BABYLON {
  36250. /**
  36251. * Class containing static functions to help procedurally build meshes
  36252. */
  36253. export class PlaneBuilder {
  36254. /**
  36255. * Creates a plane mesh
  36256. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36257. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36258. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36259. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36260. * * 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
  36261. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36262. * @param name defines the name of the mesh
  36263. * @param options defines the options used to create the mesh
  36264. * @param scene defines the hosting scene
  36265. * @returns the plane mesh
  36266. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36267. */
  36268. static CreatePlane(name: string, options: {
  36269. size?: number;
  36270. width?: number;
  36271. height?: number;
  36272. sideOrientation?: number;
  36273. frontUVs?: Vector4;
  36274. backUVs?: Vector4;
  36275. updatable?: boolean;
  36276. sourcePlane?: Plane;
  36277. }, scene?: Nullable<Scene>): Mesh;
  36278. }
  36279. }
  36280. declare module BABYLON {
  36281. /**
  36282. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36283. */
  36284. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36285. private static _AnyMouseID;
  36286. /**
  36287. * Abstract mesh the behavior is set on
  36288. */
  36289. attachedNode: AbstractMesh;
  36290. private _dragPlane;
  36291. private _scene;
  36292. private _pointerObserver;
  36293. private _beforeRenderObserver;
  36294. private static _planeScene;
  36295. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36296. /**
  36297. * 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)
  36298. */
  36299. maxDragAngle: number;
  36300. /**
  36301. * @hidden
  36302. */ private _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36303. /**
  36304. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36305. */
  36306. currentDraggingPointerID: number;
  36307. /**
  36308. * The last position where the pointer hit the drag plane in world space
  36309. */
  36310. lastDragPosition: Vector3;
  36311. /**
  36312. * If the behavior is currently in a dragging state
  36313. */
  36314. dragging: boolean;
  36315. /**
  36316. * 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)
  36317. */
  36318. dragDeltaRatio: number;
  36319. /**
  36320. * If the drag plane orientation should be updated during the dragging (Default: true)
  36321. */
  36322. updateDragPlane: boolean;
  36323. private _debugMode;
  36324. private _moving;
  36325. /**
  36326. * Fires each time the attached mesh is dragged with the pointer
  36327. * * delta between last drag position and current drag position in world space
  36328. * * dragDistance along the drag axis
  36329. * * dragPlaneNormal normal of the current drag plane used during the drag
  36330. * * dragPlanePoint in world space where the drag intersects the drag plane
  36331. */
  36332. onDragObservable: Observable<{
  36333. delta: Vector3;
  36334. dragPlanePoint: Vector3;
  36335. dragPlaneNormal: Vector3;
  36336. dragDistance: number;
  36337. pointerId: number;
  36338. }>;
  36339. /**
  36340. * Fires each time a drag begins (eg. mouse down on mesh)
  36341. */
  36342. onDragStartObservable: Observable<{
  36343. dragPlanePoint: Vector3;
  36344. pointerId: number;
  36345. }>;
  36346. /**
  36347. * Fires each time a drag ends (eg. mouse release after drag)
  36348. */
  36349. onDragEndObservable: Observable<{
  36350. dragPlanePoint: Vector3;
  36351. pointerId: number;
  36352. }>;
  36353. /**
  36354. * If the attached mesh should be moved when dragged
  36355. */
  36356. moveAttached: boolean;
  36357. /**
  36358. * If the drag behavior will react to drag events (Default: true)
  36359. */
  36360. enabled: boolean;
  36361. /**
  36362. * If pointer events should start and release the drag (Default: true)
  36363. */
  36364. startAndReleaseDragOnPointerEvents: boolean;
  36365. /**
  36366. * If camera controls should be detached during the drag
  36367. */
  36368. detachCameraControls: boolean;
  36369. /**
  36370. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36371. */
  36372. useObjectOrienationForDragging: boolean;
  36373. private _options;
  36374. /**
  36375. * Creates a pointer drag behavior that can be attached to a mesh
  36376. * @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)
  36377. */
  36378. constructor(options?: {
  36379. dragAxis?: Vector3;
  36380. dragPlaneNormal?: Vector3;
  36381. });
  36382. /**
  36383. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36384. */
  36385. validateDrag: (targetPosition: Vector3) => boolean;
  36386. /**
  36387. * The name of the behavior
  36388. */
  36389. readonly name: string;
  36390. /**
  36391. * Initializes the behavior
  36392. */
  36393. init(): void;
  36394. private _tmpVector;
  36395. private _alternatePickedPoint;
  36396. private _worldDragAxis;
  36397. private _targetPosition;
  36398. private _attachedElement;
  36399. /**
  36400. * Attaches the drag behavior the passed in mesh
  36401. * @param ownerNode The mesh that will be dragged around once attached
  36402. * @param predicate Predicate to use for pick filtering
  36403. */
  36404. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  36405. /**
  36406. * Force relase the drag action by code.
  36407. */
  36408. releaseDrag(): void;
  36409. private _startDragRay;
  36410. private _lastPointerRay;
  36411. /**
  36412. * Simulates the start of a pointer drag event on the behavior
  36413. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36414. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36415. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36416. */
  36417. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36418. private _startDrag;
  36419. private _dragDelta;
  36420. private _moveDrag;
  36421. private _pickWithRayOnDragPlane;
  36422. private _pointA;
  36423. private _pointB;
  36424. private _pointC;
  36425. private _lineA;
  36426. private _lineB;
  36427. private _localAxis;
  36428. private _lookAt;
  36429. private _updateDragPlanePosition;
  36430. /**
  36431. * Detaches the behavior from the mesh
  36432. */
  36433. detach(): void;
  36434. }
  36435. }
  36436. declare module BABYLON {
  36437. /**
  36438. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36439. */
  36440. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36441. private _dragBehaviorA;
  36442. private _dragBehaviorB;
  36443. private _startDistance;
  36444. private _initialScale;
  36445. private _targetScale;
  36446. private _ownerNode;
  36447. private _sceneRenderObserver;
  36448. /**
  36449. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36450. */
  36451. constructor();
  36452. /**
  36453. * The name of the behavior
  36454. */
  36455. readonly name: string;
  36456. /**
  36457. * Initializes the behavior
  36458. */
  36459. init(): void;
  36460. private _getCurrentDistance;
  36461. /**
  36462. * Attaches the scale behavior the passed in mesh
  36463. * @param ownerNode The mesh that will be scaled around once attached
  36464. */
  36465. attach(ownerNode: Mesh): void;
  36466. /**
  36467. * Detaches the behavior from the mesh
  36468. */
  36469. detach(): void;
  36470. }
  36471. }
  36472. declare module BABYLON {
  36473. /**
  36474. * 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
  36475. */
  36476. export class SixDofDragBehavior implements Behavior<Mesh> {
  36477. private static _virtualScene;
  36478. private _ownerNode;
  36479. private _sceneRenderObserver;
  36480. private _scene;
  36481. private _targetPosition;
  36482. private _virtualOriginMesh;
  36483. private _virtualDragMesh;
  36484. private _pointerObserver;
  36485. private _moving;
  36486. private _startingOrientation;
  36487. /**
  36488. * 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)
  36489. */
  36490. private zDragFactor;
  36491. /**
  36492. * If the object should rotate to face the drag origin
  36493. */
  36494. rotateDraggedObject: boolean;
  36495. /**
  36496. * If the behavior is currently in a dragging state
  36497. */
  36498. dragging: boolean;
  36499. /**
  36500. * 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)
  36501. */
  36502. dragDeltaRatio: number;
  36503. /**
  36504. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36505. */
  36506. currentDraggingPointerID: number;
  36507. /**
  36508. * If camera controls should be detached during the drag
  36509. */
  36510. detachCameraControls: boolean;
  36511. /**
  36512. * Fires each time a drag starts
  36513. */
  36514. onDragStartObservable: Observable<{}>;
  36515. /**
  36516. * Fires each time a drag ends (eg. mouse release after drag)
  36517. */
  36518. onDragEndObservable: Observable<{}>;
  36519. /**
  36520. * 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
  36521. */
  36522. constructor();
  36523. /**
  36524. * The name of the behavior
  36525. */
  36526. readonly name: string;
  36527. /**
  36528. * Initializes the behavior
  36529. */
  36530. init(): void;
  36531. /**
  36532. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  36533. */
  36534. private readonly _pointerCamera;
  36535. /**
  36536. * Attaches the scale behavior the passed in mesh
  36537. * @param ownerNode The mesh that will be scaled around once attached
  36538. */
  36539. attach(ownerNode: Mesh): void;
  36540. /**
  36541. * Detaches the behavior from the mesh
  36542. */
  36543. detach(): void;
  36544. }
  36545. }
  36546. declare module BABYLON {
  36547. /**
  36548. * Class used to apply inverse kinematics to bones
  36549. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36550. */
  36551. export class BoneIKController {
  36552. private static _tmpVecs;
  36553. private static _tmpQuat;
  36554. private static _tmpMats;
  36555. /**
  36556. * Gets or sets the target mesh
  36557. */
  36558. targetMesh: AbstractMesh;
  36559. /** Gets or sets the mesh used as pole */
  36560. poleTargetMesh: AbstractMesh;
  36561. /**
  36562. * Gets or sets the bone used as pole
  36563. */
  36564. poleTargetBone: Nullable<Bone>;
  36565. /**
  36566. * Gets or sets the target position
  36567. */
  36568. targetPosition: Vector3;
  36569. /**
  36570. * Gets or sets the pole target position
  36571. */
  36572. poleTargetPosition: Vector3;
  36573. /**
  36574. * Gets or sets the pole target local offset
  36575. */
  36576. poleTargetLocalOffset: Vector3;
  36577. /**
  36578. * Gets or sets the pole angle
  36579. */
  36580. poleAngle: number;
  36581. /**
  36582. * Gets or sets the mesh associated with the controller
  36583. */
  36584. mesh: AbstractMesh;
  36585. /**
  36586. * 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)
  36587. */
  36588. slerpAmount: number;
  36589. private _bone1Quat;
  36590. private _bone1Mat;
  36591. private _bone2Ang;
  36592. private _bone1;
  36593. private _bone2;
  36594. private _bone1Length;
  36595. private _bone2Length;
  36596. private _maxAngle;
  36597. private _maxReach;
  36598. private _rightHandedSystem;
  36599. private _bendAxis;
  36600. private _slerping;
  36601. private _adjustRoll;
  36602. /**
  36603. * Gets or sets maximum allowed angle
  36604. */
  36605. maxAngle: number;
  36606. /**
  36607. * Creates a new BoneIKController
  36608. * @param mesh defines the mesh to control
  36609. * @param bone defines the bone to control
  36610. * @param options defines options to set up the controller
  36611. */
  36612. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36613. targetMesh?: AbstractMesh;
  36614. poleTargetMesh?: AbstractMesh;
  36615. poleTargetBone?: Bone;
  36616. poleTargetLocalOffset?: Vector3;
  36617. poleAngle?: number;
  36618. bendAxis?: Vector3;
  36619. maxAngle?: number;
  36620. slerpAmount?: number;
  36621. });
  36622. private _setMaxAngle;
  36623. /**
  36624. * Force the controller to update the bones
  36625. */
  36626. update(): void;
  36627. }
  36628. }
  36629. declare module BABYLON {
  36630. /**
  36631. * Class used to make a bone look toward a point in space
  36632. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36633. */
  36634. export class BoneLookController {
  36635. private static _tmpVecs;
  36636. private static _tmpQuat;
  36637. private static _tmpMats;
  36638. /**
  36639. * The target Vector3 that the bone will look at
  36640. */
  36641. target: Vector3;
  36642. /**
  36643. * The mesh that the bone is attached to
  36644. */
  36645. mesh: AbstractMesh;
  36646. /**
  36647. * The bone that will be looking to the target
  36648. */
  36649. bone: Bone;
  36650. /**
  36651. * The up axis of the coordinate system that is used when the bone is rotated
  36652. */
  36653. upAxis: Vector3;
  36654. /**
  36655. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36656. */
  36657. upAxisSpace: Space;
  36658. /**
  36659. * Used to make an adjustment to the yaw of the bone
  36660. */
  36661. adjustYaw: number;
  36662. /**
  36663. * Used to make an adjustment to the pitch of the bone
  36664. */
  36665. adjustPitch: number;
  36666. /**
  36667. * Used to make an adjustment to the roll of the bone
  36668. */
  36669. adjustRoll: number;
  36670. /**
  36671. * 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)
  36672. */
  36673. slerpAmount: number;
  36674. private _minYaw;
  36675. private _maxYaw;
  36676. private _minPitch;
  36677. private _maxPitch;
  36678. private _minYawSin;
  36679. private _minYawCos;
  36680. private _maxYawSin;
  36681. private _maxYawCos;
  36682. private _midYawConstraint;
  36683. private _minPitchTan;
  36684. private _maxPitchTan;
  36685. private _boneQuat;
  36686. private _slerping;
  36687. private _transformYawPitch;
  36688. private _transformYawPitchInv;
  36689. private _firstFrameSkipped;
  36690. private _yawRange;
  36691. private _fowardAxis;
  36692. /**
  36693. * Gets or sets the minimum yaw angle that the bone can look to
  36694. */
  36695. minYaw: number;
  36696. /**
  36697. * Gets or sets the maximum yaw angle that the bone can look to
  36698. */
  36699. maxYaw: number;
  36700. /**
  36701. * Gets or sets the minimum pitch angle that the bone can look to
  36702. */
  36703. minPitch: number;
  36704. /**
  36705. * Gets or sets the maximum pitch angle that the bone can look to
  36706. */
  36707. maxPitch: number;
  36708. /**
  36709. * Create a BoneLookController
  36710. * @param mesh the mesh that the bone belongs to
  36711. * @param bone the bone that will be looking to the target
  36712. * @param target the target Vector3 to look at
  36713. * @param options optional settings:
  36714. * * maxYaw: the maximum angle the bone will yaw to
  36715. * * minYaw: the minimum angle the bone will yaw to
  36716. * * maxPitch: the maximum angle the bone will pitch to
  36717. * * minPitch: the minimum angle the bone will yaw to
  36718. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36719. * * upAxis: the up axis of the coordinate system
  36720. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36721. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36722. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36723. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36724. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36725. * * adjustRoll: used to make an adjustment to the roll of the bone
  36726. **/
  36727. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36728. maxYaw?: number;
  36729. minYaw?: number;
  36730. maxPitch?: number;
  36731. minPitch?: number;
  36732. slerpAmount?: number;
  36733. upAxis?: Vector3;
  36734. upAxisSpace?: Space;
  36735. yawAxis?: Vector3;
  36736. pitchAxis?: Vector3;
  36737. adjustYaw?: number;
  36738. adjustPitch?: number;
  36739. adjustRoll?: number;
  36740. });
  36741. /**
  36742. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36743. */
  36744. update(): void;
  36745. private _getAngleDiff;
  36746. private _getAngleBetween;
  36747. private _isAngleBetween;
  36748. }
  36749. }
  36750. declare module BABYLON {
  36751. /**
  36752. * Manage the gamepad inputs to control an arc rotate camera.
  36753. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36754. */
  36755. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36756. /**
  36757. * Defines the camera the input is attached to.
  36758. */
  36759. camera: ArcRotateCamera;
  36760. /**
  36761. * Defines the gamepad the input is gathering event from.
  36762. */
  36763. gamepad: Nullable<Gamepad>;
  36764. /**
  36765. * Defines the gamepad rotation sensiblity.
  36766. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36767. */
  36768. gamepadRotationSensibility: number;
  36769. /**
  36770. * Defines the gamepad move sensiblity.
  36771. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36772. */
  36773. gamepadMoveSensibility: number;
  36774. private _yAxisScale;
  36775. /**
  36776. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  36777. */
  36778. invertYAxis: boolean;
  36779. private _onGamepadConnectedObserver;
  36780. private _onGamepadDisconnectedObserver;
  36781. /**
  36782. * Attach the input controls to a specific dom element to get the input from.
  36783. * @param element Defines the element the controls should be listened from
  36784. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36785. */
  36786. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36787. /**
  36788. * Detach the current controls from the specified dom element.
  36789. * @param element Defines the element to stop listening the inputs from
  36790. */
  36791. detachControl(element: Nullable<HTMLElement>): void;
  36792. /**
  36793. * Update the current camera state depending on the inputs that have been used this frame.
  36794. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36795. */
  36796. checkInputs(): void;
  36797. /**
  36798. * Gets the class name of the current intput.
  36799. * @returns the class name
  36800. */
  36801. getClassName(): string;
  36802. /**
  36803. * Get the friendly name associated with the input class.
  36804. * @returns the input friendly name
  36805. */
  36806. getSimpleName(): string;
  36807. }
  36808. }
  36809. declare module BABYLON {
  36810. interface ArcRotateCameraInputsManager {
  36811. /**
  36812. * Add orientation input support to the input manager.
  36813. * @returns the current input manager
  36814. */
  36815. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36816. }
  36817. /**
  36818. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36819. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36820. */
  36821. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36822. /**
  36823. * Defines the camera the input is attached to.
  36824. */
  36825. camera: ArcRotateCamera;
  36826. /**
  36827. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36828. */
  36829. alphaCorrection: number;
  36830. /**
  36831. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36832. */
  36833. gammaCorrection: number;
  36834. private _alpha;
  36835. private _gamma;
  36836. private _dirty;
  36837. private _deviceOrientationHandler;
  36838. /**
  36839. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36840. */
  36841. constructor();
  36842. /**
  36843. * Attach the input controls to a specific dom element to get the input from.
  36844. * @param element Defines the element the controls should be listened from
  36845. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36846. */
  36847. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36848. /** @hidden */ private _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36849. /**
  36850. * Update the current camera state depending on the inputs that have been used this frame.
  36851. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36852. */
  36853. checkInputs(): void;
  36854. /**
  36855. * Detach the current controls from the specified dom element.
  36856. * @param element Defines the element to stop listening the inputs from
  36857. */
  36858. detachControl(element: Nullable<HTMLElement>): void;
  36859. /**
  36860. * Gets the class name of the current intput.
  36861. * @returns the class name
  36862. */
  36863. getClassName(): string;
  36864. /**
  36865. * Get the friendly name associated with the input class.
  36866. * @returns the input friendly name
  36867. */
  36868. getSimpleName(): string;
  36869. }
  36870. }
  36871. declare module BABYLON {
  36872. /**
  36873. * Listen to mouse events to control the camera.
  36874. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36875. */
  36876. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36877. /**
  36878. * Defines the camera the input is attached to.
  36879. */
  36880. camera: FlyCamera;
  36881. /**
  36882. * Defines if touch is enabled. (Default is true.)
  36883. */
  36884. touchEnabled: boolean;
  36885. /**
  36886. * Defines the buttons associated with the input to handle camera rotation.
  36887. */
  36888. buttons: number[];
  36889. /**
  36890. * Assign buttons for Yaw control.
  36891. */
  36892. buttonsYaw: number[];
  36893. /**
  36894. * Assign buttons for Pitch control.
  36895. */
  36896. buttonsPitch: number[];
  36897. /**
  36898. * Assign buttons for Roll control.
  36899. */
  36900. buttonsRoll: number[];
  36901. /**
  36902. * Detect if any button is being pressed while mouse is moved.
  36903. * -1 = Mouse locked.
  36904. * 0 = Left button.
  36905. * 1 = Middle Button.
  36906. * 2 = Right Button.
  36907. */
  36908. activeButton: number;
  36909. /**
  36910. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36911. * Higher values reduce its sensitivity.
  36912. */
  36913. angularSensibility: number;
  36914. private _mousemoveCallback;
  36915. private _observer;
  36916. private _rollObserver;
  36917. private previousPosition;
  36918. private noPreventDefault;
  36919. private element;
  36920. /**
  36921. * Listen to mouse events to control the camera.
  36922. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36923. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36924. */
  36925. constructor(touchEnabled?: boolean);
  36926. /**
  36927. * Attach the mouse control to the HTML DOM element.
  36928. * @param element Defines the element that listens to the input events.
  36929. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36930. */
  36931. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36932. /**
  36933. * Detach the current controls from the specified dom element.
  36934. * @param element Defines the element to stop listening the inputs from
  36935. */
  36936. detachControl(element: Nullable<HTMLElement>): void;
  36937. /**
  36938. * Gets the class name of the current input.
  36939. * @returns the class name.
  36940. */
  36941. getClassName(): string;
  36942. /**
  36943. * Get the friendly name associated with the input class.
  36944. * @returns the input's friendly name.
  36945. */
  36946. getSimpleName(): string;
  36947. private _pointerInput;
  36948. private _onMouseMove;
  36949. /**
  36950. * Rotate camera by mouse offset.
  36951. */
  36952. private rotateCamera;
  36953. }
  36954. }
  36955. declare module BABYLON {
  36956. /**
  36957. * Default Inputs manager for the FlyCamera.
  36958. * It groups all the default supported inputs for ease of use.
  36959. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36960. */
  36961. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36962. /**
  36963. * Instantiates a new FlyCameraInputsManager.
  36964. * @param camera Defines the camera the inputs belong to.
  36965. */
  36966. constructor(camera: FlyCamera);
  36967. /**
  36968. * Add keyboard input support to the input manager.
  36969. * @returns the new FlyCameraKeyboardMoveInput().
  36970. */
  36971. addKeyboard(): FlyCameraInputsManager;
  36972. /**
  36973. * Add mouse input support to the input manager.
  36974. * @param touchEnabled Enable touch screen support.
  36975. * @returns the new FlyCameraMouseInput().
  36976. */
  36977. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36978. }
  36979. }
  36980. declare module BABYLON {
  36981. /**
  36982. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36983. * such as in a 3D Space Shooter or a Flight Simulator.
  36984. */
  36985. export class FlyCamera extends TargetCamera {
  36986. /**
  36987. * Define the collision ellipsoid of the camera.
  36988. * This is helpful for simulating a camera body, like a player's body.
  36989. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36990. */
  36991. ellipsoid: Vector3;
  36992. /**
  36993. * Define an offset for the position of the ellipsoid around the camera.
  36994. * This can be helpful if the camera is attached away from the player's body center,
  36995. * such as at its head.
  36996. */
  36997. ellipsoidOffset: Vector3;
  36998. /**
  36999. * Enable or disable collisions of the camera with the rest of the scene objects.
  37000. */
  37001. checkCollisions: boolean;
  37002. /**
  37003. * Enable or disable gravity on the camera.
  37004. */
  37005. applyGravity: boolean;
  37006. /**
  37007. * Define the current direction the camera is moving to.
  37008. */
  37009. cameraDirection: Vector3;
  37010. /**
  37011. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37012. * This overrides and empties cameraRotation.
  37013. */
  37014. rotationQuaternion: Quaternion;
  37015. /**
  37016. * Track Roll to maintain the wanted Rolling when looking around.
  37017. */ private _trackRoll: number;
  37018. /**
  37019. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37020. */
  37021. rollCorrect: number;
  37022. /**
  37023. * Mimic a banked turn, Rolling the camera when Yawing.
  37024. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37025. */
  37026. bankedTurn: boolean;
  37027. /**
  37028. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37029. */
  37030. bankedTurnLimit: number;
  37031. /**
  37032. * Value of 0 disables the banked Roll.
  37033. * Value of 1 is equal to the Yaw angle in radians.
  37034. */
  37035. bankedTurnMultiplier: number;
  37036. /**
  37037. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37038. */
  37039. inputs: FlyCameraInputsManager;
  37040. /**
  37041. * Gets the input sensibility for mouse input.
  37042. * Higher values reduce sensitivity.
  37043. */
  37044. /**
  37045. * Sets the input sensibility for a mouse input.
  37046. * Higher values reduce sensitivity.
  37047. */
  37048. angularSensibility: number;
  37049. /**
  37050. * Get the keys for camera movement forward.
  37051. */
  37052. /**
  37053. * Set the keys for camera movement forward.
  37054. */
  37055. keysForward: number[];
  37056. /**
  37057. * Get the keys for camera movement backward.
  37058. */
  37059. keysBackward: number[];
  37060. /**
  37061. * Get the keys for camera movement up.
  37062. */
  37063. /**
  37064. * Set the keys for camera movement up.
  37065. */
  37066. keysUp: number[];
  37067. /**
  37068. * Get the keys for camera movement down.
  37069. */
  37070. /**
  37071. * Set the keys for camera movement down.
  37072. */
  37073. keysDown: number[];
  37074. /**
  37075. * Get the keys for camera movement left.
  37076. */
  37077. /**
  37078. * Set the keys for camera movement left.
  37079. */
  37080. keysLeft: number[];
  37081. /**
  37082. * Set the keys for camera movement right.
  37083. */
  37084. /**
  37085. * Set the keys for camera movement right.
  37086. */
  37087. keysRight: number[];
  37088. /**
  37089. * Event raised when the camera collides with a mesh in the scene.
  37090. */
  37091. onCollide: (collidedMesh: AbstractMesh) => void;
  37092. private _collider;
  37093. private _needMoveForGravity;
  37094. private _oldPosition;
  37095. private _diffPosition;
  37096. private _newPosition;
  37097. /** @hidden */ private _localDirection: Vector3;
  37098. /** @hidden */ private _transformedDirection: Vector3;
  37099. /**
  37100. * Instantiates a FlyCamera.
  37101. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37102. * such as in a 3D Space Shooter or a Flight Simulator.
  37103. * @param name Define the name of the camera in the scene.
  37104. * @param position Define the starting position of the camera in the scene.
  37105. * @param scene Define the scene the camera belongs to.
  37106. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37107. */
  37108. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37109. /**
  37110. * Attach a control to the HTML DOM element.
  37111. * @param element Defines the element that listens to the input events.
  37112. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37113. */
  37114. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37115. /**
  37116. * Detach a control from the HTML DOM element.
  37117. * The camera will stop reacting to that input.
  37118. * @param element Defines the element that listens to the input events.
  37119. */
  37120. detachControl(element: HTMLElement): void;
  37121. private _collisionMask;
  37122. /**
  37123. * Get the mask that the camera ignores in collision events.
  37124. */
  37125. /**
  37126. * Set the mask that the camera ignores in collision events.
  37127. */
  37128. collisionMask: number;
  37129. /** @hidden */ private _collideWithWorld(displacement: Vector3): void;
  37130. /** @hidden */
  37131. private _onCollisionPositionChange;
  37132. /** @hidden */ private _checkInputs(): void;
  37133. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  37134. /** @hidden */ private _updatePosition(): void;
  37135. /**
  37136. * Restore the Roll to its target value at the rate specified.
  37137. * @param rate - Higher means slower restoring.
  37138. * @hidden
  37139. */
  37140. restoreRoll(rate: number): void;
  37141. /**
  37142. * Destroy the camera and release the current resources held by it.
  37143. */
  37144. dispose(): void;
  37145. /**
  37146. * Get the current object class name.
  37147. * @returns the class name.
  37148. */
  37149. getClassName(): string;
  37150. }
  37151. }
  37152. declare module BABYLON {
  37153. /**
  37154. * Listen to keyboard events to control the camera.
  37155. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37156. */
  37157. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37158. /**
  37159. * Defines the camera the input is attached to.
  37160. */
  37161. camera: FlyCamera;
  37162. /**
  37163. * The list of keyboard keys used to control the forward move of the camera.
  37164. */
  37165. keysForward: number[];
  37166. /**
  37167. * The list of keyboard keys used to control the backward move of the camera.
  37168. */
  37169. keysBackward: number[];
  37170. /**
  37171. * The list of keyboard keys used to control the forward move of the camera.
  37172. */
  37173. keysUp: number[];
  37174. /**
  37175. * The list of keyboard keys used to control the backward move of the camera.
  37176. */
  37177. keysDown: number[];
  37178. /**
  37179. * The list of keyboard keys used to control the right strafe move of the camera.
  37180. */
  37181. keysRight: number[];
  37182. /**
  37183. * The list of keyboard keys used to control the left strafe move of the camera.
  37184. */
  37185. keysLeft: number[];
  37186. private _keys;
  37187. private _onCanvasBlurObserver;
  37188. private _onKeyboardObserver;
  37189. private _engine;
  37190. private _scene;
  37191. /**
  37192. * Attach the input controls to a specific dom element to get the input from.
  37193. * @param element Defines the element the controls should be listened from
  37194. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37195. */
  37196. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37197. /**
  37198. * Detach the current controls from the specified dom element.
  37199. * @param element Defines the element to stop listening the inputs from
  37200. */
  37201. detachControl(element: Nullable<HTMLElement>): void;
  37202. /**
  37203. * Gets the class name of the current intput.
  37204. * @returns the class name
  37205. */
  37206. getClassName(): string;
  37207. /** @hidden */ private _onLostFocus(e: FocusEvent): void;
  37208. /**
  37209. * Get the friendly name associated with the input class.
  37210. * @returns the input friendly name
  37211. */
  37212. getSimpleName(): string;
  37213. /**
  37214. * Update the current camera state depending on the inputs that have been used this frame.
  37215. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37216. */
  37217. checkInputs(): void;
  37218. }
  37219. }
  37220. declare module BABYLON {
  37221. /**
  37222. * Manage the mouse wheel inputs to control a follow camera.
  37223. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37224. */
  37225. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37226. /**
  37227. * Defines the camera the input is attached to.
  37228. */
  37229. camera: FollowCamera;
  37230. /**
  37231. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37232. */
  37233. axisControlRadius: boolean;
  37234. /**
  37235. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37236. */
  37237. axisControlHeight: boolean;
  37238. /**
  37239. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37240. */
  37241. axisControlRotation: boolean;
  37242. /**
  37243. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37244. * relation to mouseWheel events.
  37245. */
  37246. wheelPrecision: number;
  37247. /**
  37248. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37249. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37250. */
  37251. wheelDeltaPercentage: number;
  37252. private _wheel;
  37253. private _observer;
  37254. /**
  37255. * Attach the input controls to a specific dom element to get the input from.
  37256. * @param element Defines the element the controls should be listened from
  37257. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37258. */
  37259. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37260. /**
  37261. * Detach the current controls from the specified dom element.
  37262. * @param element Defines the element to stop listening the inputs from
  37263. */
  37264. detachControl(element: Nullable<HTMLElement>): void;
  37265. /**
  37266. * Gets the class name of the current intput.
  37267. * @returns the class name
  37268. */
  37269. getClassName(): string;
  37270. /**
  37271. * Get the friendly name associated with the input class.
  37272. * @returns the input friendly name
  37273. */
  37274. getSimpleName(): string;
  37275. }
  37276. }
  37277. declare module BABYLON {
  37278. /**
  37279. * Manage the pointers inputs to control an follow camera.
  37280. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37281. */
  37282. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37283. /**
  37284. * Defines the camera the input is attached to.
  37285. */
  37286. camera: FollowCamera;
  37287. /**
  37288. * Gets the class name of the current input.
  37289. * @returns the class name
  37290. */
  37291. getClassName(): string;
  37292. /**
  37293. * Defines the pointer angular sensibility along the X axis or how fast is
  37294. * the camera rotating.
  37295. * A negative number will reverse the axis direction.
  37296. */
  37297. angularSensibilityX: number;
  37298. /**
  37299. * Defines the pointer angular sensibility along the Y axis or how fast is
  37300. * the camera rotating.
  37301. * A negative number will reverse the axis direction.
  37302. */
  37303. angularSensibilityY: number;
  37304. /**
  37305. * Defines the pointer pinch precision or how fast is the camera zooming.
  37306. * A negative number will reverse the axis direction.
  37307. */
  37308. pinchPrecision: number;
  37309. /**
  37310. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37311. * from 0.
  37312. * It defines the percentage of current camera.radius to use as delta when
  37313. * pinch zoom is used.
  37314. */
  37315. pinchDeltaPercentage: number;
  37316. /**
  37317. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37318. */
  37319. axisXControlRadius: boolean;
  37320. /**
  37321. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37322. */
  37323. axisXControlHeight: boolean;
  37324. /**
  37325. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37326. */
  37327. axisXControlRotation: boolean;
  37328. /**
  37329. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37330. */
  37331. axisYControlRadius: boolean;
  37332. /**
  37333. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37334. */
  37335. axisYControlHeight: boolean;
  37336. /**
  37337. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37338. */
  37339. axisYControlRotation: boolean;
  37340. /**
  37341. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37342. */
  37343. axisPinchControlRadius: boolean;
  37344. /**
  37345. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37346. */
  37347. axisPinchControlHeight: boolean;
  37348. /**
  37349. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37350. */
  37351. axisPinchControlRotation: boolean;
  37352. /**
  37353. * Log error messages if basic misconfiguration has occurred.
  37354. */
  37355. warningEnable: boolean;
  37356. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37357. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37358. private _warningCounter;
  37359. private _warning;
  37360. }
  37361. }
  37362. declare module BABYLON {
  37363. /**
  37364. * Default Inputs manager for the FollowCamera.
  37365. * It groups all the default supported inputs for ease of use.
  37366. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37367. */
  37368. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37369. /**
  37370. * Instantiates a new FollowCameraInputsManager.
  37371. * @param camera Defines the camera the inputs belong to
  37372. */
  37373. constructor(camera: FollowCamera);
  37374. /**
  37375. * Add keyboard input support to the input manager.
  37376. * @returns the current input manager
  37377. */
  37378. addKeyboard(): FollowCameraInputsManager;
  37379. /**
  37380. * Add mouse wheel input support to the input manager.
  37381. * @returns the current input manager
  37382. */
  37383. addMouseWheel(): FollowCameraInputsManager;
  37384. /**
  37385. * Add pointers input support to the input manager.
  37386. * @returns the current input manager
  37387. */
  37388. addPointers(): FollowCameraInputsManager;
  37389. /**
  37390. * Add orientation input support to the input manager.
  37391. * @returns the current input manager
  37392. */
  37393. addVRDeviceOrientation(): FollowCameraInputsManager;
  37394. }
  37395. }
  37396. declare module BABYLON {
  37397. /**
  37398. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37399. * an arc rotate version arcFollowCamera are available.
  37400. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37401. */
  37402. export class FollowCamera extends TargetCamera {
  37403. /**
  37404. * Distance the follow camera should follow an object at
  37405. */
  37406. radius: number;
  37407. /**
  37408. * Minimum allowed distance of the camera to the axis of rotation
  37409. * (The camera can not get closer).
  37410. * This can help limiting how the Camera is able to move in the scene.
  37411. */
  37412. lowerRadiusLimit: Nullable<number>;
  37413. /**
  37414. * Maximum allowed distance of the camera to the axis of rotation
  37415. * (The camera can not get further).
  37416. * This can help limiting how the Camera is able to move in the scene.
  37417. */
  37418. upperRadiusLimit: Nullable<number>;
  37419. /**
  37420. * Define a rotation offset between the camera and the object it follows
  37421. */
  37422. rotationOffset: number;
  37423. /**
  37424. * Minimum allowed angle to camera position relative to target object.
  37425. * This can help limiting how the Camera is able to move in the scene.
  37426. */
  37427. lowerRotationOffsetLimit: Nullable<number>;
  37428. /**
  37429. * Maximum allowed angle to camera position relative to target object.
  37430. * This can help limiting how the Camera is able to move in the scene.
  37431. */
  37432. upperRotationOffsetLimit: Nullable<number>;
  37433. /**
  37434. * Define a height offset between the camera and the object it follows.
  37435. * It can help following an object from the top (like a car chaing a plane)
  37436. */
  37437. heightOffset: number;
  37438. /**
  37439. * Minimum allowed height of camera position relative to target object.
  37440. * This can help limiting how the Camera is able to move in the scene.
  37441. */
  37442. lowerHeightOffsetLimit: Nullable<number>;
  37443. /**
  37444. * Maximum allowed height of camera position relative to target object.
  37445. * This can help limiting how the Camera is able to move in the scene.
  37446. */
  37447. upperHeightOffsetLimit: Nullable<number>;
  37448. /**
  37449. * Define how fast the camera can accelerate to follow it s target.
  37450. */
  37451. cameraAcceleration: number;
  37452. /**
  37453. * Define the speed limit of the camera following an object.
  37454. */
  37455. maxCameraSpeed: number;
  37456. /**
  37457. * Define the target of the camera.
  37458. */
  37459. lockedTarget: Nullable<AbstractMesh>;
  37460. /**
  37461. * Defines the input associated with the camera.
  37462. */
  37463. inputs: FollowCameraInputsManager;
  37464. /**
  37465. * Instantiates the follow camera.
  37466. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37467. * @param name Define the name of the camera in the scene
  37468. * @param position Define the position of the camera
  37469. * @param scene Define the scene the camera belong to
  37470. * @param lockedTarget Define the target of the camera
  37471. */
  37472. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37473. private _follow;
  37474. /**
  37475. * Attached controls to the current camera.
  37476. * @param element Defines the element the controls should be listened from
  37477. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37478. */
  37479. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37480. /**
  37481. * Detach the current controls from the camera.
  37482. * The camera will stop reacting to inputs.
  37483. * @param element Defines the element to stop listening the inputs from
  37484. */
  37485. detachControl(element: HTMLElement): void;
  37486. /** @hidden */ private _checkInputs(): void;
  37487. private _checkLimits;
  37488. /**
  37489. * Gets the camera class name.
  37490. * @returns the class name
  37491. */
  37492. getClassName(): string;
  37493. }
  37494. /**
  37495. * Arc Rotate version of the follow camera.
  37496. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37497. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37498. */
  37499. export class ArcFollowCamera extends TargetCamera {
  37500. /** The longitudinal angle of the camera */
  37501. alpha: number;
  37502. /** The latitudinal angle of the camera */
  37503. beta: number;
  37504. /** The radius of the camera from its target */
  37505. radius: number;
  37506. /** Define the camera target (the messh it should follow) */
  37507. target: Nullable<AbstractMesh>;
  37508. private _cartesianCoordinates;
  37509. /**
  37510. * Instantiates a new ArcFollowCamera
  37511. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37512. * @param name Define the name of the camera
  37513. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37514. * @param beta Define the rotation angle of the camera around the elevation axis
  37515. * @param radius Define the radius of the camera from its target point
  37516. * @param target Define the target of the camera
  37517. * @param scene Define the scene the camera belongs to
  37518. */
  37519. constructor(name: string,
  37520. /** The longitudinal angle of the camera */
  37521. alpha: number,
  37522. /** The latitudinal angle of the camera */
  37523. beta: number,
  37524. /** The radius of the camera from its target */
  37525. radius: number,
  37526. /** Define the camera target (the messh it should follow) */
  37527. target: Nullable<AbstractMesh>, scene: Scene);
  37528. private _follow;
  37529. /** @hidden */ private _checkInputs(): void;
  37530. /**
  37531. * Returns the class name of the object.
  37532. * It is mostly used internally for serialization purposes.
  37533. */
  37534. getClassName(): string;
  37535. }
  37536. }
  37537. declare module BABYLON {
  37538. /**
  37539. * Manage the keyboard inputs to control the movement of a follow camera.
  37540. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37541. */
  37542. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37543. /**
  37544. * Defines the camera the input is attached to.
  37545. */
  37546. camera: FollowCamera;
  37547. /**
  37548. * Defines the list of key codes associated with the up action (increase heightOffset)
  37549. */
  37550. keysHeightOffsetIncr: number[];
  37551. /**
  37552. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37553. */
  37554. keysHeightOffsetDecr: number[];
  37555. /**
  37556. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37557. */
  37558. keysHeightOffsetModifierAlt: boolean;
  37559. /**
  37560. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37561. */
  37562. keysHeightOffsetModifierCtrl: boolean;
  37563. /**
  37564. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37565. */
  37566. keysHeightOffsetModifierShift: boolean;
  37567. /**
  37568. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37569. */
  37570. keysRotationOffsetIncr: number[];
  37571. /**
  37572. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37573. */
  37574. keysRotationOffsetDecr: number[];
  37575. /**
  37576. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37577. */
  37578. keysRotationOffsetModifierAlt: boolean;
  37579. /**
  37580. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37581. */
  37582. keysRotationOffsetModifierCtrl: boolean;
  37583. /**
  37584. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37585. */
  37586. keysRotationOffsetModifierShift: boolean;
  37587. /**
  37588. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37589. */
  37590. keysRadiusIncr: number[];
  37591. /**
  37592. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37593. */
  37594. keysRadiusDecr: number[];
  37595. /**
  37596. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37597. */
  37598. keysRadiusModifierAlt: boolean;
  37599. /**
  37600. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37601. */
  37602. keysRadiusModifierCtrl: boolean;
  37603. /**
  37604. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37605. */
  37606. keysRadiusModifierShift: boolean;
  37607. /**
  37608. * Defines the rate of change of heightOffset.
  37609. */
  37610. heightSensibility: number;
  37611. /**
  37612. * Defines the rate of change of rotationOffset.
  37613. */
  37614. rotationSensibility: number;
  37615. /**
  37616. * Defines the rate of change of radius.
  37617. */
  37618. radiusSensibility: number;
  37619. private _keys;
  37620. private _ctrlPressed;
  37621. private _altPressed;
  37622. private _shiftPressed;
  37623. private _onCanvasBlurObserver;
  37624. private _onKeyboardObserver;
  37625. private _engine;
  37626. private _scene;
  37627. /**
  37628. * Attach the input controls to a specific dom element to get the input from.
  37629. * @param element Defines the element the controls should be listened from
  37630. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37631. */
  37632. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37633. /**
  37634. * Detach the current controls from the specified dom element.
  37635. * @param element Defines the element to stop listening the inputs from
  37636. */
  37637. detachControl(element: Nullable<HTMLElement>): void;
  37638. /**
  37639. * Update the current camera state depending on the inputs that have been used this frame.
  37640. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37641. */
  37642. checkInputs(): void;
  37643. /**
  37644. * Gets the class name of the current input.
  37645. * @returns the class name
  37646. */
  37647. getClassName(): string;
  37648. /**
  37649. * Get the friendly name associated with the input class.
  37650. * @returns the input friendly name
  37651. */
  37652. getSimpleName(): string;
  37653. /**
  37654. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37655. * allow modification of the heightOffset value.
  37656. */
  37657. private _modifierHeightOffset;
  37658. /**
  37659. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37660. * allow modification of the rotationOffset value.
  37661. */
  37662. private _modifierRotationOffset;
  37663. /**
  37664. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37665. * allow modification of the radius value.
  37666. */
  37667. private _modifierRadius;
  37668. }
  37669. }
  37670. declare module BABYLON {
  37671. interface FreeCameraInputsManager {
  37672. /**
  37673. * @hidden
  37674. */ private _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37675. /**
  37676. * Add orientation input support to the input manager.
  37677. * @returns the current input manager
  37678. */
  37679. addDeviceOrientation(): FreeCameraInputsManager;
  37680. }
  37681. /**
  37682. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37683. * Screen rotation is taken into account.
  37684. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37685. */
  37686. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37687. private _camera;
  37688. private _screenOrientationAngle;
  37689. private _constantTranform;
  37690. private _screenQuaternion;
  37691. private _alpha;
  37692. private _beta;
  37693. private _gamma;
  37694. /**
  37695. * Can be used to detect if a device orientation sensor is availible on a device
  37696. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  37697. * @returns a promise that will resolve on orientation change
  37698. */
  37699. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  37700. /**
  37701. * @hidden
  37702. */ private _onDeviceOrientationChangedObservable: Observable<void>;
  37703. /**
  37704. * Instantiates a new input
  37705. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37706. */
  37707. constructor();
  37708. /**
  37709. * Define the camera controlled by the input.
  37710. */
  37711. camera: FreeCamera;
  37712. /**
  37713. * Attach the input controls to a specific dom element to get the input from.
  37714. * @param element Defines the element the controls should be listened from
  37715. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37716. */
  37717. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37718. private _orientationChanged;
  37719. private _deviceOrientation;
  37720. /**
  37721. * Detach the current controls from the specified dom element.
  37722. * @param element Defines the element to stop listening the inputs from
  37723. */
  37724. detachControl(element: Nullable<HTMLElement>): void;
  37725. /**
  37726. * Update the current camera state depending on the inputs that have been used this frame.
  37727. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37728. */
  37729. checkInputs(): void;
  37730. /**
  37731. * Gets the class name of the current intput.
  37732. * @returns the class name
  37733. */
  37734. getClassName(): string;
  37735. /**
  37736. * Get the friendly name associated with the input class.
  37737. * @returns the input friendly name
  37738. */
  37739. getSimpleName(): string;
  37740. }
  37741. }
  37742. declare module BABYLON {
  37743. /**
  37744. * Manage the gamepad inputs to control a free camera.
  37745. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37746. */
  37747. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37748. /**
  37749. * Define the camera the input is attached to.
  37750. */
  37751. camera: FreeCamera;
  37752. /**
  37753. * Define the Gamepad controlling the input
  37754. */
  37755. gamepad: Nullable<Gamepad>;
  37756. /**
  37757. * Defines the gamepad rotation sensiblity.
  37758. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37759. */
  37760. gamepadAngularSensibility: number;
  37761. /**
  37762. * Defines the gamepad move sensiblity.
  37763. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37764. */
  37765. gamepadMoveSensibility: number;
  37766. private _yAxisScale;
  37767. /**
  37768. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  37769. */
  37770. invertYAxis: boolean;
  37771. private _onGamepadConnectedObserver;
  37772. private _onGamepadDisconnectedObserver;
  37773. private _cameraTransform;
  37774. private _deltaTransform;
  37775. private _vector3;
  37776. private _vector2;
  37777. /**
  37778. * Attach the input controls to a specific dom element to get the input from.
  37779. * @param element Defines the element the controls should be listened from
  37780. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37781. */
  37782. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37783. /**
  37784. * Detach the current controls from the specified dom element.
  37785. * @param element Defines the element to stop listening the inputs from
  37786. */
  37787. detachControl(element: Nullable<HTMLElement>): void;
  37788. /**
  37789. * Update the current camera state depending on the inputs that have been used this frame.
  37790. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37791. */
  37792. checkInputs(): void;
  37793. /**
  37794. * Gets the class name of the current intput.
  37795. * @returns the class name
  37796. */
  37797. getClassName(): string;
  37798. /**
  37799. * Get the friendly name associated with the input class.
  37800. * @returns the input friendly name
  37801. */
  37802. getSimpleName(): string;
  37803. }
  37804. }
  37805. declare module BABYLON {
  37806. /**
  37807. * Defines the potential axis of a Joystick
  37808. */
  37809. export enum JoystickAxis {
  37810. /** X axis */
  37811. X = 0,
  37812. /** Y axis */
  37813. Y = 1,
  37814. /** Z axis */
  37815. Z = 2
  37816. }
  37817. /**
  37818. * Class used to define virtual joystick (used in touch mode)
  37819. */
  37820. export class VirtualJoystick {
  37821. /**
  37822. * Gets or sets a boolean indicating that left and right values must be inverted
  37823. */
  37824. reverseLeftRight: boolean;
  37825. /**
  37826. * Gets or sets a boolean indicating that up and down values must be inverted
  37827. */
  37828. reverseUpDown: boolean;
  37829. /**
  37830. * Gets the offset value for the position (ie. the change of the position value)
  37831. */
  37832. deltaPosition: Vector3;
  37833. /**
  37834. * Gets a boolean indicating if the virtual joystick was pressed
  37835. */
  37836. pressed: boolean;
  37837. /**
  37838. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37839. */
  37840. static Canvas: Nullable<HTMLCanvasElement>;
  37841. private static _globalJoystickIndex;
  37842. private static vjCanvasContext;
  37843. private static vjCanvasWidth;
  37844. private static vjCanvasHeight;
  37845. private static halfWidth;
  37846. private _action;
  37847. private _axisTargetedByLeftAndRight;
  37848. private _axisTargetedByUpAndDown;
  37849. private _joystickSensibility;
  37850. private _inversedSensibility;
  37851. private _joystickPointerID;
  37852. private _joystickColor;
  37853. private _joystickPointerPos;
  37854. private _joystickPreviousPointerPos;
  37855. private _joystickPointerStartPos;
  37856. private _deltaJoystickVector;
  37857. private _leftJoystick;
  37858. private _touches;
  37859. private _onPointerDownHandlerRef;
  37860. private _onPointerMoveHandlerRef;
  37861. private _onPointerUpHandlerRef;
  37862. private _onResize;
  37863. /**
  37864. * Creates a new virtual joystick
  37865. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37866. */
  37867. constructor(leftJoystick?: boolean);
  37868. /**
  37869. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37870. * @param newJoystickSensibility defines the new sensibility
  37871. */
  37872. setJoystickSensibility(newJoystickSensibility: number): void;
  37873. private _onPointerDown;
  37874. private _onPointerMove;
  37875. private _onPointerUp;
  37876. /**
  37877. * Change the color of the virtual joystick
  37878. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37879. */
  37880. setJoystickColor(newColor: string): void;
  37881. /**
  37882. * Defines a callback to call when the joystick is touched
  37883. * @param action defines the callback
  37884. */
  37885. setActionOnTouch(action: () => any): void;
  37886. /**
  37887. * Defines which axis you'd like to control for left & right
  37888. * @param axis defines the axis to use
  37889. */
  37890. setAxisForLeftRight(axis: JoystickAxis): void;
  37891. /**
  37892. * Defines which axis you'd like to control for up & down
  37893. * @param axis defines the axis to use
  37894. */
  37895. setAxisForUpDown(axis: JoystickAxis): void;
  37896. private _drawVirtualJoystick;
  37897. /**
  37898. * Release internal HTML canvas
  37899. */
  37900. releaseCanvas(): void;
  37901. }
  37902. }
  37903. declare module BABYLON {
  37904. interface FreeCameraInputsManager {
  37905. /**
  37906. * Add virtual joystick input support to the input manager.
  37907. * @returns the current input manager
  37908. */
  37909. addVirtualJoystick(): FreeCameraInputsManager;
  37910. }
  37911. /**
  37912. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37913. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37914. */
  37915. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37916. /**
  37917. * Defines the camera the input is attached to.
  37918. */
  37919. camera: FreeCamera;
  37920. private _leftjoystick;
  37921. private _rightjoystick;
  37922. /**
  37923. * Gets the left stick of the virtual joystick.
  37924. * @returns The virtual Joystick
  37925. */
  37926. getLeftJoystick(): VirtualJoystick;
  37927. /**
  37928. * Gets the right stick of the virtual joystick.
  37929. * @returns The virtual Joystick
  37930. */
  37931. getRightJoystick(): VirtualJoystick;
  37932. /**
  37933. * Update the current camera state depending on the inputs that have been used this frame.
  37934. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37935. */
  37936. checkInputs(): void;
  37937. /**
  37938. * Attach the input controls to a specific dom element to get the input from.
  37939. * @param element Defines the element the controls should be listened from
  37940. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37941. */
  37942. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37943. /**
  37944. * Detach the current controls from the specified dom element.
  37945. * @param element Defines the element to stop listening the inputs from
  37946. */
  37947. detachControl(element: Nullable<HTMLElement>): void;
  37948. /**
  37949. * Gets the class name of the current intput.
  37950. * @returns the class name
  37951. */
  37952. getClassName(): string;
  37953. /**
  37954. * Get the friendly name associated with the input class.
  37955. * @returns the input friendly name
  37956. */
  37957. getSimpleName(): string;
  37958. }
  37959. }
  37960. declare module BABYLON {
  37961. /**
  37962. * This represents a FPS type of camera controlled by touch.
  37963. * This is like a universal camera minus the Gamepad controls.
  37964. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37965. */
  37966. export class TouchCamera extends FreeCamera {
  37967. /**
  37968. * Defines the touch sensibility for rotation.
  37969. * The higher the faster.
  37970. */
  37971. touchAngularSensibility: number;
  37972. /**
  37973. * Defines the touch sensibility for move.
  37974. * The higher the faster.
  37975. */
  37976. touchMoveSensibility: number;
  37977. /**
  37978. * Instantiates a new touch camera.
  37979. * This represents a FPS type of camera controlled by touch.
  37980. * This is like a universal camera minus the Gamepad controls.
  37981. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37982. * @param name Define the name of the camera in the scene
  37983. * @param position Define the start position of the camera in the scene
  37984. * @param scene Define the scene the camera belongs to
  37985. */
  37986. constructor(name: string, position: Vector3, scene: Scene);
  37987. /**
  37988. * Gets the current object class name.
  37989. * @return the class name
  37990. */
  37991. getClassName(): string;
  37992. /** @hidden */ private _setupInputs(): void;
  37993. }
  37994. }
  37995. declare module BABYLON {
  37996. /**
  37997. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37998. * being tilted forward or back and left or right.
  37999. */
  38000. export class DeviceOrientationCamera extends FreeCamera {
  38001. private _initialQuaternion;
  38002. private _quaternionCache;
  38003. private _tmpDragQuaternion;
  38004. private _disablePointerInputWhenUsingDeviceOrientation;
  38005. /**
  38006. * Creates a new device orientation camera
  38007. * @param name The name of the camera
  38008. * @param position The start position camera
  38009. * @param scene The scene the camera belongs to
  38010. */
  38011. constructor(name: string, position: Vector3, scene: Scene);
  38012. /**
  38013. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  38014. */
  38015. disablePointerInputWhenUsingDeviceOrientation: boolean;
  38016. private _dragFactor;
  38017. /**
  38018. * Enabled turning on the y axis when the orientation sensor is active
  38019. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38020. */
  38021. enableHorizontalDragging(dragFactor?: number): void;
  38022. /**
  38023. * Gets the current instance class name ("DeviceOrientationCamera").
  38024. * This helps avoiding instanceof at run time.
  38025. * @returns the class name
  38026. */
  38027. getClassName(): string;
  38028. /**
  38029. * @hidden
  38030. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38031. */ private _checkInputs(): void;
  38032. /**
  38033. * Reset the camera to its default orientation on the specified axis only.
  38034. * @param axis The axis to reset
  38035. */
  38036. resetToCurrentRotation(axis?: Axis): void;
  38037. }
  38038. }
  38039. declare module BABYLON {
  38040. /**
  38041. * Defines supported buttons for XBox360 compatible gamepads
  38042. */
  38043. export enum Xbox360Button {
  38044. /** A */
  38045. A = 0,
  38046. /** B */
  38047. B = 1,
  38048. /** X */
  38049. X = 2,
  38050. /** Y */
  38051. Y = 3,
  38052. /** Start */
  38053. Start = 4,
  38054. /** Back */
  38055. Back = 5,
  38056. /** Left button */
  38057. LB = 6,
  38058. /** Right button */
  38059. RB = 7,
  38060. /** Left stick */
  38061. LeftStick = 8,
  38062. /** Right stick */
  38063. RightStick = 9
  38064. }
  38065. /** Defines values for XBox360 DPad */
  38066. export enum Xbox360Dpad {
  38067. /** Up */
  38068. Up = 0,
  38069. /** Down */
  38070. Down = 1,
  38071. /** Left */
  38072. Left = 2,
  38073. /** Right */
  38074. Right = 3
  38075. }
  38076. /**
  38077. * Defines a XBox360 gamepad
  38078. */
  38079. export class Xbox360Pad extends Gamepad {
  38080. private _leftTrigger;
  38081. private _rightTrigger;
  38082. private _onlefttriggerchanged;
  38083. private _onrighttriggerchanged;
  38084. private _onbuttondown;
  38085. private _onbuttonup;
  38086. private _ondpaddown;
  38087. private _ondpadup;
  38088. /** Observable raised when a button is pressed */
  38089. onButtonDownObservable: Observable<Xbox360Button>;
  38090. /** Observable raised when a button is released */
  38091. onButtonUpObservable: Observable<Xbox360Button>;
  38092. /** Observable raised when a pad is pressed */
  38093. onPadDownObservable: Observable<Xbox360Dpad>;
  38094. /** Observable raised when a pad is released */
  38095. onPadUpObservable: Observable<Xbox360Dpad>;
  38096. private _buttonA;
  38097. private _buttonB;
  38098. private _buttonX;
  38099. private _buttonY;
  38100. private _buttonBack;
  38101. private _buttonStart;
  38102. private _buttonLB;
  38103. private _buttonRB;
  38104. private _buttonLeftStick;
  38105. private _buttonRightStick;
  38106. private _dPadUp;
  38107. private _dPadDown;
  38108. private _dPadLeft;
  38109. private _dPadRight;
  38110. private _isXboxOnePad;
  38111. /**
  38112. * Creates a new XBox360 gamepad object
  38113. * @param id defines the id of this gamepad
  38114. * @param index defines its index
  38115. * @param gamepad defines the internal HTML gamepad object
  38116. * @param xboxOne defines if it is a XBox One gamepad
  38117. */
  38118. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38119. /**
  38120. * Defines the callback to call when left trigger is pressed
  38121. * @param callback defines the callback to use
  38122. */
  38123. onlefttriggerchanged(callback: (value: number) => void): void;
  38124. /**
  38125. * Defines the callback to call when right trigger is pressed
  38126. * @param callback defines the callback to use
  38127. */
  38128. onrighttriggerchanged(callback: (value: number) => void): void;
  38129. /**
  38130. * Gets the left trigger value
  38131. */
  38132. /**
  38133. * Sets the left trigger value
  38134. */
  38135. leftTrigger: number;
  38136. /**
  38137. * Gets the right trigger value
  38138. */
  38139. /**
  38140. * Sets the right trigger value
  38141. */
  38142. rightTrigger: number;
  38143. /**
  38144. * Defines the callback to call when a button is pressed
  38145. * @param callback defines the callback to use
  38146. */
  38147. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38148. /**
  38149. * Defines the callback to call when a button is released
  38150. * @param callback defines the callback to use
  38151. */
  38152. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38153. /**
  38154. * Defines the callback to call when a pad is pressed
  38155. * @param callback defines the callback to use
  38156. */
  38157. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38158. /**
  38159. * Defines the callback to call when a pad is released
  38160. * @param callback defines the callback to use
  38161. */
  38162. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38163. private _setButtonValue;
  38164. private _setDPadValue;
  38165. /**
  38166. * Gets the value of the `A` button
  38167. */
  38168. /**
  38169. * Sets the value of the `A` button
  38170. */
  38171. buttonA: number;
  38172. /**
  38173. * Gets the value of the `B` button
  38174. */
  38175. /**
  38176. * Sets the value of the `B` button
  38177. */
  38178. buttonB: number;
  38179. /**
  38180. * Gets the value of the `X` button
  38181. */
  38182. /**
  38183. * Sets the value of the `X` button
  38184. */
  38185. buttonX: number;
  38186. /**
  38187. * Gets the value of the `Y` button
  38188. */
  38189. /**
  38190. * Sets the value of the `Y` button
  38191. */
  38192. buttonY: number;
  38193. /**
  38194. * Gets the value of the `Start` button
  38195. */
  38196. /**
  38197. * Sets the value of the `Start` button
  38198. */
  38199. buttonStart: number;
  38200. /**
  38201. * Gets the value of the `Back` button
  38202. */
  38203. /**
  38204. * Sets the value of the `Back` button
  38205. */
  38206. buttonBack: number;
  38207. /**
  38208. * Gets the value of the `Left` button
  38209. */
  38210. /**
  38211. * Sets the value of the `Left` button
  38212. */
  38213. buttonLB: number;
  38214. /**
  38215. * Gets the value of the `Right` button
  38216. */
  38217. /**
  38218. * Sets the value of the `Right` button
  38219. */
  38220. buttonRB: number;
  38221. /**
  38222. * Gets the value of the Left joystick
  38223. */
  38224. /**
  38225. * Sets the value of the Left joystick
  38226. */
  38227. buttonLeftStick: number;
  38228. /**
  38229. * Gets the value of the Right joystick
  38230. */
  38231. /**
  38232. * Sets the value of the Right joystick
  38233. */
  38234. buttonRightStick: number;
  38235. /**
  38236. * Gets the value of D-pad up
  38237. */
  38238. /**
  38239. * Sets the value of D-pad up
  38240. */
  38241. dPadUp: number;
  38242. /**
  38243. * Gets the value of D-pad down
  38244. */
  38245. /**
  38246. * Sets the value of D-pad down
  38247. */
  38248. dPadDown: number;
  38249. /**
  38250. * Gets the value of D-pad left
  38251. */
  38252. /**
  38253. * Sets the value of D-pad left
  38254. */
  38255. dPadLeft: number;
  38256. /**
  38257. * Gets the value of D-pad right
  38258. */
  38259. /**
  38260. * Sets the value of D-pad right
  38261. */
  38262. dPadRight: number;
  38263. /**
  38264. * Force the gamepad to synchronize with device values
  38265. */
  38266. update(): void;
  38267. /**
  38268. * Disposes the gamepad
  38269. */
  38270. dispose(): void;
  38271. }
  38272. }
  38273. declare module BABYLON {
  38274. /**
  38275. * Defines supported buttons for DualShock compatible gamepads
  38276. */
  38277. export enum DualShockButton {
  38278. /** Cross */
  38279. Cross = 0,
  38280. /** Circle */
  38281. Circle = 1,
  38282. /** Square */
  38283. Square = 2,
  38284. /** Triangle */
  38285. Triangle = 3,
  38286. /** Options */
  38287. Options = 4,
  38288. /** Share */
  38289. Share = 5,
  38290. /** L1 */
  38291. L1 = 6,
  38292. /** R1 */
  38293. R1 = 7,
  38294. /** Left stick */
  38295. LeftStick = 8,
  38296. /** Right stick */
  38297. RightStick = 9
  38298. }
  38299. /** Defines values for DualShock DPad */
  38300. export enum DualShockDpad {
  38301. /** Up */
  38302. Up = 0,
  38303. /** Down */
  38304. Down = 1,
  38305. /** Left */
  38306. Left = 2,
  38307. /** Right */
  38308. Right = 3
  38309. }
  38310. /**
  38311. * Defines a DualShock gamepad
  38312. */
  38313. export class DualShockPad extends Gamepad {
  38314. private _leftTrigger;
  38315. private _rightTrigger;
  38316. private _onlefttriggerchanged;
  38317. private _onrighttriggerchanged;
  38318. private _onbuttondown;
  38319. private _onbuttonup;
  38320. private _ondpaddown;
  38321. private _ondpadup;
  38322. /** Observable raised when a button is pressed */
  38323. onButtonDownObservable: Observable<DualShockButton>;
  38324. /** Observable raised when a button is released */
  38325. onButtonUpObservable: Observable<DualShockButton>;
  38326. /** Observable raised when a pad is pressed */
  38327. onPadDownObservable: Observable<DualShockDpad>;
  38328. /** Observable raised when a pad is released */
  38329. onPadUpObservable: Observable<DualShockDpad>;
  38330. private _buttonCross;
  38331. private _buttonCircle;
  38332. private _buttonSquare;
  38333. private _buttonTriangle;
  38334. private _buttonShare;
  38335. private _buttonOptions;
  38336. private _buttonL1;
  38337. private _buttonR1;
  38338. private _buttonLeftStick;
  38339. private _buttonRightStick;
  38340. private _dPadUp;
  38341. private _dPadDown;
  38342. private _dPadLeft;
  38343. private _dPadRight;
  38344. /**
  38345. * Creates a new DualShock gamepad object
  38346. * @param id defines the id of this gamepad
  38347. * @param index defines its index
  38348. * @param gamepad defines the internal HTML gamepad object
  38349. */
  38350. constructor(id: string, index: number, gamepad: any);
  38351. /**
  38352. * Defines the callback to call when left trigger is pressed
  38353. * @param callback defines the callback to use
  38354. */
  38355. onlefttriggerchanged(callback: (value: number) => void): void;
  38356. /**
  38357. * Defines the callback to call when right trigger is pressed
  38358. * @param callback defines the callback to use
  38359. */
  38360. onrighttriggerchanged(callback: (value: number) => void): void;
  38361. /**
  38362. * Gets the left trigger value
  38363. */
  38364. /**
  38365. * Sets the left trigger value
  38366. */
  38367. leftTrigger: number;
  38368. /**
  38369. * Gets the right trigger value
  38370. */
  38371. /**
  38372. * Sets the right trigger value
  38373. */
  38374. rightTrigger: number;
  38375. /**
  38376. * Defines the callback to call when a button is pressed
  38377. * @param callback defines the callback to use
  38378. */
  38379. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  38380. /**
  38381. * Defines the callback to call when a button is released
  38382. * @param callback defines the callback to use
  38383. */
  38384. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  38385. /**
  38386. * Defines the callback to call when a pad is pressed
  38387. * @param callback defines the callback to use
  38388. */
  38389. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  38390. /**
  38391. * Defines the callback to call when a pad is released
  38392. * @param callback defines the callback to use
  38393. */
  38394. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  38395. private _setButtonValue;
  38396. private _setDPadValue;
  38397. /**
  38398. * Gets the value of the `Cross` button
  38399. */
  38400. /**
  38401. * Sets the value of the `Cross` button
  38402. */
  38403. buttonCross: number;
  38404. /**
  38405. * Gets the value of the `Circle` button
  38406. */
  38407. /**
  38408. * Sets the value of the `Circle` button
  38409. */
  38410. buttonCircle: number;
  38411. /**
  38412. * Gets the value of the `Square` button
  38413. */
  38414. /**
  38415. * Sets the value of the `Square` button
  38416. */
  38417. buttonSquare: number;
  38418. /**
  38419. * Gets the value of the `Triangle` button
  38420. */
  38421. /**
  38422. * Sets the value of the `Triangle` button
  38423. */
  38424. buttonTriangle: number;
  38425. /**
  38426. * Gets the value of the `Options` button
  38427. */
  38428. /**
  38429. * Sets the value of the `Options` button
  38430. */
  38431. buttonOptions: number;
  38432. /**
  38433. * Gets the value of the `Share` button
  38434. */
  38435. /**
  38436. * Sets the value of the `Share` button
  38437. */
  38438. buttonShare: number;
  38439. /**
  38440. * Gets the value of the `L1` button
  38441. */
  38442. /**
  38443. * Sets the value of the `L1` button
  38444. */
  38445. buttonL1: number;
  38446. /**
  38447. * Gets the value of the `R1` button
  38448. */
  38449. /**
  38450. * Sets the value of the `R1` button
  38451. */
  38452. buttonR1: number;
  38453. /**
  38454. * Gets the value of the Left joystick
  38455. */
  38456. /**
  38457. * Sets the value of the Left joystick
  38458. */
  38459. buttonLeftStick: number;
  38460. /**
  38461. * Gets the value of the Right joystick
  38462. */
  38463. /**
  38464. * Sets the value of the Right joystick
  38465. */
  38466. buttonRightStick: number;
  38467. /**
  38468. * Gets the value of D-pad up
  38469. */
  38470. /**
  38471. * Sets the value of D-pad up
  38472. */
  38473. dPadUp: number;
  38474. /**
  38475. * Gets the value of D-pad down
  38476. */
  38477. /**
  38478. * Sets the value of D-pad down
  38479. */
  38480. dPadDown: number;
  38481. /**
  38482. * Gets the value of D-pad left
  38483. */
  38484. /**
  38485. * Sets the value of D-pad left
  38486. */
  38487. dPadLeft: number;
  38488. /**
  38489. * Gets the value of D-pad right
  38490. */
  38491. /**
  38492. * Sets the value of D-pad right
  38493. */
  38494. dPadRight: number;
  38495. /**
  38496. * Force the gamepad to synchronize with device values
  38497. */
  38498. update(): void;
  38499. /**
  38500. * Disposes the gamepad
  38501. */
  38502. dispose(): void;
  38503. }
  38504. }
  38505. declare module BABYLON {
  38506. /**
  38507. * Manager for handling gamepads
  38508. */
  38509. export class GamepadManager {
  38510. private _scene?;
  38511. private _babylonGamepads;
  38512. private _oneGamepadConnected;
  38513. /** @hidden */ private _isMonitoring: boolean;
  38514. private _gamepadEventSupported;
  38515. private _gamepadSupport;
  38516. /**
  38517. * observable to be triggered when the gamepad controller has been connected
  38518. */
  38519. onGamepadConnectedObservable: Observable<Gamepad>;
  38520. /**
  38521. * observable to be triggered when the gamepad controller has been disconnected
  38522. */
  38523. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38524. private _onGamepadConnectedEvent;
  38525. private _onGamepadDisconnectedEvent;
  38526. /**
  38527. * Initializes the gamepad manager
  38528. * @param _scene BabylonJS scene
  38529. */
  38530. constructor(_scene?: Scene | undefined);
  38531. /**
  38532. * The gamepads in the game pad manager
  38533. */
  38534. readonly gamepads: Gamepad[];
  38535. /**
  38536. * Get the gamepad controllers based on type
  38537. * @param type The type of gamepad controller
  38538. * @returns Nullable gamepad
  38539. */
  38540. getGamepadByType(type?: number): Nullable<Gamepad>;
  38541. /**
  38542. * Disposes the gamepad manager
  38543. */
  38544. dispose(): void;
  38545. private _addNewGamepad;
  38546. private _startMonitoringGamepads;
  38547. private _stopMonitoringGamepads;
  38548. /** @hidden */ private _checkGamepadsStatus(): void;
  38549. private _updateGamepadObjects;
  38550. }
  38551. }
  38552. declare module BABYLON {
  38553. interface Scene {
  38554. /** @hidden */ private _gamepadManager: Nullable<GamepadManager>;
  38555. /**
  38556. * Gets the gamepad manager associated with the scene
  38557. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38558. */
  38559. gamepadManager: GamepadManager;
  38560. }
  38561. /**
  38562. * Interface representing a free camera inputs manager
  38563. */
  38564. interface FreeCameraInputsManager {
  38565. /**
  38566. * Adds gamepad input support to the FreeCameraInputsManager.
  38567. * @returns the FreeCameraInputsManager
  38568. */
  38569. addGamepad(): FreeCameraInputsManager;
  38570. }
  38571. /**
  38572. * Interface representing an arc rotate camera inputs manager
  38573. */
  38574. interface ArcRotateCameraInputsManager {
  38575. /**
  38576. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38577. * @returns the camera inputs manager
  38578. */
  38579. addGamepad(): ArcRotateCameraInputsManager;
  38580. }
  38581. /**
  38582. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38583. */
  38584. export class GamepadSystemSceneComponent implements ISceneComponent {
  38585. /**
  38586. * The component name helpfull to identify the component in the list of scene components.
  38587. */
  38588. readonly name: string;
  38589. /**
  38590. * The scene the component belongs to.
  38591. */
  38592. scene: Scene;
  38593. /**
  38594. * Creates a new instance of the component for the given scene
  38595. * @param scene Defines the scene to register the component in
  38596. */
  38597. constructor(scene: Scene);
  38598. /**
  38599. * Registers the component in a given scene
  38600. */
  38601. register(): void;
  38602. /**
  38603. * Rebuilds the elements related to this component in case of
  38604. * context lost for instance.
  38605. */
  38606. rebuild(): void;
  38607. /**
  38608. * Disposes the component and the associated ressources
  38609. */
  38610. dispose(): void;
  38611. private _beforeCameraUpdate;
  38612. }
  38613. }
  38614. declare module BABYLON {
  38615. /**
  38616. * 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,
  38617. * which still works and will still be found in many Playgrounds.
  38618. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38619. */
  38620. export class UniversalCamera extends TouchCamera {
  38621. /**
  38622. * Defines the gamepad rotation sensiblity.
  38623. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38624. */
  38625. gamepadAngularSensibility: number;
  38626. /**
  38627. * Defines the gamepad move sensiblity.
  38628. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38629. */
  38630. gamepadMoveSensibility: number;
  38631. /**
  38632. * 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,
  38633. * which still works and will still be found in many Playgrounds.
  38634. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38635. * @param name Define the name of the camera in the scene
  38636. * @param position Define the start position of the camera in the scene
  38637. * @param scene Define the scene the camera belongs to
  38638. */
  38639. constructor(name: string, position: Vector3, scene: Scene);
  38640. /**
  38641. * Gets the current object class name.
  38642. * @return the class name
  38643. */
  38644. getClassName(): string;
  38645. }
  38646. }
  38647. declare module BABYLON {
  38648. /**
  38649. * This represents a FPS type of camera. This is only here for back compat purpose.
  38650. * Please use the UniversalCamera instead as both are identical.
  38651. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38652. */
  38653. export class GamepadCamera extends UniversalCamera {
  38654. /**
  38655. * Instantiates a new Gamepad Camera
  38656. * This represents a FPS type of camera. This is only here for back compat purpose.
  38657. * Please use the UniversalCamera instead as both are identical.
  38658. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38659. * @param name Define the name of the camera in the scene
  38660. * @param position Define the start position of the camera in the scene
  38661. * @param scene Define the scene the camera belongs to
  38662. */
  38663. constructor(name: string, position: Vector3, scene: Scene);
  38664. /**
  38665. * Gets the current object class name.
  38666. * @return the class name
  38667. */
  38668. getClassName(): string;
  38669. }
  38670. }
  38671. declare module BABYLON {
  38672. /** @hidden */
  38673. export var passPixelShader: {
  38674. name: string;
  38675. shader: string;
  38676. };
  38677. }
  38678. declare module BABYLON {
  38679. /** @hidden */
  38680. export var passCubePixelShader: {
  38681. name: string;
  38682. shader: string;
  38683. };
  38684. }
  38685. declare module BABYLON {
  38686. /**
  38687. * PassPostProcess which produces an output the same as it's input
  38688. */
  38689. export class PassPostProcess extends PostProcess {
  38690. /**
  38691. * Creates the PassPostProcess
  38692. * @param name The name of the effect.
  38693. * @param options The required width/height ratio to downsize to before computing the render pass.
  38694. * @param camera The camera to apply the render pass to.
  38695. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38696. * @param engine The engine which the post process will be applied. (default: current engine)
  38697. * @param reusable If the post process can be reused on the same frame. (default: false)
  38698. * @param textureType The type of texture to be used when performing the post processing.
  38699. * @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)
  38700. */
  38701. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38702. }
  38703. /**
  38704. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38705. */
  38706. export class PassCubePostProcess extends PostProcess {
  38707. private _face;
  38708. /**
  38709. * Gets or sets the cube face to display.
  38710. * * 0 is +X
  38711. * * 1 is -X
  38712. * * 2 is +Y
  38713. * * 3 is -Y
  38714. * * 4 is +Z
  38715. * * 5 is -Z
  38716. */
  38717. face: number;
  38718. /**
  38719. * Creates the PassCubePostProcess
  38720. * @param name The name of the effect.
  38721. * @param options The required width/height ratio to downsize to before computing the render pass.
  38722. * @param camera The camera to apply the render pass to.
  38723. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38724. * @param engine The engine which the post process will be applied. (default: current engine)
  38725. * @param reusable If the post process can be reused on the same frame. (default: false)
  38726. * @param textureType The type of texture to be used when performing the post processing.
  38727. * @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)
  38728. */
  38729. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38730. }
  38731. }
  38732. declare module BABYLON {
  38733. /** @hidden */
  38734. export var anaglyphPixelShader: {
  38735. name: string;
  38736. shader: string;
  38737. };
  38738. }
  38739. declare module BABYLON {
  38740. /**
  38741. * Postprocess used to generate anaglyphic rendering
  38742. */
  38743. export class AnaglyphPostProcess extends PostProcess {
  38744. private _passedProcess;
  38745. /**
  38746. * Creates a new AnaglyphPostProcess
  38747. * @param name defines postprocess name
  38748. * @param options defines creation options or target ratio scale
  38749. * @param rigCameras defines cameras using this postprocess
  38750. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38751. * @param engine defines hosting engine
  38752. * @param reusable defines if the postprocess will be reused multiple times per frame
  38753. */
  38754. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38755. }
  38756. }
  38757. declare module BABYLON {
  38758. /**
  38759. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38760. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38761. */
  38762. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38763. /**
  38764. * Creates a new AnaglyphArcRotateCamera
  38765. * @param name defines camera name
  38766. * @param alpha defines alpha angle (in radians)
  38767. * @param beta defines beta angle (in radians)
  38768. * @param radius defines radius
  38769. * @param target defines camera target
  38770. * @param interaxialDistance defines distance between each color axis
  38771. * @param scene defines the hosting scene
  38772. */
  38773. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38774. /**
  38775. * Gets camera class name
  38776. * @returns AnaglyphArcRotateCamera
  38777. */
  38778. getClassName(): string;
  38779. }
  38780. }
  38781. declare module BABYLON {
  38782. /**
  38783. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38784. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38785. */
  38786. export class AnaglyphFreeCamera extends FreeCamera {
  38787. /**
  38788. * Creates a new AnaglyphFreeCamera
  38789. * @param name defines camera name
  38790. * @param position defines initial position
  38791. * @param interaxialDistance defines distance between each color axis
  38792. * @param scene defines the hosting scene
  38793. */
  38794. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38795. /**
  38796. * Gets camera class name
  38797. * @returns AnaglyphFreeCamera
  38798. */
  38799. getClassName(): string;
  38800. }
  38801. }
  38802. declare module BABYLON {
  38803. /**
  38804. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38805. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38806. */
  38807. export class AnaglyphGamepadCamera extends GamepadCamera {
  38808. /**
  38809. * Creates a new AnaglyphGamepadCamera
  38810. * @param name defines camera name
  38811. * @param position defines initial position
  38812. * @param interaxialDistance defines distance between each color axis
  38813. * @param scene defines the hosting scene
  38814. */
  38815. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38816. /**
  38817. * Gets camera class name
  38818. * @returns AnaglyphGamepadCamera
  38819. */
  38820. getClassName(): string;
  38821. }
  38822. }
  38823. declare module BABYLON {
  38824. /**
  38825. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38826. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38827. */
  38828. export class AnaglyphUniversalCamera extends UniversalCamera {
  38829. /**
  38830. * Creates a new AnaglyphUniversalCamera
  38831. * @param name defines camera name
  38832. * @param position defines initial position
  38833. * @param interaxialDistance defines distance between each color axis
  38834. * @param scene defines the hosting scene
  38835. */
  38836. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38837. /**
  38838. * Gets camera class name
  38839. * @returns AnaglyphUniversalCamera
  38840. */
  38841. getClassName(): string;
  38842. }
  38843. }
  38844. declare module BABYLON {
  38845. /** @hidden */
  38846. export var stereoscopicInterlacePixelShader: {
  38847. name: string;
  38848. shader: string;
  38849. };
  38850. }
  38851. declare module BABYLON {
  38852. /**
  38853. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38854. */
  38855. export class StereoscopicInterlacePostProcess extends PostProcess {
  38856. private _stepSize;
  38857. private _passedProcess;
  38858. /**
  38859. * Initializes a StereoscopicInterlacePostProcess
  38860. * @param name The name of the effect.
  38861. * @param rigCameras The rig cameras to be appled to the post process
  38862. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38863. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38864. * @param engine The engine which the post process will be applied. (default: current engine)
  38865. * @param reusable If the post process can be reused on the same frame. (default: false)
  38866. */
  38867. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38868. }
  38869. }
  38870. declare module BABYLON {
  38871. /**
  38872. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38873. * @see http://doc.babylonjs.com/features/cameras
  38874. */
  38875. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38876. /**
  38877. * Creates a new StereoscopicArcRotateCamera
  38878. * @param name defines camera name
  38879. * @param alpha defines alpha angle (in radians)
  38880. * @param beta defines beta angle (in radians)
  38881. * @param radius defines radius
  38882. * @param target defines camera target
  38883. * @param interaxialDistance defines distance between each color axis
  38884. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38885. * @param scene defines the hosting scene
  38886. */
  38887. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38888. /**
  38889. * Gets camera class name
  38890. * @returns StereoscopicArcRotateCamera
  38891. */
  38892. getClassName(): string;
  38893. }
  38894. }
  38895. declare module BABYLON {
  38896. /**
  38897. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38898. * @see http://doc.babylonjs.com/features/cameras
  38899. */
  38900. export class StereoscopicFreeCamera extends FreeCamera {
  38901. /**
  38902. * Creates a new StereoscopicFreeCamera
  38903. * @param name defines camera name
  38904. * @param position defines initial position
  38905. * @param interaxialDistance defines distance between each color axis
  38906. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38907. * @param scene defines the hosting scene
  38908. */
  38909. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38910. /**
  38911. * Gets camera class name
  38912. * @returns StereoscopicFreeCamera
  38913. */
  38914. getClassName(): string;
  38915. }
  38916. }
  38917. declare module BABYLON {
  38918. /**
  38919. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38920. * @see http://doc.babylonjs.com/features/cameras
  38921. */
  38922. export class StereoscopicGamepadCamera extends GamepadCamera {
  38923. /**
  38924. * Creates a new StereoscopicGamepadCamera
  38925. * @param name defines camera name
  38926. * @param position defines initial position
  38927. * @param interaxialDistance defines distance between each color axis
  38928. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38929. * @param scene defines the hosting scene
  38930. */
  38931. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38932. /**
  38933. * Gets camera class name
  38934. * @returns StereoscopicGamepadCamera
  38935. */
  38936. getClassName(): string;
  38937. }
  38938. }
  38939. declare module BABYLON {
  38940. /**
  38941. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38942. * @see http://doc.babylonjs.com/features/cameras
  38943. */
  38944. export class StereoscopicUniversalCamera extends UniversalCamera {
  38945. /**
  38946. * Creates a new StereoscopicUniversalCamera
  38947. * @param name defines camera name
  38948. * @param position defines initial position
  38949. * @param interaxialDistance defines distance between each color axis
  38950. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38951. * @param scene defines the hosting scene
  38952. */
  38953. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38954. /**
  38955. * Gets camera class name
  38956. * @returns StereoscopicUniversalCamera
  38957. */
  38958. getClassName(): string;
  38959. }
  38960. }
  38961. declare module BABYLON {
  38962. /**
  38963. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38964. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38965. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38966. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38967. */
  38968. export class VirtualJoysticksCamera extends FreeCamera {
  38969. /**
  38970. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38971. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38972. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38973. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38974. * @param name Define the name of the camera in the scene
  38975. * @param position Define the start position of the camera in the scene
  38976. * @param scene Define the scene the camera belongs to
  38977. */
  38978. constructor(name: string, position: Vector3, scene: Scene);
  38979. /**
  38980. * Gets the current object class name.
  38981. * @return the class name
  38982. */
  38983. getClassName(): string;
  38984. }
  38985. }
  38986. declare module BABYLON {
  38987. /**
  38988. * This represents all the required metrics to create a VR camera.
  38989. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38990. */
  38991. export class VRCameraMetrics {
  38992. /**
  38993. * Define the horizontal resolution off the screen.
  38994. */
  38995. hResolution: number;
  38996. /**
  38997. * Define the vertical resolution off the screen.
  38998. */
  38999. vResolution: number;
  39000. /**
  39001. * Define the horizontal screen size.
  39002. */
  39003. hScreenSize: number;
  39004. /**
  39005. * Define the vertical screen size.
  39006. */
  39007. vScreenSize: number;
  39008. /**
  39009. * Define the vertical screen center position.
  39010. */
  39011. vScreenCenter: number;
  39012. /**
  39013. * Define the distance of the eyes to the screen.
  39014. */
  39015. eyeToScreenDistance: number;
  39016. /**
  39017. * Define the distance between both lenses
  39018. */
  39019. lensSeparationDistance: number;
  39020. /**
  39021. * Define the distance between both viewer's eyes.
  39022. */
  39023. interpupillaryDistance: number;
  39024. /**
  39025. * Define the distortion factor of the VR postprocess.
  39026. * Please, touch with care.
  39027. */
  39028. distortionK: number[];
  39029. /**
  39030. * Define the chromatic aberration correction factors for the VR post process.
  39031. */
  39032. chromaAbCorrection: number[];
  39033. /**
  39034. * Define the scale factor of the post process.
  39035. * The smaller the better but the slower.
  39036. */
  39037. postProcessScaleFactor: number;
  39038. /**
  39039. * Define an offset for the lens center.
  39040. */
  39041. lensCenterOffset: number;
  39042. /**
  39043. * Define if the current vr camera should compensate the distortion of the lense or not.
  39044. */
  39045. compensateDistortion: boolean;
  39046. /**
  39047. * Defines if multiview should be enabled when rendering (Default: false)
  39048. */
  39049. multiviewEnabled: boolean;
  39050. /**
  39051. * Gets the rendering aspect ratio based on the provided resolutions.
  39052. */
  39053. readonly aspectRatio: number;
  39054. /**
  39055. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39056. */
  39057. readonly aspectRatioFov: number;
  39058. /**
  39059. * @hidden
  39060. */
  39061. readonly leftHMatrix: Matrix;
  39062. /**
  39063. * @hidden
  39064. */
  39065. readonly rightHMatrix: Matrix;
  39066. /**
  39067. * @hidden
  39068. */
  39069. readonly leftPreViewMatrix: Matrix;
  39070. /**
  39071. * @hidden
  39072. */
  39073. readonly rightPreViewMatrix: Matrix;
  39074. /**
  39075. * Get the default VRMetrics based on the most generic setup.
  39076. * @returns the default vr metrics
  39077. */
  39078. static GetDefault(): VRCameraMetrics;
  39079. }
  39080. }
  39081. declare module BABYLON {
  39082. /** @hidden */
  39083. export var vrDistortionCorrectionPixelShader: {
  39084. name: string;
  39085. shader: string;
  39086. };
  39087. }
  39088. declare module BABYLON {
  39089. /**
  39090. * VRDistortionCorrectionPostProcess used for mobile VR
  39091. */
  39092. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39093. private _isRightEye;
  39094. private _distortionFactors;
  39095. private _postProcessScaleFactor;
  39096. private _lensCenterOffset;
  39097. private _scaleIn;
  39098. private _scaleFactor;
  39099. private _lensCenter;
  39100. /**
  39101. * Initializes the VRDistortionCorrectionPostProcess
  39102. * @param name The name of the effect.
  39103. * @param camera The camera to apply the render pass to.
  39104. * @param isRightEye If this is for the right eye distortion
  39105. * @param vrMetrics All the required metrics for the VR camera
  39106. */
  39107. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39108. }
  39109. }
  39110. declare module BABYLON {
  39111. /**
  39112. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39113. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39114. */
  39115. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39116. /**
  39117. * Creates a new VRDeviceOrientationArcRotateCamera
  39118. * @param name defines camera name
  39119. * @param alpha defines the camera rotation along the logitudinal axis
  39120. * @param beta defines the camera rotation along the latitudinal axis
  39121. * @param radius defines the camera distance from its target
  39122. * @param target defines the camera target
  39123. * @param scene defines the scene the camera belongs to
  39124. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39125. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39126. */
  39127. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39128. /**
  39129. * Gets camera class name
  39130. * @returns VRDeviceOrientationArcRotateCamera
  39131. */
  39132. getClassName(): string;
  39133. }
  39134. }
  39135. declare module BABYLON {
  39136. /**
  39137. * Camera used to simulate VR rendering (based on FreeCamera)
  39138. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39139. */
  39140. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39141. /**
  39142. * Creates a new VRDeviceOrientationFreeCamera
  39143. * @param name defines camera name
  39144. * @param position defines the start position of the camera
  39145. * @param scene defines the scene the camera belongs to
  39146. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39147. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39148. */
  39149. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39150. /**
  39151. * Gets camera class name
  39152. * @returns VRDeviceOrientationFreeCamera
  39153. */
  39154. getClassName(): string;
  39155. }
  39156. }
  39157. declare module BABYLON {
  39158. /**
  39159. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39160. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39161. */
  39162. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39163. /**
  39164. * Creates a new VRDeviceOrientationGamepadCamera
  39165. * @param name defines camera name
  39166. * @param position defines the start position of the camera
  39167. * @param scene defines the scene the camera belongs to
  39168. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39169. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39170. */
  39171. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39172. /**
  39173. * Gets camera class name
  39174. * @returns VRDeviceOrientationGamepadCamera
  39175. */
  39176. getClassName(): string;
  39177. }
  39178. }
  39179. declare module BABYLON {
  39180. /**
  39181. * Base class of materials working in push mode in babylon JS
  39182. * @hidden
  39183. */
  39184. export class PushMaterial extends Material {
  39185. protected _activeEffect: Effect;
  39186. protected _normalMatrix: Matrix;
  39187. /**
  39188. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39189. * This means that the material can keep using a previous shader while a new one is being compiled.
  39190. * This is mostly used when shader parallel compilation is supported (true by default)
  39191. */
  39192. allowShaderHotSwapping: boolean;
  39193. constructor(name: string, scene: Scene);
  39194. getEffect(): Effect;
  39195. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39196. /**
  39197. * Binds the given world matrix to the active effect
  39198. *
  39199. * @param world the matrix to bind
  39200. */
  39201. bindOnlyWorldMatrix(world: Matrix): void;
  39202. /**
  39203. * Binds the given normal matrix to the active effect
  39204. *
  39205. * @param normalMatrix the matrix to bind
  39206. */
  39207. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39208. bind(world: Matrix, mesh?: Mesh): void;
  39209. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39210. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39211. }
  39212. }
  39213. declare module BABYLON {
  39214. /**
  39215. * This groups all the flags used to control the materials channel.
  39216. */
  39217. export class MaterialFlags {
  39218. private static _DiffuseTextureEnabled;
  39219. /**
  39220. * Are diffuse textures enabled in the application.
  39221. */
  39222. static DiffuseTextureEnabled: boolean;
  39223. private static _AmbientTextureEnabled;
  39224. /**
  39225. * Are ambient textures enabled in the application.
  39226. */
  39227. static AmbientTextureEnabled: boolean;
  39228. private static _OpacityTextureEnabled;
  39229. /**
  39230. * Are opacity textures enabled in the application.
  39231. */
  39232. static OpacityTextureEnabled: boolean;
  39233. private static _ReflectionTextureEnabled;
  39234. /**
  39235. * Are reflection textures enabled in the application.
  39236. */
  39237. static ReflectionTextureEnabled: boolean;
  39238. private static _EmissiveTextureEnabled;
  39239. /**
  39240. * Are emissive textures enabled in the application.
  39241. */
  39242. static EmissiveTextureEnabled: boolean;
  39243. private static _SpecularTextureEnabled;
  39244. /**
  39245. * Are specular textures enabled in the application.
  39246. */
  39247. static SpecularTextureEnabled: boolean;
  39248. private static _BumpTextureEnabled;
  39249. /**
  39250. * Are bump textures enabled in the application.
  39251. */
  39252. static BumpTextureEnabled: boolean;
  39253. private static _LightmapTextureEnabled;
  39254. /**
  39255. * Are lightmap textures enabled in the application.
  39256. */
  39257. static LightmapTextureEnabled: boolean;
  39258. private static _RefractionTextureEnabled;
  39259. /**
  39260. * Are refraction textures enabled in the application.
  39261. */
  39262. static RefractionTextureEnabled: boolean;
  39263. private static _ColorGradingTextureEnabled;
  39264. /**
  39265. * Are color grading textures enabled in the application.
  39266. */
  39267. static ColorGradingTextureEnabled: boolean;
  39268. private static _FresnelEnabled;
  39269. /**
  39270. * Are fresnels enabled in the application.
  39271. */
  39272. static FresnelEnabled: boolean;
  39273. private static _ClearCoatTextureEnabled;
  39274. /**
  39275. * Are clear coat textures enabled in the application.
  39276. */
  39277. static ClearCoatTextureEnabled: boolean;
  39278. private static _ClearCoatBumpTextureEnabled;
  39279. /**
  39280. * Are clear coat bump textures enabled in the application.
  39281. */
  39282. static ClearCoatBumpTextureEnabled: boolean;
  39283. private static _ClearCoatTintTextureEnabled;
  39284. /**
  39285. * Are clear coat tint textures enabled in the application.
  39286. */
  39287. static ClearCoatTintTextureEnabled: boolean;
  39288. private static _SheenTextureEnabled;
  39289. /**
  39290. * Are sheen textures enabled in the application.
  39291. */
  39292. static SheenTextureEnabled: boolean;
  39293. private static _AnisotropicTextureEnabled;
  39294. /**
  39295. * Are anisotropic textures enabled in the application.
  39296. */
  39297. static AnisotropicTextureEnabled: boolean;
  39298. private static _ThicknessTextureEnabled;
  39299. /**
  39300. * Are thickness textures enabled in the application.
  39301. */
  39302. static ThicknessTextureEnabled: boolean;
  39303. }
  39304. }
  39305. declare module BABYLON {
  39306. /** @hidden */
  39307. export var defaultFragmentDeclaration: {
  39308. name: string;
  39309. shader: string;
  39310. };
  39311. }
  39312. declare module BABYLON {
  39313. /** @hidden */
  39314. export var defaultUboDeclaration: {
  39315. name: string;
  39316. shader: string;
  39317. };
  39318. }
  39319. declare module BABYLON {
  39320. /** @hidden */
  39321. export var lightFragmentDeclaration: {
  39322. name: string;
  39323. shader: string;
  39324. };
  39325. }
  39326. declare module BABYLON {
  39327. /** @hidden */
  39328. export var lightUboDeclaration: {
  39329. name: string;
  39330. shader: string;
  39331. };
  39332. }
  39333. declare module BABYLON {
  39334. /** @hidden */
  39335. export var lightsFragmentFunctions: {
  39336. name: string;
  39337. shader: string;
  39338. };
  39339. }
  39340. declare module BABYLON {
  39341. /** @hidden */
  39342. export var shadowsFragmentFunctions: {
  39343. name: string;
  39344. shader: string;
  39345. };
  39346. }
  39347. declare module BABYLON {
  39348. /** @hidden */
  39349. export var fresnelFunction: {
  39350. name: string;
  39351. shader: string;
  39352. };
  39353. }
  39354. declare module BABYLON {
  39355. /** @hidden */
  39356. export var reflectionFunction: {
  39357. name: string;
  39358. shader: string;
  39359. };
  39360. }
  39361. declare module BABYLON {
  39362. /** @hidden */
  39363. export var bumpFragmentFunctions: {
  39364. name: string;
  39365. shader: string;
  39366. };
  39367. }
  39368. declare module BABYLON {
  39369. /** @hidden */
  39370. export var logDepthDeclaration: {
  39371. name: string;
  39372. shader: string;
  39373. };
  39374. }
  39375. declare module BABYLON {
  39376. /** @hidden */
  39377. export var bumpFragment: {
  39378. name: string;
  39379. shader: string;
  39380. };
  39381. }
  39382. declare module BABYLON {
  39383. /** @hidden */
  39384. export var depthPrePass: {
  39385. name: string;
  39386. shader: string;
  39387. };
  39388. }
  39389. declare module BABYLON {
  39390. /** @hidden */
  39391. export var lightFragment: {
  39392. name: string;
  39393. shader: string;
  39394. };
  39395. }
  39396. declare module BABYLON {
  39397. /** @hidden */
  39398. export var logDepthFragment: {
  39399. name: string;
  39400. shader: string;
  39401. };
  39402. }
  39403. declare module BABYLON {
  39404. /** @hidden */
  39405. export var defaultPixelShader: {
  39406. name: string;
  39407. shader: string;
  39408. };
  39409. }
  39410. declare module BABYLON {
  39411. /** @hidden */
  39412. export var defaultVertexDeclaration: {
  39413. name: string;
  39414. shader: string;
  39415. };
  39416. }
  39417. declare module BABYLON {
  39418. /** @hidden */
  39419. export var bumpVertexDeclaration: {
  39420. name: string;
  39421. shader: string;
  39422. };
  39423. }
  39424. declare module BABYLON {
  39425. /** @hidden */
  39426. export var bumpVertex: {
  39427. name: string;
  39428. shader: string;
  39429. };
  39430. }
  39431. declare module BABYLON {
  39432. /** @hidden */
  39433. export var fogVertex: {
  39434. name: string;
  39435. shader: string;
  39436. };
  39437. }
  39438. declare module BABYLON {
  39439. /** @hidden */
  39440. export var shadowsVertex: {
  39441. name: string;
  39442. shader: string;
  39443. };
  39444. }
  39445. declare module BABYLON {
  39446. /** @hidden */
  39447. export var pointCloudVertex: {
  39448. name: string;
  39449. shader: string;
  39450. };
  39451. }
  39452. declare module BABYLON {
  39453. /** @hidden */
  39454. export var logDepthVertex: {
  39455. name: string;
  39456. shader: string;
  39457. };
  39458. }
  39459. declare module BABYLON {
  39460. /** @hidden */
  39461. export var defaultVertexShader: {
  39462. name: string;
  39463. shader: string;
  39464. };
  39465. }
  39466. declare module BABYLON {
  39467. /** @hidden */
  39468. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39469. MAINUV1: boolean;
  39470. MAINUV2: boolean;
  39471. DIFFUSE: boolean;
  39472. DIFFUSEDIRECTUV: number;
  39473. AMBIENT: boolean;
  39474. AMBIENTDIRECTUV: number;
  39475. OPACITY: boolean;
  39476. OPACITYDIRECTUV: number;
  39477. OPACITYRGB: boolean;
  39478. REFLECTION: boolean;
  39479. EMISSIVE: boolean;
  39480. EMISSIVEDIRECTUV: number;
  39481. SPECULAR: boolean;
  39482. SPECULARDIRECTUV: number;
  39483. BUMP: boolean;
  39484. BUMPDIRECTUV: number;
  39485. PARALLAX: boolean;
  39486. PARALLAXOCCLUSION: boolean;
  39487. SPECULAROVERALPHA: boolean;
  39488. CLIPPLANE: boolean;
  39489. CLIPPLANE2: boolean;
  39490. CLIPPLANE3: boolean;
  39491. CLIPPLANE4: boolean;
  39492. ALPHATEST: boolean;
  39493. DEPTHPREPASS: boolean;
  39494. ALPHAFROMDIFFUSE: boolean;
  39495. POINTSIZE: boolean;
  39496. FOG: boolean;
  39497. SPECULARTERM: boolean;
  39498. DIFFUSEFRESNEL: boolean;
  39499. OPACITYFRESNEL: boolean;
  39500. REFLECTIONFRESNEL: boolean;
  39501. REFRACTIONFRESNEL: boolean;
  39502. EMISSIVEFRESNEL: boolean;
  39503. FRESNEL: boolean;
  39504. NORMAL: boolean;
  39505. UV1: boolean;
  39506. UV2: boolean;
  39507. VERTEXCOLOR: boolean;
  39508. VERTEXALPHA: boolean;
  39509. NUM_BONE_INFLUENCERS: number;
  39510. BonesPerMesh: number;
  39511. BONETEXTURE: boolean;
  39512. INSTANCES: boolean;
  39513. GLOSSINESS: boolean;
  39514. ROUGHNESS: boolean;
  39515. EMISSIVEASILLUMINATION: boolean;
  39516. LINKEMISSIVEWITHDIFFUSE: boolean;
  39517. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39518. LIGHTMAP: boolean;
  39519. LIGHTMAPDIRECTUV: number;
  39520. OBJECTSPACE_NORMALMAP: boolean;
  39521. USELIGHTMAPASSHADOWMAP: boolean;
  39522. REFLECTIONMAP_3D: boolean;
  39523. REFLECTIONMAP_SPHERICAL: boolean;
  39524. REFLECTIONMAP_PLANAR: boolean;
  39525. REFLECTIONMAP_CUBIC: boolean;
  39526. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39527. REFLECTIONMAP_PROJECTION: boolean;
  39528. REFLECTIONMAP_SKYBOX: boolean;
  39529. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39530. REFLECTIONMAP_EXPLICIT: boolean;
  39531. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39532. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39533. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39534. INVERTCUBICMAP: boolean;
  39535. LOGARITHMICDEPTH: boolean;
  39536. REFRACTION: boolean;
  39537. REFRACTIONMAP_3D: boolean;
  39538. REFLECTIONOVERALPHA: boolean;
  39539. TWOSIDEDLIGHTING: boolean;
  39540. SHADOWFLOAT: boolean;
  39541. MORPHTARGETS: boolean;
  39542. MORPHTARGETS_NORMAL: boolean;
  39543. MORPHTARGETS_TANGENT: boolean;
  39544. MORPHTARGETS_UV: boolean;
  39545. NUM_MORPH_INFLUENCERS: number;
  39546. NONUNIFORMSCALING: boolean;
  39547. PREMULTIPLYALPHA: boolean;
  39548. IMAGEPROCESSING: boolean;
  39549. VIGNETTE: boolean;
  39550. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39551. VIGNETTEBLENDMODEOPAQUE: boolean;
  39552. TONEMAPPING: boolean;
  39553. TONEMAPPING_ACES: boolean;
  39554. CONTRAST: boolean;
  39555. COLORCURVES: boolean;
  39556. COLORGRADING: boolean;
  39557. COLORGRADING3D: boolean;
  39558. SAMPLER3DGREENDEPTH: boolean;
  39559. SAMPLER3DBGRMAP: boolean;
  39560. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39561. MULTIVIEW: boolean;
  39562. /**
  39563. * If the reflection texture on this material is in linear color space
  39564. * @hidden
  39565. */
  39566. IS_REFLECTION_LINEAR: boolean;
  39567. /**
  39568. * If the refraction texture on this material is in linear color space
  39569. * @hidden
  39570. */
  39571. IS_REFRACTION_LINEAR: boolean;
  39572. EXPOSURE: boolean;
  39573. constructor();
  39574. setReflectionMode(modeToEnable: string): void;
  39575. }
  39576. /**
  39577. * This is the default material used in Babylon. It is the best trade off between quality
  39578. * and performances.
  39579. * @see http://doc.babylonjs.com/babylon101/materials
  39580. */
  39581. export class StandardMaterial extends PushMaterial {
  39582. private _diffuseTexture;
  39583. /**
  39584. * The basic texture of the material as viewed under a light.
  39585. */
  39586. diffuseTexture: Nullable<BaseTexture>;
  39587. private _ambientTexture;
  39588. /**
  39589. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39590. */
  39591. ambientTexture: Nullable<BaseTexture>;
  39592. private _opacityTexture;
  39593. /**
  39594. * Define the transparency of the material from a texture.
  39595. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39596. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39597. */
  39598. opacityTexture: Nullable<BaseTexture>;
  39599. private _reflectionTexture;
  39600. /**
  39601. * Define the texture used to display the reflection.
  39602. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39603. */
  39604. reflectionTexture: Nullable<BaseTexture>;
  39605. private _emissiveTexture;
  39606. /**
  39607. * Define texture of the material as if self lit.
  39608. * This will be mixed in the final result even in the absence of light.
  39609. */
  39610. emissiveTexture: Nullable<BaseTexture>;
  39611. private _specularTexture;
  39612. /**
  39613. * Define how the color and intensity of the highlight given by the light in the material.
  39614. */
  39615. specularTexture: Nullable<BaseTexture>;
  39616. private _bumpTexture;
  39617. /**
  39618. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39619. * 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.
  39620. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39621. */
  39622. bumpTexture: Nullable<BaseTexture>;
  39623. private _lightmapTexture;
  39624. /**
  39625. * Complex lighting can be computationally expensive to compute at runtime.
  39626. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39627. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39628. */
  39629. lightmapTexture: Nullable<BaseTexture>;
  39630. private _refractionTexture;
  39631. /**
  39632. * Define the texture used to display the refraction.
  39633. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39634. */
  39635. refractionTexture: Nullable<BaseTexture>;
  39636. /**
  39637. * The color of the material lit by the environmental background lighting.
  39638. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39639. */
  39640. ambientColor: Color3;
  39641. /**
  39642. * The basic color of the material as viewed under a light.
  39643. */
  39644. diffuseColor: Color3;
  39645. /**
  39646. * Define how the color and intensity of the highlight given by the light in the material.
  39647. */
  39648. specularColor: Color3;
  39649. /**
  39650. * Define the color of the material as if self lit.
  39651. * This will be mixed in the final result even in the absence of light.
  39652. */
  39653. emissiveColor: Color3;
  39654. /**
  39655. * Defines how sharp are the highlights in the material.
  39656. * The bigger the value the sharper giving a more glossy feeling to the result.
  39657. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39658. */
  39659. specularPower: number;
  39660. private _useAlphaFromDiffuseTexture;
  39661. /**
  39662. * Does the transparency come from the diffuse texture alpha channel.
  39663. */
  39664. useAlphaFromDiffuseTexture: boolean;
  39665. private _useEmissiveAsIllumination;
  39666. /**
  39667. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39668. */
  39669. useEmissiveAsIllumination: boolean;
  39670. private _linkEmissiveWithDiffuse;
  39671. /**
  39672. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39673. * the emissive level when the final color is close to one.
  39674. */
  39675. linkEmissiveWithDiffuse: boolean;
  39676. private _useSpecularOverAlpha;
  39677. /**
  39678. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39679. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39680. */
  39681. useSpecularOverAlpha: boolean;
  39682. private _useReflectionOverAlpha;
  39683. /**
  39684. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39685. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39686. */
  39687. useReflectionOverAlpha: boolean;
  39688. private _disableLighting;
  39689. /**
  39690. * Does lights from the scene impacts this material.
  39691. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39692. */
  39693. disableLighting: boolean;
  39694. private _useObjectSpaceNormalMap;
  39695. /**
  39696. * Allows using an object space normal map (instead of tangent space).
  39697. */
  39698. useObjectSpaceNormalMap: boolean;
  39699. private _useParallax;
  39700. /**
  39701. * Is parallax enabled or not.
  39702. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39703. */
  39704. useParallax: boolean;
  39705. private _useParallaxOcclusion;
  39706. /**
  39707. * Is parallax occlusion enabled or not.
  39708. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39709. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39710. */
  39711. useParallaxOcclusion: boolean;
  39712. /**
  39713. * 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.
  39714. */
  39715. parallaxScaleBias: number;
  39716. private _roughness;
  39717. /**
  39718. * Helps to define how blurry the reflections should appears in the material.
  39719. */
  39720. roughness: number;
  39721. /**
  39722. * In case of refraction, define the value of the index of refraction.
  39723. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39724. */
  39725. indexOfRefraction: number;
  39726. /**
  39727. * Invert the refraction texture alongside the y axis.
  39728. * It can be useful with procedural textures or probe for instance.
  39729. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39730. */
  39731. invertRefractionY: boolean;
  39732. /**
  39733. * Defines the alpha limits in alpha test mode.
  39734. */
  39735. alphaCutOff: number;
  39736. private _useLightmapAsShadowmap;
  39737. /**
  39738. * In case of light mapping, define whether the map contains light or shadow informations.
  39739. */
  39740. useLightmapAsShadowmap: boolean;
  39741. private _diffuseFresnelParameters;
  39742. /**
  39743. * Define the diffuse fresnel parameters of the material.
  39744. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39745. */
  39746. diffuseFresnelParameters: FresnelParameters;
  39747. private _opacityFresnelParameters;
  39748. /**
  39749. * Define the opacity fresnel parameters of the material.
  39750. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39751. */
  39752. opacityFresnelParameters: FresnelParameters;
  39753. private _reflectionFresnelParameters;
  39754. /**
  39755. * Define the reflection fresnel parameters of the material.
  39756. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39757. */
  39758. reflectionFresnelParameters: FresnelParameters;
  39759. private _refractionFresnelParameters;
  39760. /**
  39761. * Define the refraction fresnel parameters of the material.
  39762. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39763. */
  39764. refractionFresnelParameters: FresnelParameters;
  39765. private _emissiveFresnelParameters;
  39766. /**
  39767. * Define the emissive fresnel parameters of the material.
  39768. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39769. */
  39770. emissiveFresnelParameters: FresnelParameters;
  39771. private _useReflectionFresnelFromSpecular;
  39772. /**
  39773. * If true automatically deducts the fresnels values from the material specularity.
  39774. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39775. */
  39776. useReflectionFresnelFromSpecular: boolean;
  39777. private _useGlossinessFromSpecularMapAlpha;
  39778. /**
  39779. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39780. */
  39781. useGlossinessFromSpecularMapAlpha: boolean;
  39782. private _maxSimultaneousLights;
  39783. /**
  39784. * Defines the maximum number of lights that can be used in the material
  39785. */
  39786. maxSimultaneousLights: number;
  39787. private _invertNormalMapX;
  39788. /**
  39789. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39790. */
  39791. invertNormalMapX: boolean;
  39792. private _invertNormalMapY;
  39793. /**
  39794. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39795. */
  39796. invertNormalMapY: boolean;
  39797. private _twoSidedLighting;
  39798. /**
  39799. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39800. */
  39801. twoSidedLighting: boolean;
  39802. /**
  39803. * Default configuration related to image processing available in the standard Material.
  39804. */
  39805. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39806. /**
  39807. * Gets the image processing configuration used either in this material.
  39808. */
  39809. /**
  39810. * Sets the Default image processing configuration used either in the this material.
  39811. *
  39812. * If sets to null, the scene one is in use.
  39813. */
  39814. imageProcessingConfiguration: ImageProcessingConfiguration;
  39815. /**
  39816. * Keep track of the image processing observer to allow dispose and replace.
  39817. */
  39818. private _imageProcessingObserver;
  39819. /**
  39820. * Attaches a new image processing configuration to the Standard Material.
  39821. * @param configuration
  39822. */
  39823. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39824. /**
  39825. * Gets wether the color curves effect is enabled.
  39826. */
  39827. /**
  39828. * Sets wether the color curves effect is enabled.
  39829. */
  39830. cameraColorCurvesEnabled: boolean;
  39831. /**
  39832. * Gets wether the color grading effect is enabled.
  39833. */
  39834. /**
  39835. * Gets wether the color grading effect is enabled.
  39836. */
  39837. cameraColorGradingEnabled: boolean;
  39838. /**
  39839. * Gets wether tonemapping is enabled or not.
  39840. */
  39841. /**
  39842. * Sets wether tonemapping is enabled or not
  39843. */
  39844. cameraToneMappingEnabled: boolean;
  39845. /**
  39846. * The camera exposure used on this material.
  39847. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39848. * This corresponds to a photographic exposure.
  39849. */
  39850. /**
  39851. * The camera exposure used on this material.
  39852. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39853. * This corresponds to a photographic exposure.
  39854. */
  39855. cameraExposure: number;
  39856. /**
  39857. * Gets The camera contrast used on this material.
  39858. */
  39859. /**
  39860. * Sets The camera contrast used on this material.
  39861. */
  39862. cameraContrast: number;
  39863. /**
  39864. * Gets the Color Grading 2D Lookup Texture.
  39865. */
  39866. /**
  39867. * Sets the Color Grading 2D Lookup Texture.
  39868. */
  39869. cameraColorGradingTexture: Nullable<BaseTexture>;
  39870. /**
  39871. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39872. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39873. * 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;
  39874. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39875. */
  39876. /**
  39877. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39878. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39879. * 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;
  39880. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39881. */
  39882. cameraColorCurves: Nullable<ColorCurves>;
  39883. /**
  39884. * Custom callback helping to override the default shader used in the material.
  39885. */
  39886. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39887. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39888. protected _worldViewProjectionMatrix: Matrix;
  39889. protected _globalAmbientColor: Color3;
  39890. protected _useLogarithmicDepth: boolean;
  39891. protected _rebuildInParallel: boolean;
  39892. /**
  39893. * Instantiates a new standard material.
  39894. * This is the default material used in Babylon. It is the best trade off between quality
  39895. * and performances.
  39896. * @see http://doc.babylonjs.com/babylon101/materials
  39897. * @param name Define the name of the material in the scene
  39898. * @param scene Define the scene the material belong to
  39899. */
  39900. constructor(name: string, scene: Scene);
  39901. /**
  39902. * Gets a boolean indicating that current material needs to register RTT
  39903. */
  39904. readonly hasRenderTargetTextures: boolean;
  39905. /**
  39906. * Gets the current class name of the material e.g. "StandardMaterial"
  39907. * Mainly use in serialization.
  39908. * @returns the class name
  39909. */
  39910. getClassName(): string;
  39911. /**
  39912. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39913. * You can try switching to logarithmic depth.
  39914. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39915. */
  39916. useLogarithmicDepth: boolean;
  39917. /**
  39918. * Specifies if the material will require alpha blending
  39919. * @returns a boolean specifying if alpha blending is needed
  39920. */
  39921. needAlphaBlending(): boolean;
  39922. /**
  39923. * Specifies if this material should be rendered in alpha test mode
  39924. * @returns a boolean specifying if an alpha test is needed.
  39925. */
  39926. needAlphaTesting(): boolean;
  39927. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39928. /**
  39929. * Get the texture used for alpha test purpose.
  39930. * @returns the diffuse texture in case of the standard material.
  39931. */
  39932. getAlphaTestTexture(): Nullable<BaseTexture>;
  39933. /**
  39934. * Get if the submesh is ready to be used and all its information available.
  39935. * Child classes can use it to update shaders
  39936. * @param mesh defines the mesh to check
  39937. * @param subMesh defines which submesh to check
  39938. * @param useInstances specifies that instances should be used
  39939. * @returns a boolean indicating that the submesh is ready or not
  39940. */
  39941. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39942. /**
  39943. * Builds the material UBO layouts.
  39944. * Used internally during the effect preparation.
  39945. */
  39946. buildUniformLayout(): void;
  39947. /**
  39948. * Unbinds the material from the mesh
  39949. */
  39950. unbind(): void;
  39951. /**
  39952. * Binds the submesh to this material by preparing the effect and shader to draw
  39953. * @param world defines the world transformation matrix
  39954. * @param mesh defines the mesh containing the submesh
  39955. * @param subMesh defines the submesh to bind the material to
  39956. */
  39957. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39958. /**
  39959. * Get the list of animatables in the material.
  39960. * @returns the list of animatables object used in the material
  39961. */
  39962. getAnimatables(): IAnimatable[];
  39963. /**
  39964. * Gets the active textures from the material
  39965. * @returns an array of textures
  39966. */
  39967. getActiveTextures(): BaseTexture[];
  39968. /**
  39969. * Specifies if the material uses a texture
  39970. * @param texture defines the texture to check against the material
  39971. * @returns a boolean specifying if the material uses the texture
  39972. */
  39973. hasTexture(texture: BaseTexture): boolean;
  39974. /**
  39975. * Disposes the material
  39976. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39977. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39978. */
  39979. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39980. /**
  39981. * Makes a duplicate of the material, and gives it a new name
  39982. * @param name defines the new name for the duplicated material
  39983. * @returns the cloned material
  39984. */
  39985. clone(name: string): StandardMaterial;
  39986. /**
  39987. * Serializes this material in a JSON representation
  39988. * @returns the serialized material object
  39989. */
  39990. serialize(): any;
  39991. /**
  39992. * Creates a standard material from parsed material data
  39993. * @param source defines the JSON representation of the material
  39994. * @param scene defines the hosting scene
  39995. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39996. * @returns a new standard material
  39997. */
  39998. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39999. /**
  40000. * Are diffuse textures enabled in the application.
  40001. */
  40002. static DiffuseTextureEnabled: boolean;
  40003. /**
  40004. * Are ambient textures enabled in the application.
  40005. */
  40006. static AmbientTextureEnabled: boolean;
  40007. /**
  40008. * Are opacity textures enabled in the application.
  40009. */
  40010. static OpacityTextureEnabled: boolean;
  40011. /**
  40012. * Are reflection textures enabled in the application.
  40013. */
  40014. static ReflectionTextureEnabled: boolean;
  40015. /**
  40016. * Are emissive textures enabled in the application.
  40017. */
  40018. static EmissiveTextureEnabled: boolean;
  40019. /**
  40020. * Are specular textures enabled in the application.
  40021. */
  40022. static SpecularTextureEnabled: boolean;
  40023. /**
  40024. * Are bump textures enabled in the application.
  40025. */
  40026. static BumpTextureEnabled: boolean;
  40027. /**
  40028. * Are lightmap textures enabled in the application.
  40029. */
  40030. static LightmapTextureEnabled: boolean;
  40031. /**
  40032. * Are refraction textures enabled in the application.
  40033. */
  40034. static RefractionTextureEnabled: boolean;
  40035. /**
  40036. * Are color grading textures enabled in the application.
  40037. */
  40038. static ColorGradingTextureEnabled: boolean;
  40039. /**
  40040. * Are fresnels enabled in the application.
  40041. */
  40042. static FresnelEnabled: boolean;
  40043. }
  40044. }
  40045. declare module BABYLON {
  40046. /** @hidden */
  40047. export var imageProcessingPixelShader: {
  40048. name: string;
  40049. shader: string;
  40050. };
  40051. }
  40052. declare module BABYLON {
  40053. /**
  40054. * ImageProcessingPostProcess
  40055. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40056. */
  40057. export class ImageProcessingPostProcess extends PostProcess {
  40058. /**
  40059. * Default configuration related to image processing available in the PBR Material.
  40060. */
  40061. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40062. /**
  40063. * Gets the image processing configuration used either in this material.
  40064. */
  40065. /**
  40066. * Sets the Default image processing configuration used either in the this material.
  40067. *
  40068. * If sets to null, the scene one is in use.
  40069. */
  40070. imageProcessingConfiguration: ImageProcessingConfiguration;
  40071. /**
  40072. * Keep track of the image processing observer to allow dispose and replace.
  40073. */
  40074. private _imageProcessingObserver;
  40075. /**
  40076. * Attaches a new image processing configuration to the PBR Material.
  40077. * @param configuration
  40078. */
  40079. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40080. /**
  40081. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40082. */
  40083. /**
  40084. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40085. */
  40086. colorCurves: Nullable<ColorCurves>;
  40087. /**
  40088. * Gets wether the color curves effect is enabled.
  40089. */
  40090. /**
  40091. * Sets wether the color curves effect is enabled.
  40092. */
  40093. colorCurvesEnabled: boolean;
  40094. /**
  40095. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40096. */
  40097. /**
  40098. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40099. */
  40100. colorGradingTexture: Nullable<BaseTexture>;
  40101. /**
  40102. * Gets wether the color grading effect is enabled.
  40103. */
  40104. /**
  40105. * Gets wether the color grading effect is enabled.
  40106. */
  40107. colorGradingEnabled: boolean;
  40108. /**
  40109. * Gets exposure used in the effect.
  40110. */
  40111. /**
  40112. * Sets exposure used in the effect.
  40113. */
  40114. exposure: number;
  40115. /**
  40116. * Gets wether tonemapping is enabled or not.
  40117. */
  40118. /**
  40119. * Sets wether tonemapping is enabled or not
  40120. */
  40121. toneMappingEnabled: boolean;
  40122. /**
  40123. * Gets the type of tone mapping effect.
  40124. */
  40125. /**
  40126. * Sets the type of tone mapping effect.
  40127. */
  40128. toneMappingType: number;
  40129. /**
  40130. * Gets contrast used in the effect.
  40131. */
  40132. /**
  40133. * Sets contrast used in the effect.
  40134. */
  40135. contrast: number;
  40136. /**
  40137. * Gets Vignette stretch size.
  40138. */
  40139. /**
  40140. * Sets Vignette stretch size.
  40141. */
  40142. vignetteStretch: number;
  40143. /**
  40144. * Gets Vignette centre X Offset.
  40145. */
  40146. /**
  40147. * Sets Vignette centre X Offset.
  40148. */
  40149. vignetteCentreX: number;
  40150. /**
  40151. * Gets Vignette centre Y Offset.
  40152. */
  40153. /**
  40154. * Sets Vignette centre Y Offset.
  40155. */
  40156. vignetteCentreY: number;
  40157. /**
  40158. * Gets Vignette weight or intensity of the vignette effect.
  40159. */
  40160. /**
  40161. * Sets Vignette weight or intensity of the vignette effect.
  40162. */
  40163. vignetteWeight: number;
  40164. /**
  40165. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40166. * if vignetteEnabled is set to true.
  40167. */
  40168. /**
  40169. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40170. * if vignetteEnabled is set to true.
  40171. */
  40172. vignetteColor: Color4;
  40173. /**
  40174. * Gets Camera field of view used by the Vignette effect.
  40175. */
  40176. /**
  40177. * Sets Camera field of view used by the Vignette effect.
  40178. */
  40179. vignetteCameraFov: number;
  40180. /**
  40181. * Gets the vignette blend mode allowing different kind of effect.
  40182. */
  40183. /**
  40184. * Sets the vignette blend mode allowing different kind of effect.
  40185. */
  40186. vignetteBlendMode: number;
  40187. /**
  40188. * Gets wether the vignette effect is enabled.
  40189. */
  40190. /**
  40191. * Sets wether the vignette effect is enabled.
  40192. */
  40193. vignetteEnabled: boolean;
  40194. private _fromLinearSpace;
  40195. /**
  40196. * Gets wether the input of the processing is in Gamma or Linear Space.
  40197. */
  40198. /**
  40199. * Sets wether the input of the processing is in Gamma or Linear Space.
  40200. */
  40201. fromLinearSpace: boolean;
  40202. /**
  40203. * Defines cache preventing GC.
  40204. */
  40205. private _defines;
  40206. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40207. /**
  40208. * "ImageProcessingPostProcess"
  40209. * @returns "ImageProcessingPostProcess"
  40210. */
  40211. getClassName(): string;
  40212. protected _updateParameters(): void;
  40213. dispose(camera?: Camera): void;
  40214. }
  40215. }
  40216. declare module BABYLON {
  40217. /**
  40218. * Class containing static functions to help procedurally build meshes
  40219. */
  40220. export class GroundBuilder {
  40221. /**
  40222. * Creates a ground mesh
  40223. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40224. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40225. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40226. * @param name defines the name of the mesh
  40227. * @param options defines the options used to create the mesh
  40228. * @param scene defines the hosting scene
  40229. * @returns the ground mesh
  40230. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40231. */
  40232. static CreateGround(name: string, options: {
  40233. width?: number;
  40234. height?: number;
  40235. subdivisions?: number;
  40236. subdivisionsX?: number;
  40237. subdivisionsY?: number;
  40238. updatable?: boolean;
  40239. }, scene: any): Mesh;
  40240. /**
  40241. * Creates a tiled ground mesh
  40242. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40243. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40244. * * 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
  40245. * * 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
  40246. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40247. * @param name defines the name of the mesh
  40248. * @param options defines the options used to create the mesh
  40249. * @param scene defines the hosting scene
  40250. * @returns the tiled ground mesh
  40251. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40252. */
  40253. static CreateTiledGround(name: string, options: {
  40254. xmin: number;
  40255. zmin: number;
  40256. xmax: number;
  40257. zmax: number;
  40258. subdivisions?: {
  40259. w: number;
  40260. h: number;
  40261. };
  40262. precision?: {
  40263. w: number;
  40264. h: number;
  40265. };
  40266. updatable?: boolean;
  40267. }, scene?: Nullable<Scene>): Mesh;
  40268. /**
  40269. * Creates a ground mesh from a height map
  40270. * * The parameter `url` sets the URL of the height map image resource.
  40271. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40272. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40273. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40274. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40275. * * 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.
  40276. * * 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).
  40277. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40279. * @param name defines the name of the mesh
  40280. * @param url defines the url to the height map
  40281. * @param options defines the options used to create the mesh
  40282. * @param scene defines the hosting scene
  40283. * @returns the ground mesh
  40284. * @see https://doc.babylonjs.com/babylon101/height_map
  40285. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40286. */
  40287. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40288. width?: number;
  40289. height?: number;
  40290. subdivisions?: number;
  40291. minHeight?: number;
  40292. maxHeight?: number;
  40293. colorFilter?: Color3;
  40294. alphaFilter?: number;
  40295. updatable?: boolean;
  40296. onReady?: (mesh: GroundMesh) => void;
  40297. }, scene?: Nullable<Scene>): GroundMesh;
  40298. }
  40299. }
  40300. declare module BABYLON {
  40301. /**
  40302. * Class containing static functions to help procedurally build meshes
  40303. */
  40304. export class TorusBuilder {
  40305. /**
  40306. * Creates a torus mesh
  40307. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40308. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40309. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40310. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40311. * * 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
  40312. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40313. * @param name defines the name of the mesh
  40314. * @param options defines the options used to create the mesh
  40315. * @param scene defines the hosting scene
  40316. * @returns the torus mesh
  40317. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40318. */
  40319. static CreateTorus(name: string, options: {
  40320. diameter?: number;
  40321. thickness?: number;
  40322. tessellation?: number;
  40323. updatable?: boolean;
  40324. sideOrientation?: number;
  40325. frontUVs?: Vector4;
  40326. backUVs?: Vector4;
  40327. }, scene: any): Mesh;
  40328. }
  40329. }
  40330. declare module BABYLON {
  40331. /**
  40332. * Class containing static functions to help procedurally build meshes
  40333. */
  40334. export class CylinderBuilder {
  40335. /**
  40336. * Creates a cylinder or a cone mesh
  40337. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40338. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40339. * * 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.
  40340. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40341. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40342. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40343. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40344. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  40345. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40346. * * 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).
  40347. * * 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
  40348. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40349. * * 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
  40350. * * 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.
  40351. * * If `enclose` is false, a ring surface is one element.
  40352. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40353. * * 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
  40354. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40355. * * 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
  40356. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40357. * @param name defines the name of the mesh
  40358. * @param options defines the options used to create the mesh
  40359. * @param scene defines the hosting scene
  40360. * @returns the cylinder mesh
  40361. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40362. */
  40363. static CreateCylinder(name: string, options: {
  40364. height?: number;
  40365. diameterTop?: number;
  40366. diameterBottom?: number;
  40367. diameter?: number;
  40368. tessellation?: number;
  40369. subdivisions?: number;
  40370. arc?: number;
  40371. faceColors?: Color4[];
  40372. faceUV?: Vector4[];
  40373. updatable?: boolean;
  40374. hasRings?: boolean;
  40375. enclose?: boolean;
  40376. cap?: number;
  40377. sideOrientation?: number;
  40378. frontUVs?: Vector4;
  40379. backUVs?: Vector4;
  40380. }, scene: any): Mesh;
  40381. }
  40382. }
  40383. declare module BABYLON {
  40384. /**
  40385. * Options to modify the vr teleportation behavior.
  40386. */
  40387. export interface VRTeleportationOptions {
  40388. /**
  40389. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40390. */
  40391. floorMeshName?: string;
  40392. /**
  40393. * A list of meshes to be used as the teleportation floor. (default: empty)
  40394. */
  40395. floorMeshes?: Mesh[];
  40396. }
  40397. /**
  40398. * Options to modify the vr experience helper's behavior.
  40399. */
  40400. export interface VRExperienceHelperOptions extends WebVROptions {
  40401. /**
  40402. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40403. */
  40404. createDeviceOrientationCamera?: boolean;
  40405. /**
  40406. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40407. */
  40408. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40409. /**
  40410. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40411. */
  40412. laserToggle?: boolean;
  40413. /**
  40414. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40415. */
  40416. floorMeshes?: Mesh[];
  40417. /**
  40418. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40419. */
  40420. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40421. }
  40422. /**
  40423. * Event containing information after VR has been entered
  40424. */
  40425. export class OnAfterEnteringVRObservableEvent {
  40426. /**
  40427. * If entering vr was successful
  40428. */
  40429. success: boolean;
  40430. }
  40431. /**
  40432. * Helps to quickly add VR support to an existing scene.
  40433. * See http://doc.babylonjs.com/how_to/webvr_helper
  40434. */
  40435. export class VRExperienceHelper {
  40436. /** Options to modify the vr experience helper's behavior. */
  40437. webVROptions: VRExperienceHelperOptions;
  40438. private _scene;
  40439. private _position;
  40440. private _btnVR;
  40441. private _btnVRDisplayed;
  40442. private _webVRsupported;
  40443. private _webVRready;
  40444. private _webVRrequesting;
  40445. private _webVRpresenting;
  40446. private _hasEnteredVR;
  40447. private _fullscreenVRpresenting;
  40448. private _canvas;
  40449. private _webVRCamera;
  40450. private _vrDeviceOrientationCamera;
  40451. private _deviceOrientationCamera;
  40452. private _existingCamera;
  40453. private _onKeyDown;
  40454. private _onVrDisplayPresentChange;
  40455. private _onVRDisplayChanged;
  40456. private _onVRRequestPresentStart;
  40457. private _onVRRequestPresentComplete;
  40458. /**
  40459. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  40460. */
  40461. enableGazeEvenWhenNoPointerLock: boolean;
  40462. /**
  40463. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  40464. */
  40465. exitVROnDoubleTap: boolean;
  40466. /**
  40467. * Observable raised right before entering VR.
  40468. */
  40469. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40470. /**
  40471. * Observable raised when entering VR has completed.
  40472. */
  40473. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40474. /**
  40475. * Observable raised when exiting VR.
  40476. */
  40477. onExitingVRObservable: Observable<VRExperienceHelper>;
  40478. /**
  40479. * Observable raised when controller mesh is loaded.
  40480. */
  40481. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40482. /** Return this.onEnteringVRObservable
  40483. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40484. */
  40485. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40486. /** Return this.onExitingVRObservable
  40487. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40488. */
  40489. readonly onExitingVR: Observable<VRExperienceHelper>;
  40490. /** Return this.onControllerMeshLoadedObservable
  40491. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40492. */
  40493. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40494. private _rayLength;
  40495. private _useCustomVRButton;
  40496. private _teleportationRequested;
  40497. private _teleportActive;
  40498. private _floorMeshName;
  40499. private _floorMeshesCollection;
  40500. private _rotationAllowed;
  40501. private _teleportBackwardsVector;
  40502. private _teleportationTarget;
  40503. private _isDefaultTeleportationTarget;
  40504. private _postProcessMove;
  40505. private _teleportationFillColor;
  40506. private _teleportationBorderColor;
  40507. private _rotationAngle;
  40508. private _haloCenter;
  40509. private _cameraGazer;
  40510. private _padSensibilityUp;
  40511. private _padSensibilityDown;
  40512. private _leftController;
  40513. private _rightController;
  40514. /**
  40515. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40516. */
  40517. onNewMeshSelected: Observable<AbstractMesh>;
  40518. /**
  40519. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  40520. * This observable will provide the mesh and the controller used to select the mesh
  40521. */
  40522. onMeshSelectedWithController: Observable<{
  40523. mesh: AbstractMesh;
  40524. controller: WebVRController;
  40525. }>;
  40526. /**
  40527. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40528. */
  40529. onNewMeshPicked: Observable<PickingInfo>;
  40530. private _circleEase;
  40531. /**
  40532. * Observable raised before camera teleportation
  40533. */
  40534. onBeforeCameraTeleport: Observable<Vector3>;
  40535. /**
  40536. * Observable raised after camera teleportation
  40537. */
  40538. onAfterCameraTeleport: Observable<Vector3>;
  40539. /**
  40540. * Observable raised when current selected mesh gets unselected
  40541. */
  40542. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40543. private _raySelectionPredicate;
  40544. /**
  40545. * To be optionaly changed by user to define custom ray selection
  40546. */
  40547. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40548. /**
  40549. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40550. */
  40551. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40552. /**
  40553. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40554. */
  40555. teleportationEnabled: boolean;
  40556. private _defaultHeight;
  40557. private _teleportationInitialized;
  40558. private _interactionsEnabled;
  40559. private _interactionsRequested;
  40560. private _displayGaze;
  40561. private _displayLaserPointer;
  40562. /**
  40563. * The mesh used to display where the user is going to teleport.
  40564. */
  40565. /**
  40566. * Sets the mesh to be used to display where the user is going to teleport.
  40567. */
  40568. teleportationTarget: Mesh;
  40569. /**
  40570. * 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
  40571. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40572. * See http://doc.babylonjs.com/resources/baking_transformations
  40573. */
  40574. gazeTrackerMesh: Mesh;
  40575. /**
  40576. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40577. */
  40578. updateGazeTrackerScale: boolean;
  40579. /**
  40580. * If the gaze trackers color should be updated when selecting meshes
  40581. */
  40582. updateGazeTrackerColor: boolean;
  40583. /**
  40584. * If the controller laser color should be updated when selecting meshes
  40585. */
  40586. updateControllerLaserColor: boolean;
  40587. /**
  40588. * The gaze tracking mesh corresponding to the left controller
  40589. */
  40590. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40591. /**
  40592. * The gaze tracking mesh corresponding to the right controller
  40593. */
  40594. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40595. /**
  40596. * If the ray of the gaze should be displayed.
  40597. */
  40598. /**
  40599. * Sets if the ray of the gaze should be displayed.
  40600. */
  40601. displayGaze: boolean;
  40602. /**
  40603. * If the ray of the LaserPointer should be displayed.
  40604. */
  40605. /**
  40606. * Sets if the ray of the LaserPointer should be displayed.
  40607. */
  40608. displayLaserPointer: boolean;
  40609. /**
  40610. * The deviceOrientationCamera used as the camera when not in VR.
  40611. */
  40612. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40613. /**
  40614. * Based on the current WebVR support, returns the current VR camera used.
  40615. */
  40616. readonly currentVRCamera: Nullable<Camera>;
  40617. /**
  40618. * The webVRCamera which is used when in VR.
  40619. */
  40620. readonly webVRCamera: WebVRFreeCamera;
  40621. /**
  40622. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40623. */
  40624. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40625. /**
  40626. * The html button that is used to trigger entering into VR.
  40627. */
  40628. readonly vrButton: Nullable<HTMLButtonElement>;
  40629. private readonly _teleportationRequestInitiated;
  40630. /**
  40631. * Defines wether or not Pointer lock should be requested when switching to
  40632. * full screen.
  40633. */
  40634. requestPointerLockOnFullScreen: boolean;
  40635. /**
  40636. * Instantiates a VRExperienceHelper.
  40637. * Helps to quickly add VR support to an existing scene.
  40638. * @param scene The scene the VRExperienceHelper belongs to.
  40639. * @param webVROptions Options to modify the vr experience helper's behavior.
  40640. */
  40641. constructor(scene: Scene,
  40642. /** Options to modify the vr experience helper's behavior. */
  40643. webVROptions?: VRExperienceHelperOptions);
  40644. private _onDefaultMeshLoaded;
  40645. private _onResize;
  40646. private _onFullscreenChange;
  40647. /**
  40648. * Gets a value indicating if we are currently in VR mode.
  40649. */
  40650. readonly isInVRMode: boolean;
  40651. private onVrDisplayPresentChange;
  40652. private onVRDisplayChanged;
  40653. private moveButtonToBottomRight;
  40654. private displayVRButton;
  40655. private updateButtonVisibility;
  40656. private _cachedAngularSensibility;
  40657. /**
  40658. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40659. * Otherwise, will use the fullscreen API.
  40660. */
  40661. enterVR(): void;
  40662. /**
  40663. * Attempt to exit VR, or fullscreen.
  40664. */
  40665. exitVR(): void;
  40666. /**
  40667. * The position of the vr experience helper.
  40668. */
  40669. /**
  40670. * Sets the position of the vr experience helper.
  40671. */
  40672. position: Vector3;
  40673. /**
  40674. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40675. */
  40676. enableInteractions(): void;
  40677. private readonly _noControllerIsActive;
  40678. private beforeRender;
  40679. private _isTeleportationFloor;
  40680. /**
  40681. * Adds a floor mesh to be used for teleportation.
  40682. * @param floorMesh the mesh to be used for teleportation.
  40683. */
  40684. addFloorMesh(floorMesh: Mesh): void;
  40685. /**
  40686. * Removes a floor mesh from being used for teleportation.
  40687. * @param floorMesh the mesh to be removed.
  40688. */
  40689. removeFloorMesh(floorMesh: Mesh): void;
  40690. /**
  40691. * Enables interactions and teleportation using the VR controllers and gaze.
  40692. * @param vrTeleportationOptions options to modify teleportation behavior.
  40693. */
  40694. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40695. private _onNewGamepadConnected;
  40696. private _tryEnableInteractionOnController;
  40697. private _onNewGamepadDisconnected;
  40698. private _enableInteractionOnController;
  40699. private _checkTeleportWithRay;
  40700. private _checkRotate;
  40701. private _checkTeleportBackwards;
  40702. private _enableTeleportationOnController;
  40703. private _createTeleportationCircles;
  40704. private _displayTeleportationTarget;
  40705. private _hideTeleportationTarget;
  40706. private _rotateCamera;
  40707. private _moveTeleportationSelectorTo;
  40708. private _workingVector;
  40709. private _workingQuaternion;
  40710. private _workingMatrix;
  40711. /**
  40712. * Teleports the users feet to the desired location
  40713. * @param location The location where the user's feet should be placed
  40714. */
  40715. teleportCamera(location: Vector3): void;
  40716. private _convertNormalToDirectionOfRay;
  40717. private _castRayAndSelectObject;
  40718. private _notifySelectedMeshUnselected;
  40719. /**
  40720. * Sets the color of the laser ray from the vr controllers.
  40721. * @param color new color for the ray.
  40722. */
  40723. changeLaserColor(color: Color3): void;
  40724. /**
  40725. * Sets the color of the ray from the vr headsets gaze.
  40726. * @param color new color for the ray.
  40727. */
  40728. changeGazeColor(color: Color3): void;
  40729. /**
  40730. * Exits VR and disposes of the vr experience helper
  40731. */
  40732. dispose(): void;
  40733. /**
  40734. * Gets the name of the VRExperienceHelper class
  40735. * @returns "VRExperienceHelper"
  40736. */
  40737. getClassName(): string;
  40738. }
  40739. }
  40740. declare module BABYLON {
  40741. /**
  40742. * Manages an XRSession to work with Babylon's engine
  40743. * @see https://doc.babylonjs.com/how_to/webxr
  40744. */
  40745. export class WebXRSessionManager implements IDisposable {
  40746. private scene;
  40747. /**
  40748. * Fires every time a new xrFrame arrives which can be used to update the camera
  40749. */
  40750. onXRFrameObservable: Observable<any>;
  40751. /**
  40752. * Fires when the xr session is ended either by the device or manually done
  40753. */
  40754. onXRSessionEnded: Observable<any>;
  40755. /**
  40756. * Underlying xr session
  40757. */
  40758. session: XRSession;
  40759. /**
  40760. * Type of reference space used when creating the session
  40761. */
  40762. referenceSpace: XRReferenceSpace;
  40763. /** @hidden */ private _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40764. /**
  40765. * Current XR frame
  40766. */
  40767. currentFrame: Nullable<XRFrame>;
  40768. private _xrNavigator;
  40769. private baseLayer;
  40770. /**
  40771. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40772. * @param scene The scene which the session should be created for
  40773. */
  40774. constructor(scene: Scene);
  40775. /**
  40776. * Initializes the manager
  40777. * After initialization enterXR can be called to start an XR session
  40778. * @returns Promise which resolves after it is initialized
  40779. */
  40780. initializeAsync(): Promise<void>;
  40781. /**
  40782. * Initializes an xr session
  40783. * @param xrSessionMode mode to initialize
  40784. * @returns a promise which will resolve once the session has been initialized
  40785. */
  40786. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  40787. /**
  40788. * Sets the reference space on the xr session
  40789. * @param referenceSpace space to set
  40790. * @returns a promise that will resolve once the reference space has been set
  40791. */
  40792. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  40793. /**
  40794. * Updates the render state of the session
  40795. * @param state state to set
  40796. * @returns a promise that resolves once the render state has been updated
  40797. */
  40798. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  40799. /**
  40800. * Starts rendering to the xr layer
  40801. * @returns a promise that will resolve once rendering has started
  40802. */
  40803. startRenderingToXRAsync(): Promise<void>;
  40804. /**
  40805. * Stops the xrSession and restores the renderloop
  40806. * @returns Promise which resolves after it exits XR
  40807. */
  40808. exitXRAsync(): Promise<unknown>;
  40809. /**
  40810. * Checks if a session would be supported for the creation options specified
  40811. * @param sessionMode session mode to check if supported eg. immersive-vr
  40812. * @returns true if supported
  40813. */
  40814. supportsSessionAsync(sessionMode: XRSessionMode): any;
  40815. /**
  40816. * @hidden
  40817. * Converts the render layer of xrSession to a render target
  40818. * @param session session to create render target for
  40819. * @param scene scene the new render target should be created for
  40820. */ private static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  40821. /**
  40822. * Disposes of the session manager
  40823. */
  40824. dispose(): void;
  40825. }
  40826. }
  40827. declare module BABYLON {
  40828. /**
  40829. * WebXR Camera which holds the views for the xrSession
  40830. * @see https://doc.babylonjs.com/how_to/webxr
  40831. */
  40832. export class WebXRCamera extends FreeCamera {
  40833. private static _TmpMatrix;
  40834. /**
  40835. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40836. * @param name the name of the camera
  40837. * @param scene the scene to add the camera to
  40838. */
  40839. constructor(name: string, scene: Scene);
  40840. private _updateNumberOfRigCameras;
  40841. /** @hidden */ private _updateForDualEyeDebugging(pupilDistance?: number): void;
  40842. /**
  40843. * Updates the cameras position from the current pose information of the XR session
  40844. * @param xrSessionManager the session containing pose information
  40845. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40846. */
  40847. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40848. }
  40849. }
  40850. declare module BABYLON {
  40851. /**
  40852. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40853. */
  40854. export class WebXRManagedOutputCanvas implements IDisposable {
  40855. private helper;
  40856. private _canvas;
  40857. /**
  40858. * xrpresent context of the canvas which can be used to display/mirror xr content
  40859. */
  40860. canvasContext: WebGLRenderingContext;
  40861. /**
  40862. * xr layer for the canvas
  40863. */
  40864. xrLayer: Nullable<XRWebGLLayer>;
  40865. /**
  40866. * Initializes the xr layer for the session
  40867. * @param xrSession xr session
  40868. * @returns a promise that will resolve once the XR Layer has been created
  40869. */
  40870. initializeXRLayerAsync(xrSession: any): any;
  40871. /**
  40872. * Initializes the canvas to be added/removed upon entering/exiting xr
  40873. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40874. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40875. */
  40876. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40877. /**
  40878. * Disposes of the object
  40879. */
  40880. dispose(): void;
  40881. private _setManagedOutputCanvas;
  40882. private _addCanvas;
  40883. private _removeCanvas;
  40884. }
  40885. }
  40886. declare module BABYLON {
  40887. /**
  40888. * States of the webXR experience
  40889. */
  40890. export enum WebXRState {
  40891. /**
  40892. * Transitioning to being in XR mode
  40893. */
  40894. ENTERING_XR = 0,
  40895. /**
  40896. * Transitioning to non XR mode
  40897. */
  40898. EXITING_XR = 1,
  40899. /**
  40900. * In XR mode and presenting
  40901. */
  40902. IN_XR = 2,
  40903. /**
  40904. * Not entered XR mode
  40905. */
  40906. NOT_IN_XR = 3
  40907. }
  40908. /**
  40909. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  40910. * @see https://doc.babylonjs.com/how_to/webxr
  40911. */
  40912. export class WebXRExperienceHelper implements IDisposable {
  40913. private scene;
  40914. /**
  40915. * 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
  40916. */
  40917. container: AbstractMesh;
  40918. /**
  40919. * Camera used to render xr content
  40920. */
  40921. camera: WebXRCamera;
  40922. /**
  40923. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40924. */
  40925. state: WebXRState;
  40926. private _setState;
  40927. private static _TmpVector;
  40928. /**
  40929. * Fires when the state of the experience helper has changed
  40930. */
  40931. onStateChangedObservable: Observable<WebXRState>;
  40932. /** Session manager used to keep track of xr session */
  40933. sessionManager: WebXRSessionManager;
  40934. private _nonVRCamera;
  40935. private _originalSceneAutoClear;
  40936. private _supported;
  40937. /**
  40938. * Creates the experience helper
  40939. * @param scene the scene to attach the experience helper to
  40940. * @returns a promise for the experience helper
  40941. */
  40942. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40943. /**
  40944. * Creates a WebXRExperienceHelper
  40945. * @param scene The scene the helper should be created in
  40946. */
  40947. private constructor();
  40948. /**
  40949. * Exits XR mode and returns the scene to its original state
  40950. * @returns promise that resolves after xr mode has exited
  40951. */
  40952. exitXRAsync(): Promise<unknown>;
  40953. /**
  40954. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40955. * @param sessionCreationOptions options for the XR session
  40956. * @param referenceSpaceType frame of reference of the XR session
  40957. * @param outputCanvas the output canvas that will be used to enter XR mode
  40958. * @returns promise that resolves after xr mode has entered
  40959. */
  40960. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  40961. /**
  40962. * Updates the global position of the camera by moving the camera's container
  40963. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40964. * @param position The desired global position of the camera
  40965. */
  40966. setPositionOfCameraUsingContainer(position: Vector3): void;
  40967. /**
  40968. * Rotates the xr camera by rotating the camera's container around the camera's position
  40969. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40970. * @param rotation the desired quaternion rotation to apply to the camera
  40971. */
  40972. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40973. /**
  40974. * Disposes of the experience helper
  40975. */
  40976. dispose(): void;
  40977. }
  40978. }
  40979. declare module BABYLON {
  40980. /**
  40981. * Button which can be used to enter a different mode of XR
  40982. */
  40983. export class WebXREnterExitUIButton {
  40984. /** button element */
  40985. element: HTMLElement;
  40986. /** XR initialization options for the button */
  40987. sessionMode: XRSessionMode;
  40988. /** Reference space type */
  40989. referenceSpaceType: XRReferenceSpaceType;
  40990. /**
  40991. * Creates a WebXREnterExitUIButton
  40992. * @param element button element
  40993. * @param sessionMode XR initialization session mode
  40994. * @param referenceSpaceType the type of reference space to be used
  40995. */
  40996. constructor(
  40997. /** button element */
  40998. element: HTMLElement,
  40999. /** XR initialization options for the button */
  41000. sessionMode: XRSessionMode,
  41001. /** Reference space type */
  41002. referenceSpaceType: XRReferenceSpaceType);
  41003. /**
  41004. * Overwritable function which can be used to update the button's visuals when the state changes
  41005. * @param activeButton the current active button in the UI
  41006. */
  41007. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41008. }
  41009. /**
  41010. * Options to create the webXR UI
  41011. */
  41012. export class WebXREnterExitUIOptions {
  41013. /**
  41014. * Context to enter xr with
  41015. */
  41016. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  41017. /**
  41018. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41019. */
  41020. customButtons?: Array<WebXREnterExitUIButton>;
  41021. }
  41022. /**
  41023. * UI to allow the user to enter/exit XR mode
  41024. */
  41025. export class WebXREnterExitUI implements IDisposable {
  41026. private scene;
  41027. private _overlay;
  41028. private _buttons;
  41029. private _activeButton;
  41030. /**
  41031. * Fired every time the active button is changed.
  41032. *
  41033. * When xr is entered via a button that launches xr that button will be the callback parameter
  41034. *
  41035. * When exiting xr the callback parameter will be null)
  41036. */
  41037. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41038. /**
  41039. * Creates UI to allow the user to enter/exit XR mode
  41040. * @param scene the scene to add the ui to
  41041. * @param helper the xr experience helper to enter/exit xr with
  41042. * @param options options to configure the UI
  41043. * @returns the created ui
  41044. */
  41045. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41046. private constructor();
  41047. private _updateButtons;
  41048. /**
  41049. * Disposes of the object
  41050. */
  41051. dispose(): void;
  41052. }
  41053. }
  41054. declare module BABYLON {
  41055. /**
  41056. * Represents an XR input
  41057. */
  41058. export class WebXRController {
  41059. private scene;
  41060. /** The underlying input source for the controller */
  41061. inputSource: XRInputSource;
  41062. private parentContainer;
  41063. /**
  41064. * 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
  41065. */
  41066. grip?: AbstractMesh;
  41067. /**
  41068. * Pointer which can be used to select objects or attach a visible laser to
  41069. */
  41070. pointer: AbstractMesh;
  41071. /**
  41072. * Event that fires when the controller is removed/disposed
  41073. */
  41074. onDisposeObservable: Observable<{}>;
  41075. private _tmpMatrix;
  41076. private _tmpQuaternion;
  41077. private _tmpVector;
  41078. /**
  41079. * Creates the controller
  41080. * @see https://doc.babylonjs.com/how_to/webxr
  41081. * @param scene the scene which the controller should be associated to
  41082. * @param inputSource the underlying input source for the controller
  41083. * @param parentContainer parent that the controller meshes should be children of
  41084. */
  41085. constructor(scene: Scene,
  41086. /** The underlying input source for the controller */
  41087. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  41088. /**
  41089. * Updates the controller pose based on the given XRFrame
  41090. * @param xrFrame xr frame to update the pose with
  41091. * @param referenceSpace reference space to use
  41092. */
  41093. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  41094. /**
  41095. * Gets a world space ray coming from the controller
  41096. * @param result the resulting ray
  41097. */
  41098. getWorldPointerRayToRef(result: Ray): void;
  41099. /**
  41100. * Disposes of the object
  41101. */
  41102. dispose(): void;
  41103. }
  41104. }
  41105. declare module BABYLON {
  41106. /**
  41107. * XR input used to track XR inputs such as controllers/rays
  41108. */
  41109. export class WebXRInput implements IDisposable {
  41110. /**
  41111. * Base experience the input listens to
  41112. */
  41113. baseExperience: WebXRExperienceHelper;
  41114. /**
  41115. * XR controllers being tracked
  41116. */
  41117. controllers: Array<WebXRController>;
  41118. private _frameObserver;
  41119. private _stateObserver;
  41120. /**
  41121. * Event when a controller has been connected/added
  41122. */
  41123. onControllerAddedObservable: Observable<WebXRController>;
  41124. /**
  41125. * Event when a controller has been removed/disconnected
  41126. */
  41127. onControllerRemovedObservable: Observable<WebXRController>;
  41128. /**
  41129. * Initializes the WebXRInput
  41130. * @param baseExperience experience helper which the input should be created for
  41131. */
  41132. constructor(
  41133. /**
  41134. * Base experience the input listens to
  41135. */
  41136. baseExperience: WebXRExperienceHelper);
  41137. private _onInputSourcesChange;
  41138. private _addAndRemoveControllers;
  41139. /**
  41140. * Disposes of the object
  41141. */
  41142. dispose(): void;
  41143. }
  41144. }
  41145. declare module BABYLON {
  41146. /**
  41147. * Enables teleportation
  41148. */
  41149. export class WebXRControllerTeleportation {
  41150. private _teleportationFillColor;
  41151. private _teleportationBorderColor;
  41152. private _tmpRay;
  41153. private _tmpVector;
  41154. /**
  41155. * Creates a WebXRControllerTeleportation
  41156. * @param input input manager to add teleportation to
  41157. * @param floorMeshes floormeshes which can be teleported to
  41158. */
  41159. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  41160. }
  41161. }
  41162. declare module BABYLON {
  41163. /**
  41164. * Handles pointer input automatically for the pointer of XR controllers
  41165. */
  41166. export class WebXRControllerPointerSelection {
  41167. private static _idCounter;
  41168. private _tmpRay;
  41169. /**
  41170. * Creates a WebXRControllerPointerSelection
  41171. * @param input input manager to setup pointer selection
  41172. */
  41173. constructor(input: WebXRInput);
  41174. private _convertNormalToDirectionOfRay;
  41175. private _updatePointerDistance;
  41176. }
  41177. }
  41178. declare module BABYLON {
  41179. /**
  41180. * Class used to represent data loading progression
  41181. */
  41182. export class SceneLoaderProgressEvent {
  41183. /** defines if data length to load can be evaluated */
  41184. readonly lengthComputable: boolean;
  41185. /** defines the loaded data length */
  41186. readonly loaded: number;
  41187. /** defines the data length to load */
  41188. readonly total: number;
  41189. /**
  41190. * Create a new progress event
  41191. * @param lengthComputable defines if data length to load can be evaluated
  41192. * @param loaded defines the loaded data length
  41193. * @param total defines the data length to load
  41194. */
  41195. constructor(
  41196. /** defines if data length to load can be evaluated */
  41197. lengthComputable: boolean,
  41198. /** defines the loaded data length */
  41199. loaded: number,
  41200. /** defines the data length to load */
  41201. total: number);
  41202. /**
  41203. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41204. * @param event defines the source event
  41205. * @returns a new SceneLoaderProgressEvent
  41206. */
  41207. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41208. }
  41209. /**
  41210. * Interface used by SceneLoader plugins to define supported file extensions
  41211. */
  41212. export interface ISceneLoaderPluginExtensions {
  41213. /**
  41214. * Defines the list of supported extensions
  41215. */
  41216. [extension: string]: {
  41217. isBinary: boolean;
  41218. };
  41219. }
  41220. /**
  41221. * Interface used by SceneLoader plugin factory
  41222. */
  41223. export interface ISceneLoaderPluginFactory {
  41224. /**
  41225. * Defines the name of the factory
  41226. */
  41227. name: string;
  41228. /**
  41229. * Function called to create a new plugin
  41230. * @return the new plugin
  41231. */
  41232. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41233. /**
  41234. * The callback that returns true if the data can be directly loaded.
  41235. * @param data string containing the file data
  41236. * @returns if the data can be loaded directly
  41237. */
  41238. canDirectLoad?(data: string): boolean;
  41239. }
  41240. /**
  41241. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  41242. */
  41243. export interface ISceneLoaderPluginBase {
  41244. /**
  41245. * The friendly name of this plugin.
  41246. */
  41247. name: string;
  41248. /**
  41249. * The file extensions supported by this plugin.
  41250. */
  41251. extensions: string | ISceneLoaderPluginExtensions;
  41252. /**
  41253. * The callback called when loading from a url.
  41254. * @param scene scene loading this url
  41255. * @param url url to load
  41256. * @param onSuccess callback called when the file successfully loads
  41257. * @param onProgress callback called while file is loading (if the server supports this mode)
  41258. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41259. * @param onError callback called when the file fails to load
  41260. * @returns a file request object
  41261. */
  41262. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  41263. /**
  41264. * The callback called when loading from a file object.
  41265. * @param scene scene loading this file
  41266. * @param file defines the file to load
  41267. * @param onSuccess defines the callback to call when data is loaded
  41268. * @param onProgress defines the callback to call during loading process
  41269. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  41270. * @param onError defines the callback to call when an error occurs
  41271. * @returns a file request object
  41272. */
  41273. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  41274. /**
  41275. * The callback that returns true if the data can be directly loaded.
  41276. * @param data string containing the file data
  41277. * @returns if the data can be loaded directly
  41278. */
  41279. canDirectLoad?(data: string): boolean;
  41280. /**
  41281. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  41282. * @param scene scene loading this data
  41283. * @param data string containing the data
  41284. * @returns data to pass to the plugin
  41285. */
  41286. directLoad?(scene: Scene, data: string): any;
  41287. /**
  41288. * The callback that allows custom handling of the root url based on the response url.
  41289. * @param rootUrl the original root url
  41290. * @param responseURL the response url if available
  41291. * @returns the new root url
  41292. */
  41293. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  41294. }
  41295. /**
  41296. * Interface used to define a SceneLoader plugin
  41297. */
  41298. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  41299. /**
  41300. * Import meshes into a scene.
  41301. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41302. * @param scene The scene to import into
  41303. * @param data The data to import
  41304. * @param rootUrl The root url for scene and resources
  41305. * @param meshes The meshes array to import into
  41306. * @param particleSystems The particle systems array to import into
  41307. * @param skeletons The skeletons array to import into
  41308. * @param onError The callback when import fails
  41309. * @returns True if successful or false otherwise
  41310. */
  41311. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41312. /**
  41313. * Load into a scene.
  41314. * @param scene The scene to load into
  41315. * @param data The data to import
  41316. * @param rootUrl The root url for scene and resources
  41317. * @param onError The callback when import fails
  41318. * @returns True if successful or false otherwise
  41319. */
  41320. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41321. /**
  41322. * Load into an asset container.
  41323. * @param scene The scene to load into
  41324. * @param data The data to import
  41325. * @param rootUrl The root url for scene and resources
  41326. * @param onError The callback when import fails
  41327. * @returns The loaded asset container
  41328. */
  41329. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41330. }
  41331. /**
  41332. * Interface used to define an async SceneLoader plugin
  41333. */
  41334. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  41335. /**
  41336. * Import meshes into a scene.
  41337. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41338. * @param scene The scene to import into
  41339. * @param data The data to import
  41340. * @param rootUrl The root url for scene and resources
  41341. * @param onProgress The callback when the load progresses
  41342. * @param fileName Defines the name of the file to load
  41343. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41344. */
  41345. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41346. meshes: AbstractMesh[];
  41347. particleSystems: IParticleSystem[];
  41348. skeletons: Skeleton[];
  41349. animationGroups: AnimationGroup[];
  41350. }>;
  41351. /**
  41352. * Load into a scene.
  41353. * @param scene The scene to load into
  41354. * @param data The data to import
  41355. * @param rootUrl The root url for scene and resources
  41356. * @param onProgress The callback when the load progresses
  41357. * @param fileName Defines the name of the file to load
  41358. * @returns Nothing
  41359. */
  41360. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41361. /**
  41362. * Load into an asset container.
  41363. * @param scene The scene to load into
  41364. * @param data The data to import
  41365. * @param rootUrl The root url for scene and resources
  41366. * @param onProgress The callback when the load progresses
  41367. * @param fileName Defines the name of the file to load
  41368. * @returns The loaded asset container
  41369. */
  41370. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41371. }
  41372. /**
  41373. * Class used to load scene from various file formats using registered plugins
  41374. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41375. */
  41376. export class SceneLoader {
  41377. /**
  41378. * No logging while loading
  41379. */
  41380. static readonly NO_LOGGING: number;
  41381. /**
  41382. * Minimal logging while loading
  41383. */
  41384. static readonly MINIMAL_LOGGING: number;
  41385. /**
  41386. * Summary logging while loading
  41387. */
  41388. static readonly SUMMARY_LOGGING: number;
  41389. /**
  41390. * Detailled logging while loading
  41391. */
  41392. static readonly DETAILED_LOGGING: number;
  41393. /**
  41394. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41395. */
  41396. static ForceFullSceneLoadingForIncremental: boolean;
  41397. /**
  41398. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41399. */
  41400. static ShowLoadingScreen: boolean;
  41401. /**
  41402. * Defines the current logging level (while loading the scene)
  41403. * @ignorenaming
  41404. */
  41405. static loggingLevel: number;
  41406. /**
  41407. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41408. */
  41409. static CleanBoneMatrixWeights: boolean;
  41410. /**
  41411. * Event raised when a plugin is used to load a scene
  41412. */
  41413. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41414. private static _registeredPlugins;
  41415. private static _getDefaultPlugin;
  41416. private static _getPluginForExtension;
  41417. private static _getPluginForDirectLoad;
  41418. private static _getPluginForFilename;
  41419. private static _getDirectLoad;
  41420. private static _loadData;
  41421. private static _getFileInfo;
  41422. /**
  41423. * Gets a plugin that can load the given extension
  41424. * @param extension defines the extension to load
  41425. * @returns a plugin or null if none works
  41426. */
  41427. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41428. /**
  41429. * Gets a boolean indicating that the given extension can be loaded
  41430. * @param extension defines the extension to load
  41431. * @returns true if the extension is supported
  41432. */
  41433. static IsPluginForExtensionAvailable(extension: string): boolean;
  41434. /**
  41435. * Adds a new plugin to the list of registered plugins
  41436. * @param plugin defines the plugin to add
  41437. */
  41438. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41439. /**
  41440. * Import meshes into a scene
  41441. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41442. * @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)
  41443. * @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)
  41444. * @param scene the instance of BABYLON.Scene to append to
  41445. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41446. * @param onProgress a callback with a progress event for each file being loaded
  41447. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41448. * @param pluginExtension the extension used to determine the plugin
  41449. * @returns The loaded plugin
  41450. */
  41451. 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>;
  41452. /**
  41453. * Import meshes into a scene
  41454. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41455. * @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)
  41456. * @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)
  41457. * @param scene the instance of BABYLON.Scene to append to
  41458. * @param onProgress a callback with a progress event for each file being loaded
  41459. * @param pluginExtension the extension used to determine the plugin
  41460. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41461. */
  41462. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41463. meshes: AbstractMesh[];
  41464. particleSystems: IParticleSystem[];
  41465. skeletons: Skeleton[];
  41466. animationGroups: AnimationGroup[];
  41467. }>;
  41468. /**
  41469. * Load a scene
  41470. * @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)
  41471. * @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)
  41472. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41473. * @param onSuccess a callback with the scene when import succeeds
  41474. * @param onProgress a callback with a progress event for each file being loaded
  41475. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41476. * @param pluginExtension the extension used to determine the plugin
  41477. * @returns The loaded plugin
  41478. */
  41479. 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>;
  41480. /**
  41481. * Load a scene
  41482. * @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)
  41483. * @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)
  41484. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41485. * @param onProgress a callback with a progress event for each file being loaded
  41486. * @param pluginExtension the extension used to determine the plugin
  41487. * @returns The loaded scene
  41488. */
  41489. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41490. /**
  41491. * Append a scene
  41492. * @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)
  41493. * @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)
  41494. * @param scene is the instance of BABYLON.Scene to append to
  41495. * @param onSuccess a callback with the scene when import succeeds
  41496. * @param onProgress a callback with a progress event for each file being loaded
  41497. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41498. * @param pluginExtension the extension used to determine the plugin
  41499. * @returns The loaded plugin
  41500. */
  41501. 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>;
  41502. /**
  41503. * Append a scene
  41504. * @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)
  41505. * @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)
  41506. * @param scene is the instance of BABYLON.Scene to append to
  41507. * @param onProgress a callback with a progress event for each file being loaded
  41508. * @param pluginExtension the extension used to determine the plugin
  41509. * @returns The given scene
  41510. */
  41511. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41512. /**
  41513. * Load a scene into an asset container
  41514. * @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)
  41515. * @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)
  41516. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41517. * @param onSuccess a callback with the scene when import succeeds
  41518. * @param onProgress a callback with a progress event for each file being loaded
  41519. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41520. * @param pluginExtension the extension used to determine the plugin
  41521. * @returns The loaded plugin
  41522. */
  41523. 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>;
  41524. /**
  41525. * Load a scene into an asset container
  41526. * @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)
  41527. * @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)
  41528. * @param scene is the instance of Scene to append to
  41529. * @param onProgress a callback with a progress event for each file being loaded
  41530. * @param pluginExtension the extension used to determine the plugin
  41531. * @returns The loaded asset container
  41532. */
  41533. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41534. }
  41535. }
  41536. declare module BABYLON {
  41537. /**
  41538. * Generic Controller
  41539. */
  41540. export class GenericController extends WebVRController {
  41541. /**
  41542. * Base Url for the controller model.
  41543. */
  41544. static readonly MODEL_BASE_URL: string;
  41545. /**
  41546. * File name for the controller model.
  41547. */
  41548. static readonly MODEL_FILENAME: string;
  41549. /**
  41550. * Creates a new GenericController from a gamepad
  41551. * @param vrGamepad the gamepad that the controller should be created from
  41552. */
  41553. constructor(vrGamepad: any);
  41554. /**
  41555. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41556. * @param scene scene in which to add meshes
  41557. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41558. */
  41559. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41560. /**
  41561. * Called once for each button that changed state since the last frame
  41562. * @param buttonIdx Which button index changed
  41563. * @param state New state of the button
  41564. * @param changes Which properties on the state changed since last frame
  41565. */
  41566. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41567. }
  41568. }
  41569. declare module BABYLON {
  41570. /**
  41571. * Defines the WindowsMotionController object that the state of the windows motion controller
  41572. */
  41573. export class WindowsMotionController extends WebVRController {
  41574. /**
  41575. * The base url used to load the left and right controller models
  41576. */
  41577. static MODEL_BASE_URL: string;
  41578. /**
  41579. * The name of the left controller model file
  41580. */
  41581. static MODEL_LEFT_FILENAME: string;
  41582. /**
  41583. * The name of the right controller model file
  41584. */
  41585. static MODEL_RIGHT_FILENAME: string;
  41586. /**
  41587. * The controller name prefix for this controller type
  41588. */
  41589. static readonly GAMEPAD_ID_PREFIX: string;
  41590. /**
  41591. * The controller id pattern for this controller type
  41592. */
  41593. private static readonly GAMEPAD_ID_PATTERN;
  41594. private _loadedMeshInfo;
  41595. private readonly _mapping;
  41596. /**
  41597. * Fired when the trackpad on this controller is clicked
  41598. */
  41599. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41600. /**
  41601. * Fired when the trackpad on this controller is modified
  41602. */
  41603. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41604. /**
  41605. * The current x and y values of this controller's trackpad
  41606. */
  41607. trackpad: StickValues;
  41608. /**
  41609. * Creates a new WindowsMotionController from a gamepad
  41610. * @param vrGamepad the gamepad that the controller should be created from
  41611. */
  41612. constructor(vrGamepad: any);
  41613. /**
  41614. * Fired when the trigger on this controller is modified
  41615. */
  41616. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41617. /**
  41618. * Fired when the menu button on this controller is modified
  41619. */
  41620. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41621. /**
  41622. * Fired when the grip button on this controller is modified
  41623. */
  41624. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41625. /**
  41626. * Fired when the thumbstick button on this controller is modified
  41627. */
  41628. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41629. /**
  41630. * Fired when the touchpad button on this controller is modified
  41631. */
  41632. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41633. /**
  41634. * Fired when the touchpad values on this controller are modified
  41635. */
  41636. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41637. private _updateTrackpad;
  41638. /**
  41639. * Called once per frame by the engine.
  41640. */
  41641. update(): void;
  41642. /**
  41643. * Called once for each button that changed state since the last frame
  41644. * @param buttonIdx Which button index changed
  41645. * @param state New state of the button
  41646. * @param changes Which properties on the state changed since last frame
  41647. */
  41648. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41649. /**
  41650. * Moves the buttons on the controller mesh based on their current state
  41651. * @param buttonName the name of the button to move
  41652. * @param buttonValue the value of the button which determines the buttons new position
  41653. */
  41654. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  41655. /**
  41656. * Moves the axis on the controller mesh based on its current state
  41657. * @param axis the index of the axis
  41658. * @param axisValue the value of the axis which determines the meshes new position
  41659. * @hidden
  41660. */
  41661. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  41662. /**
  41663. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41664. * @param scene scene in which to add meshes
  41665. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41666. */
  41667. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  41668. /**
  41669. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  41670. * can be transformed by button presses and axes values, based on this._mapping.
  41671. *
  41672. * @param scene scene in which the meshes exist
  41673. * @param meshes list of meshes that make up the controller model to process
  41674. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  41675. */
  41676. private processModel;
  41677. private createMeshInfo;
  41678. /**
  41679. * Gets the ray of the controller in the direction the controller is pointing
  41680. * @param length the length the resulting ray should be
  41681. * @returns a ray in the direction the controller is pointing
  41682. */
  41683. getForwardRay(length?: number): Ray;
  41684. /**
  41685. * Disposes of the controller
  41686. */
  41687. dispose(): void;
  41688. }
  41689. }
  41690. declare module BABYLON {
  41691. /**
  41692. * Oculus Touch Controller
  41693. */
  41694. export class OculusTouchController extends WebVRController {
  41695. /**
  41696. * Base Url for the controller model.
  41697. */
  41698. static MODEL_BASE_URL: string;
  41699. /**
  41700. * File name for the left controller model.
  41701. */
  41702. static MODEL_LEFT_FILENAME: string;
  41703. /**
  41704. * File name for the right controller model.
  41705. */
  41706. static MODEL_RIGHT_FILENAME: string;
  41707. /**
  41708. * Base Url for the Quest controller model.
  41709. */
  41710. static QUEST_MODEL_BASE_URL: string;
  41711. /**
  41712. * @hidden
  41713. * If the controllers are running on a device that needs the updated Quest controller models
  41714. */ private static _IsQuest: boolean;
  41715. /**
  41716. * Fired when the secondary trigger on this controller is modified
  41717. */
  41718. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41719. /**
  41720. * Fired when the thumb rest on this controller is modified
  41721. */
  41722. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41723. /**
  41724. * Creates a new OculusTouchController from a gamepad
  41725. * @param vrGamepad the gamepad that the controller should be created from
  41726. */
  41727. constructor(vrGamepad: any);
  41728. /**
  41729. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41730. * @param scene scene in which to add meshes
  41731. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41732. */
  41733. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41734. /**
  41735. * Fired when the A button on this controller is modified
  41736. */
  41737. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41738. /**
  41739. * Fired when the B button on this controller is modified
  41740. */
  41741. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41742. /**
  41743. * Fired when the X button on this controller is modified
  41744. */
  41745. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41746. /**
  41747. * Fired when the Y button on this controller is modified
  41748. */
  41749. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41750. /**
  41751. * Called once for each button that changed state since the last frame
  41752. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  41753. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  41754. * 2) secondary trigger (same)
  41755. * 3) A (right) X (left), touch, pressed = value
  41756. * 4) B / Y
  41757. * 5) thumb rest
  41758. * @param buttonIdx Which button index changed
  41759. * @param state New state of the button
  41760. * @param changes Which properties on the state changed since last frame
  41761. */
  41762. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41763. }
  41764. }
  41765. declare module BABYLON {
  41766. /**
  41767. * Vive Controller
  41768. */
  41769. export class ViveController extends WebVRController {
  41770. /**
  41771. * Base Url for the controller model.
  41772. */
  41773. static MODEL_BASE_URL: string;
  41774. /**
  41775. * File name for the controller model.
  41776. */
  41777. static MODEL_FILENAME: string;
  41778. /**
  41779. * Creates a new ViveController from a gamepad
  41780. * @param vrGamepad the gamepad that the controller should be created from
  41781. */
  41782. constructor(vrGamepad: any);
  41783. /**
  41784. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41785. * @param scene scene in which to add meshes
  41786. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41787. */
  41788. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41789. /**
  41790. * Fired when the left button on this controller is modified
  41791. */
  41792. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41793. /**
  41794. * Fired when the right button on this controller is modified
  41795. */
  41796. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41797. /**
  41798. * Fired when the menu button on this controller is modified
  41799. */
  41800. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41801. /**
  41802. * Called once for each button that changed state since the last frame
  41803. * Vive mapping:
  41804. * 0: touchpad
  41805. * 1: trigger
  41806. * 2: left AND right buttons
  41807. * 3: menu button
  41808. * @param buttonIdx Which button index changed
  41809. * @param state New state of the button
  41810. * @param changes Which properties on the state changed since last frame
  41811. */
  41812. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41813. }
  41814. }
  41815. declare module BABYLON {
  41816. /**
  41817. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  41818. */
  41819. export class WebXRControllerModelLoader {
  41820. /**
  41821. * Creates the WebXRControllerModelLoader
  41822. * @param input xr input that creates the controllers
  41823. */
  41824. constructor(input: WebXRInput);
  41825. }
  41826. }
  41827. declare module BABYLON {
  41828. /**
  41829. * Contains an array of blocks representing the octree
  41830. */
  41831. export interface IOctreeContainer<T> {
  41832. /**
  41833. * Blocks within the octree
  41834. */
  41835. blocks: Array<OctreeBlock<T>>;
  41836. }
  41837. /**
  41838. * Class used to store a cell in an octree
  41839. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41840. */
  41841. export class OctreeBlock<T> {
  41842. /**
  41843. * Gets the content of the current block
  41844. */
  41845. entries: T[];
  41846. /**
  41847. * Gets the list of block children
  41848. */
  41849. blocks: Array<OctreeBlock<T>>;
  41850. private _depth;
  41851. private _maxDepth;
  41852. private _capacity;
  41853. private _minPoint;
  41854. private _maxPoint;
  41855. private _boundingVectors;
  41856. private _creationFunc;
  41857. /**
  41858. * Creates a new block
  41859. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41860. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41861. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41862. * @param depth defines the current depth of this block in the octree
  41863. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41864. * @param creationFunc defines a callback to call when an element is added to the block
  41865. */
  41866. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41867. /**
  41868. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41869. */
  41870. readonly capacity: number;
  41871. /**
  41872. * Gets the minimum vector (in world space) of the block's bounding box
  41873. */
  41874. readonly minPoint: Vector3;
  41875. /**
  41876. * Gets the maximum vector (in world space) of the block's bounding box
  41877. */
  41878. readonly maxPoint: Vector3;
  41879. /**
  41880. * Add a new element to this block
  41881. * @param entry defines the element to add
  41882. */
  41883. addEntry(entry: T): void;
  41884. /**
  41885. * Remove an element from this block
  41886. * @param entry defines the element to remove
  41887. */
  41888. removeEntry(entry: T): void;
  41889. /**
  41890. * Add an array of elements to this block
  41891. * @param entries defines the array of elements to add
  41892. */
  41893. addEntries(entries: T[]): void;
  41894. /**
  41895. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41896. * @param frustumPlanes defines the frustum planes to test
  41897. * @param selection defines the array to store current content if selection is positive
  41898. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41899. */
  41900. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41901. /**
  41902. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41903. * @param sphereCenter defines the bounding sphere center
  41904. * @param sphereRadius defines the bounding sphere radius
  41905. * @param selection defines the array to store current content if selection is positive
  41906. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41907. */
  41908. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41909. /**
  41910. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41911. * @param ray defines the ray to test with
  41912. * @param selection defines the array to store current content if selection is positive
  41913. */
  41914. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41915. /**
  41916. * Subdivide the content into child blocks (this block will then be empty)
  41917. */
  41918. createInnerBlocks(): void;
  41919. /**
  41920. * @hidden
  41921. */ 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;
  41922. }
  41923. }
  41924. declare module BABYLON {
  41925. /**
  41926. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41927. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41928. */
  41929. export class Octree<T> {
  41930. /** 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.) */
  41931. maxDepth: number;
  41932. /**
  41933. * Blocks within the octree containing objects
  41934. */
  41935. blocks: Array<OctreeBlock<T>>;
  41936. /**
  41937. * Content stored in the octree
  41938. */
  41939. dynamicContent: T[];
  41940. private _maxBlockCapacity;
  41941. private _selectionContent;
  41942. private _creationFunc;
  41943. /**
  41944. * Creates a octree
  41945. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41946. * @param creationFunc function to be used to instatiate the octree
  41947. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41948. * @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.)
  41949. */
  41950. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41951. /** 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.) */
  41952. maxDepth?: number);
  41953. /**
  41954. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41955. * @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);
  41956. * @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);
  41957. * @param entries meshes to be added to the octree blocks
  41958. */
  41959. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41960. /**
  41961. * Adds a mesh to the octree
  41962. * @param entry Mesh to add to the octree
  41963. */
  41964. addMesh(entry: T): void;
  41965. /**
  41966. * Remove an element from the octree
  41967. * @param entry defines the element to remove
  41968. */
  41969. removeMesh(entry: T): void;
  41970. /**
  41971. * Selects an array of meshes within the frustum
  41972. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41973. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41974. * @returns array of meshes within the frustum
  41975. */
  41976. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41977. /**
  41978. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41979. * @param sphereCenter defines the bounding sphere center
  41980. * @param sphereRadius defines the bounding sphere radius
  41981. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41982. * @returns an array of objects that intersect the sphere
  41983. */
  41984. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41985. /**
  41986. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41987. * @param ray defines the ray to test with
  41988. * @returns array of intersected objects
  41989. */
  41990. intersectsRay(ray: Ray): SmartArray<T>;
  41991. /**
  41992. * Adds a mesh into the octree block if it intersects the block
  41993. */
  41994. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41995. /**
  41996. * Adds a submesh into the octree block if it intersects the block
  41997. */
  41998. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41999. }
  42000. }
  42001. declare module BABYLON {
  42002. interface Scene {
  42003. /**
  42004. * @hidden
  42005. * Backing Filed
  42006. */ private _selectionOctree: Octree<AbstractMesh>;
  42007. /**
  42008. * Gets the octree used to boost mesh selection (picking)
  42009. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42010. */
  42011. selectionOctree: Octree<AbstractMesh>;
  42012. /**
  42013. * Creates or updates the octree used to boost selection (picking)
  42014. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42015. * @param maxCapacity defines the maximum capacity per leaf
  42016. * @param maxDepth defines the maximum depth of the octree
  42017. * @returns an octree of AbstractMesh
  42018. */
  42019. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42020. }
  42021. interface AbstractMesh {
  42022. /**
  42023. * @hidden
  42024. * Backing Field
  42025. */ private _submeshesOctree: Octree<SubMesh>;
  42026. /**
  42027. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42028. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42029. * @param maxCapacity defines the maximum size of each block (64 by default)
  42030. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42031. * @returns the new octree
  42032. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42033. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42034. */
  42035. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42036. }
  42037. /**
  42038. * Defines the octree scene component responsible to manage any octrees
  42039. * in a given scene.
  42040. */
  42041. export class OctreeSceneComponent {
  42042. /**
  42043. * The component name help to identify the component in the list of scene components.
  42044. */
  42045. readonly name: string;
  42046. /**
  42047. * The scene the component belongs to.
  42048. */
  42049. scene: Scene;
  42050. /**
  42051. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42052. */
  42053. readonly checksIsEnabled: boolean;
  42054. /**
  42055. * Creates a new instance of the component for the given scene
  42056. * @param scene Defines the scene to register the component in
  42057. */
  42058. constructor(scene: Scene);
  42059. /**
  42060. * Registers the component in a given scene
  42061. */
  42062. register(): void;
  42063. /**
  42064. * Return the list of active meshes
  42065. * @returns the list of active meshes
  42066. */
  42067. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42068. /**
  42069. * Return the list of active sub meshes
  42070. * @param mesh The mesh to get the candidates sub meshes from
  42071. * @returns the list of active sub meshes
  42072. */
  42073. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42074. private _tempRay;
  42075. /**
  42076. * Return the list of sub meshes intersecting with a given local ray
  42077. * @param mesh defines the mesh to find the submesh for
  42078. * @param localRay defines the ray in local space
  42079. * @returns the list of intersecting sub meshes
  42080. */
  42081. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42082. /**
  42083. * Return the list of sub meshes colliding with a collider
  42084. * @param mesh defines the mesh to find the submesh for
  42085. * @param collider defines the collider to evaluate the collision against
  42086. * @returns the list of colliding sub meshes
  42087. */
  42088. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42089. /**
  42090. * Rebuilds the elements related to this component in case of
  42091. * context lost for instance.
  42092. */
  42093. rebuild(): void;
  42094. /**
  42095. * Disposes the component and the associated ressources.
  42096. */
  42097. dispose(): void;
  42098. }
  42099. }
  42100. declare module BABYLON {
  42101. /**
  42102. * Renders a layer on top of an existing scene
  42103. */
  42104. export class UtilityLayerRenderer implements IDisposable {
  42105. /** the original scene that will be rendered on top of */
  42106. originalScene: Scene;
  42107. private _pointerCaptures;
  42108. private _lastPointerEvents;
  42109. private static _DefaultUtilityLayer;
  42110. private static _DefaultKeepDepthUtilityLayer;
  42111. private _sharedGizmoLight;
  42112. private _renderCamera;
  42113. /**
  42114. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42115. * @returns the camera that is used when rendering the utility layer
  42116. */
  42117. getRenderCamera(): Nullable<Camera>;
  42118. /**
  42119. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42120. * @param cam the camera that should be used when rendering the utility layer
  42121. */
  42122. setRenderCamera(cam: Nullable<Camera>): void;
  42123. /**
  42124. * @hidden
  42125. * Light which used by gizmos to get light shading
  42126. */ private _getSharedGizmoLight(): HemisphericLight;
  42127. /**
  42128. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42129. */
  42130. pickUtilitySceneFirst: boolean;
  42131. /**
  42132. * 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)
  42133. */
  42134. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42135. /**
  42136. * 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)
  42137. */
  42138. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42139. /**
  42140. * The scene that is rendered on top of the original scene
  42141. */
  42142. utilityLayerScene: Scene;
  42143. /**
  42144. * If the utility layer should automatically be rendered on top of existing scene
  42145. */
  42146. shouldRender: boolean;
  42147. /**
  42148. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42149. */
  42150. onlyCheckPointerDownEvents: boolean;
  42151. /**
  42152. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42153. */
  42154. processAllEvents: boolean;
  42155. /**
  42156. * Observable raised when the pointer move from the utility layer scene to the main scene
  42157. */
  42158. onPointerOutObservable: Observable<number>;
  42159. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42160. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42161. private _afterRenderObserver;
  42162. private _sceneDisposeObserver;
  42163. private _originalPointerObserver;
  42164. /**
  42165. * Instantiates a UtilityLayerRenderer
  42166. * @param originalScene the original scene that will be rendered on top of
  42167. * @param handleEvents boolean indicating if the utility layer should handle events
  42168. */
  42169. constructor(
  42170. /** the original scene that will be rendered on top of */
  42171. originalScene: Scene, handleEvents?: boolean);
  42172. private _notifyObservers;
  42173. /**
  42174. * Renders the utility layers scene on top of the original scene
  42175. */
  42176. render(): void;
  42177. /**
  42178. * Disposes of the renderer
  42179. */
  42180. dispose(): void;
  42181. private _updateCamera;
  42182. }
  42183. }
  42184. declare module BABYLON {
  42185. /**
  42186. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42187. */
  42188. export class Gizmo implements IDisposable {
  42189. /** The utility layer the gizmo will be added to */
  42190. gizmoLayer: UtilityLayerRenderer;
  42191. /**
  42192. * The root mesh of the gizmo
  42193. */ private _rootMesh: Mesh;
  42194. private _attachedMesh;
  42195. /**
  42196. * Ratio for the scale of the gizmo (Default: 1)
  42197. */
  42198. scaleRatio: number;
  42199. /**
  42200. * If a custom mesh has been set (Default: false)
  42201. */
  42202. protected _customMeshSet: boolean;
  42203. /**
  42204. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42205. * * When set, interactions will be enabled
  42206. */
  42207. attachedMesh: Nullable<AbstractMesh>;
  42208. /**
  42209. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42210. * @param mesh The mesh to replace the default mesh of the gizmo
  42211. */
  42212. setCustomMesh(mesh: Mesh): void;
  42213. /**
  42214. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42215. */
  42216. updateGizmoRotationToMatchAttachedMesh: boolean;
  42217. /**
  42218. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42219. */
  42220. updateGizmoPositionToMatchAttachedMesh: boolean;
  42221. /**
  42222. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  42223. */
  42224. updateScale: boolean;
  42225. protected _interactionsEnabled: boolean;
  42226. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42227. private _beforeRenderObserver;
  42228. private _tempVector;
  42229. /**
  42230. * Creates a gizmo
  42231. * @param gizmoLayer The utility layer the gizmo will be added to
  42232. */
  42233. constructor(
  42234. /** The utility layer the gizmo will be added to */
  42235. gizmoLayer?: UtilityLayerRenderer);
  42236. /**
  42237. * Updates the gizmo to match the attached mesh's position/rotation
  42238. */
  42239. protected _update(): void;
  42240. /**
  42241. * Disposes of the gizmo
  42242. */
  42243. dispose(): void;
  42244. }
  42245. }
  42246. declare module BABYLON {
  42247. /**
  42248. * Single plane drag gizmo
  42249. */
  42250. export class PlaneDragGizmo extends Gizmo {
  42251. /**
  42252. * Drag behavior responsible for the gizmos dragging interactions
  42253. */
  42254. dragBehavior: PointerDragBehavior;
  42255. private _pointerObserver;
  42256. /**
  42257. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42258. */
  42259. snapDistance: number;
  42260. /**
  42261. * Event that fires each time the gizmo snaps to a new location.
  42262. * * snapDistance is the the change in distance
  42263. */
  42264. onSnapObservable: Observable<{
  42265. snapDistance: number;
  42266. }>;
  42267. private _plane;
  42268. private _coloredMaterial;
  42269. private _hoverMaterial;
  42270. private _isEnabled;
  42271. private _parent;
  42272. /** @hidden */ private static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42273. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42274. /**
  42275. * Creates a PlaneDragGizmo
  42276. * @param gizmoLayer The utility layer the gizmo will be added to
  42277. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42278. * @param color The color of the gizmo
  42279. */
  42280. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42281. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42282. /**
  42283. * If the gizmo is enabled
  42284. */
  42285. isEnabled: boolean;
  42286. /**
  42287. * Disposes of the gizmo
  42288. */
  42289. dispose(): void;
  42290. }
  42291. }
  42292. declare module BABYLON {
  42293. /**
  42294. * Gizmo that enables dragging a mesh along 3 axis
  42295. */
  42296. export class PositionGizmo extends Gizmo {
  42297. /**
  42298. * Internal gizmo used for interactions on the x axis
  42299. */
  42300. xGizmo: AxisDragGizmo;
  42301. /**
  42302. * Internal gizmo used for interactions on the y axis
  42303. */
  42304. yGizmo: AxisDragGizmo;
  42305. /**
  42306. * Internal gizmo used for interactions on the z axis
  42307. */
  42308. zGizmo: AxisDragGizmo;
  42309. /**
  42310. * Internal gizmo used for interactions on the yz plane
  42311. */
  42312. xPlaneGizmo: PlaneDragGizmo;
  42313. /**
  42314. * Internal gizmo used for interactions on the xz plane
  42315. */
  42316. yPlaneGizmo: PlaneDragGizmo;
  42317. /**
  42318. * Internal gizmo used for interactions on the xy plane
  42319. */
  42320. zPlaneGizmo: PlaneDragGizmo;
  42321. /**
  42322. * private variables
  42323. */
  42324. private _meshAttached;
  42325. private _updateGizmoRotationToMatchAttachedMesh;
  42326. private _snapDistance;
  42327. private _scaleRatio;
  42328. /** Fires an event when any of it's sub gizmos are dragged */
  42329. onDragStartObservable: Observable<unknown>;
  42330. /** Fires an event when any of it's sub gizmos are released from dragging */
  42331. onDragEndObservable: Observable<unknown>;
  42332. /**
  42333. * If set to true, planar drag is enabled
  42334. */
  42335. private _planarGizmoEnabled;
  42336. attachedMesh: Nullable<AbstractMesh>;
  42337. /**
  42338. * Creates a PositionGizmo
  42339. * @param gizmoLayer The utility layer the gizmo will be added to
  42340. */
  42341. constructor(gizmoLayer?: UtilityLayerRenderer);
  42342. /**
  42343. * If the planar drag gizmo is enabled
  42344. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42345. */
  42346. planarGizmoEnabled: boolean;
  42347. updateGizmoRotationToMatchAttachedMesh: boolean;
  42348. /**
  42349. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42350. */
  42351. snapDistance: number;
  42352. /**
  42353. * Ratio for the scale of the gizmo (Default: 1)
  42354. */
  42355. scaleRatio: number;
  42356. /**
  42357. * Disposes of the gizmo
  42358. */
  42359. dispose(): void;
  42360. /**
  42361. * CustomMeshes are not supported by this gizmo
  42362. * @param mesh The mesh to replace the default mesh of the gizmo
  42363. */
  42364. setCustomMesh(mesh: Mesh): void;
  42365. }
  42366. }
  42367. declare module BABYLON {
  42368. /**
  42369. * Single axis drag gizmo
  42370. */
  42371. export class AxisDragGizmo extends Gizmo {
  42372. /**
  42373. * Drag behavior responsible for the gizmos dragging interactions
  42374. */
  42375. dragBehavior: PointerDragBehavior;
  42376. private _pointerObserver;
  42377. /**
  42378. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42379. */
  42380. snapDistance: number;
  42381. /**
  42382. * Event that fires each time the gizmo snaps to a new location.
  42383. * * snapDistance is the the change in distance
  42384. */
  42385. onSnapObservable: Observable<{
  42386. snapDistance: number;
  42387. }>;
  42388. private _isEnabled;
  42389. private _parent;
  42390. private _arrow;
  42391. private _coloredMaterial;
  42392. private _hoverMaterial;
  42393. /** @hidden */ private static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42394. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42395. /**
  42396. * Creates an AxisDragGizmo
  42397. * @param gizmoLayer The utility layer the gizmo will be added to
  42398. * @param dragAxis The axis which the gizmo will be able to drag on
  42399. * @param color The color of the gizmo
  42400. */
  42401. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42402. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42403. /**
  42404. * If the gizmo is enabled
  42405. */
  42406. isEnabled: boolean;
  42407. /**
  42408. * Disposes of the gizmo
  42409. */
  42410. dispose(): void;
  42411. }
  42412. }
  42413. declare module BABYLON.Debug {
  42414. /**
  42415. * The Axes viewer will show 3 axes in a specific point in space
  42416. */
  42417. export class AxesViewer {
  42418. private _xAxis;
  42419. private _yAxis;
  42420. private _zAxis;
  42421. private _scaleLinesFactor;
  42422. private _instanced;
  42423. /**
  42424. * Gets the hosting scene
  42425. */
  42426. scene: Scene;
  42427. /**
  42428. * Gets or sets a number used to scale line length
  42429. */
  42430. scaleLines: number;
  42431. /** Gets the node hierarchy used to render x-axis */
  42432. readonly xAxis: TransformNode;
  42433. /** Gets the node hierarchy used to render y-axis */
  42434. readonly yAxis: TransformNode;
  42435. /** Gets the node hierarchy used to render z-axis */
  42436. readonly zAxis: TransformNode;
  42437. /**
  42438. * Creates a new AxesViewer
  42439. * @param scene defines the hosting scene
  42440. * @param scaleLines defines a number used to scale line length (1 by default)
  42441. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42442. * @param xAxis defines the node hierarchy used to render the x-axis
  42443. * @param yAxis defines the node hierarchy used to render the y-axis
  42444. * @param zAxis defines the node hierarchy used to render the z-axis
  42445. */
  42446. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42447. /**
  42448. * Force the viewer to update
  42449. * @param position defines the position of the viewer
  42450. * @param xaxis defines the x axis of the viewer
  42451. * @param yaxis defines the y axis of the viewer
  42452. * @param zaxis defines the z axis of the viewer
  42453. */
  42454. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42455. /**
  42456. * Creates an instance of this axes viewer.
  42457. * @returns a new axes viewer with instanced meshes
  42458. */
  42459. createInstance(): AxesViewer;
  42460. /** Releases resources */
  42461. dispose(): void;
  42462. private static _SetRenderingGroupId;
  42463. }
  42464. }
  42465. declare module BABYLON.Debug {
  42466. /**
  42467. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42468. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42469. */
  42470. export class BoneAxesViewer extends AxesViewer {
  42471. /**
  42472. * Gets or sets the target mesh where to display the axes viewer
  42473. */
  42474. mesh: Nullable<Mesh>;
  42475. /**
  42476. * Gets or sets the target bone where to display the axes viewer
  42477. */
  42478. bone: Nullable<Bone>;
  42479. /** Gets current position */
  42480. pos: Vector3;
  42481. /** Gets direction of X axis */
  42482. xaxis: Vector3;
  42483. /** Gets direction of Y axis */
  42484. yaxis: Vector3;
  42485. /** Gets direction of Z axis */
  42486. zaxis: Vector3;
  42487. /**
  42488. * Creates a new BoneAxesViewer
  42489. * @param scene defines the hosting scene
  42490. * @param bone defines the target bone
  42491. * @param mesh defines the target mesh
  42492. * @param scaleLines defines a scaling factor for line length (1 by default)
  42493. */
  42494. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42495. /**
  42496. * Force the viewer to update
  42497. */
  42498. update(): void;
  42499. /** Releases resources */
  42500. dispose(): void;
  42501. }
  42502. }
  42503. declare module BABYLON {
  42504. /**
  42505. * Interface used to define scene explorer extensibility option
  42506. */
  42507. export interface IExplorerExtensibilityOption {
  42508. /**
  42509. * Define the option label
  42510. */
  42511. label: string;
  42512. /**
  42513. * Defines the action to execute on click
  42514. */
  42515. action: (entity: any) => void;
  42516. }
  42517. /**
  42518. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42519. */
  42520. export interface IExplorerExtensibilityGroup {
  42521. /**
  42522. * Defines a predicate to test if a given type mut be extended
  42523. */
  42524. predicate: (entity: any) => boolean;
  42525. /**
  42526. * Gets the list of options added to a type
  42527. */
  42528. entries: IExplorerExtensibilityOption[];
  42529. }
  42530. /**
  42531. * Interface used to define the options to use to create the Inspector
  42532. */
  42533. export interface IInspectorOptions {
  42534. /**
  42535. * Display in overlay mode (default: false)
  42536. */
  42537. overlay?: boolean;
  42538. /**
  42539. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42540. */
  42541. globalRoot?: HTMLElement;
  42542. /**
  42543. * Display the Scene explorer
  42544. */
  42545. showExplorer?: boolean;
  42546. /**
  42547. * Display the property inspector
  42548. */
  42549. showInspector?: boolean;
  42550. /**
  42551. * Display in embed mode (both panes on the right)
  42552. */
  42553. embedMode?: boolean;
  42554. /**
  42555. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42556. */
  42557. handleResize?: boolean;
  42558. /**
  42559. * Allow the panes to popup (default: true)
  42560. */
  42561. enablePopup?: boolean;
  42562. /**
  42563. * Allow the panes to be closed by users (default: true)
  42564. */
  42565. enableClose?: boolean;
  42566. /**
  42567. * Optional list of extensibility entries
  42568. */
  42569. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42570. /**
  42571. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42572. */
  42573. inspectorURL?: string;
  42574. }
  42575. interface Scene {
  42576. /**
  42577. * @hidden
  42578. * Backing field
  42579. */ private _debugLayer: DebugLayer;
  42580. /**
  42581. * Gets the debug layer (aka Inspector) associated with the scene
  42582. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42583. */
  42584. debugLayer: DebugLayer;
  42585. }
  42586. /**
  42587. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42588. * what is happening in your scene
  42589. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42590. */
  42591. export class DebugLayer {
  42592. /**
  42593. * Define the url to get the inspector script from.
  42594. * By default it uses the babylonjs CDN.
  42595. * @ignoreNaming
  42596. */
  42597. static InspectorURL: string;
  42598. private _scene;
  42599. private BJSINSPECTOR;
  42600. private _onPropertyChangedObservable?;
  42601. /**
  42602. * Observable triggered when a property is changed through the inspector.
  42603. */
  42604. readonly onPropertyChangedObservable: any;
  42605. /**
  42606. * Instantiates a new debug layer.
  42607. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42608. * what is happening in your scene
  42609. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42610. * @param scene Defines the scene to inspect
  42611. */
  42612. constructor(scene: Scene);
  42613. /** Creates the inspector window. */
  42614. private _createInspector;
  42615. /**
  42616. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42617. * @param entity defines the entity to select
  42618. * @param lineContainerTitle defines the specific block to highlight
  42619. */
  42620. select(entity: any, lineContainerTitle?: string): void;
  42621. /** Get the inspector from bundle or global */
  42622. private _getGlobalInspector;
  42623. /**
  42624. * Get if the inspector is visible or not.
  42625. * @returns true if visible otherwise, false
  42626. */
  42627. isVisible(): boolean;
  42628. /**
  42629. * Hide the inspector and close its window.
  42630. */
  42631. hide(): void;
  42632. /**
  42633. * Launch the debugLayer.
  42634. * @param config Define the configuration of the inspector
  42635. * @return a promise fulfilled when the debug layer is visible
  42636. */
  42637. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42638. }
  42639. }
  42640. declare module BABYLON {
  42641. /**
  42642. * Class containing static functions to help procedurally build meshes
  42643. */
  42644. export class BoxBuilder {
  42645. /**
  42646. * Creates a box mesh
  42647. * * The parameter `size` sets the size (float) of each box side (default 1)
  42648. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42649. * * 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)
  42650. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42651. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42652. * * 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
  42653. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42654. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42655. * @param name defines the name of the mesh
  42656. * @param options defines the options used to create the mesh
  42657. * @param scene defines the hosting scene
  42658. * @returns the box mesh
  42659. */
  42660. static CreateBox(name: string, options: {
  42661. size?: number;
  42662. width?: number;
  42663. height?: number;
  42664. depth?: number;
  42665. faceUV?: Vector4[];
  42666. faceColors?: Color4[];
  42667. sideOrientation?: number;
  42668. frontUVs?: Vector4;
  42669. backUVs?: Vector4;
  42670. wrap?: boolean;
  42671. topBaseAt?: number;
  42672. bottomBaseAt?: number;
  42673. updatable?: boolean;
  42674. }, scene?: Nullable<Scene>): Mesh;
  42675. }
  42676. }
  42677. declare module BABYLON {
  42678. /**
  42679. * Class containing static functions to help procedurally build meshes
  42680. */
  42681. export class SphereBuilder {
  42682. /**
  42683. * Creates a sphere mesh
  42684. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42685. * * 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`)
  42686. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42687. * * 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
  42688. * * 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)
  42689. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42690. * * 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
  42691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42692. * @param name defines the name of the mesh
  42693. * @param options defines the options used to create the mesh
  42694. * @param scene defines the hosting scene
  42695. * @returns the sphere mesh
  42696. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42697. */
  42698. static CreateSphere(name: string, options: {
  42699. segments?: number;
  42700. diameter?: number;
  42701. diameterX?: number;
  42702. diameterY?: number;
  42703. diameterZ?: number;
  42704. arc?: number;
  42705. slice?: number;
  42706. sideOrientation?: number;
  42707. frontUVs?: Vector4;
  42708. backUVs?: Vector4;
  42709. updatable?: boolean;
  42710. }, scene?: Nullable<Scene>): Mesh;
  42711. }
  42712. }
  42713. declare module BABYLON.Debug {
  42714. /**
  42715. * Used to show the physics impostor around the specific mesh
  42716. */
  42717. export class PhysicsViewer {
  42718. /** @hidden */
  42719. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42720. /** @hidden */
  42721. protected _meshes: Array<Nullable<AbstractMesh>>;
  42722. /** @hidden */
  42723. protected _scene: Nullable<Scene>;
  42724. /** @hidden */
  42725. protected _numMeshes: number;
  42726. /** @hidden */
  42727. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42728. private _renderFunction;
  42729. private _utilityLayer;
  42730. private _debugBoxMesh;
  42731. private _debugSphereMesh;
  42732. private _debugCylinderMesh;
  42733. private _debugMaterial;
  42734. private _debugMeshMeshes;
  42735. /**
  42736. * Creates a new PhysicsViewer
  42737. * @param scene defines the hosting scene
  42738. */
  42739. constructor(scene: Scene);
  42740. /** @hidden */
  42741. protected _updateDebugMeshes(): void;
  42742. /**
  42743. * Renders a specified physic impostor
  42744. * @param impostor defines the impostor to render
  42745. * @param targetMesh defines the mesh represented by the impostor
  42746. * @returns the new debug mesh used to render the impostor
  42747. */
  42748. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42749. /**
  42750. * Hides a specified physic impostor
  42751. * @param impostor defines the impostor to hide
  42752. */
  42753. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42754. private _getDebugMaterial;
  42755. private _getDebugBoxMesh;
  42756. private _getDebugSphereMesh;
  42757. private _getDebugCylinderMesh;
  42758. private _getDebugMeshMesh;
  42759. private _getDebugMesh;
  42760. /** Releases all resources */
  42761. dispose(): void;
  42762. }
  42763. }
  42764. declare module BABYLON {
  42765. /**
  42766. * Class containing static functions to help procedurally build meshes
  42767. */
  42768. export class LinesBuilder {
  42769. /**
  42770. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42771. * * 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
  42772. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42773. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42774. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42775. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42776. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42777. * * 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
  42778. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42779. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42780. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42781. * @param name defines the name of the new line system
  42782. * @param options defines the options used to create the line system
  42783. * @param scene defines the hosting scene
  42784. * @returns a new line system mesh
  42785. */
  42786. static CreateLineSystem(name: string, options: {
  42787. lines: Vector3[][];
  42788. updatable?: boolean;
  42789. instance?: Nullable<LinesMesh>;
  42790. colors?: Nullable<Color4[][]>;
  42791. useVertexAlpha?: boolean;
  42792. }, scene: Nullable<Scene>): LinesMesh;
  42793. /**
  42794. * Creates a line mesh
  42795. * 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
  42796. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42797. * * The parameter `points` is an array successive Vector3
  42798. * * 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
  42799. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42800. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42801. * * When updating an instance, remember that only point positions can change, not the number of points
  42802. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42803. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42804. * @param name defines the name of the new line system
  42805. * @param options defines the options used to create the line system
  42806. * @param scene defines the hosting scene
  42807. * @returns a new line mesh
  42808. */
  42809. static CreateLines(name: string, options: {
  42810. points: Vector3[];
  42811. updatable?: boolean;
  42812. instance?: Nullable<LinesMesh>;
  42813. colors?: Color4[];
  42814. useVertexAlpha?: boolean;
  42815. }, scene?: Nullable<Scene>): LinesMesh;
  42816. /**
  42817. * Creates a dashed line mesh
  42818. * * 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
  42819. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42820. * * The parameter `points` is an array successive Vector3
  42821. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42822. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42823. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42824. * * 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
  42825. * * When updating an instance, remember that only point positions can change, not the number of points
  42826. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42827. * @param name defines the name of the mesh
  42828. * @param options defines the options used to create the mesh
  42829. * @param scene defines the hosting scene
  42830. * @returns the dashed line mesh
  42831. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42832. */
  42833. static CreateDashedLines(name: string, options: {
  42834. points: Vector3[];
  42835. dashSize?: number;
  42836. gapSize?: number;
  42837. dashNb?: number;
  42838. updatable?: boolean;
  42839. instance?: LinesMesh;
  42840. }, scene?: Nullable<Scene>): LinesMesh;
  42841. }
  42842. }
  42843. declare module BABYLON {
  42844. /**
  42845. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42846. * in order to better appreciate the issue one might have.
  42847. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42848. */
  42849. export class RayHelper {
  42850. /**
  42851. * Defines the ray we are currently tryin to visualize.
  42852. */
  42853. ray: Nullable<Ray>;
  42854. private _renderPoints;
  42855. private _renderLine;
  42856. private _renderFunction;
  42857. private _scene;
  42858. private _updateToMeshFunction;
  42859. private _attachedToMesh;
  42860. private _meshSpaceDirection;
  42861. private _meshSpaceOrigin;
  42862. /**
  42863. * Helper function to create a colored helper in a scene in one line.
  42864. * @param ray Defines the ray we are currently tryin to visualize
  42865. * @param scene Defines the scene the ray is used in
  42866. * @param color Defines the color we want to see the ray in
  42867. * @returns The newly created ray helper.
  42868. */
  42869. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42870. /**
  42871. * Instantiate a new ray helper.
  42872. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42873. * in order to better appreciate the issue one might have.
  42874. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42875. * @param ray Defines the ray we are currently tryin to visualize
  42876. */
  42877. constructor(ray: Ray);
  42878. /**
  42879. * Shows the ray we are willing to debug.
  42880. * @param scene Defines the scene the ray needs to be rendered in
  42881. * @param color Defines the color the ray needs to be rendered in
  42882. */
  42883. show(scene: Scene, color?: Color3): void;
  42884. /**
  42885. * Hides the ray we are debugging.
  42886. */
  42887. hide(): void;
  42888. private _render;
  42889. /**
  42890. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42891. * @param mesh Defines the mesh we want the helper attached to
  42892. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42893. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42894. * @param length Defines the length of the ray
  42895. */
  42896. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42897. /**
  42898. * Detach the ray helper from the mesh it has previously been attached to.
  42899. */
  42900. detachFromMesh(): void;
  42901. private _updateToMesh;
  42902. /**
  42903. * Dispose the helper and release its associated resources.
  42904. */
  42905. dispose(): void;
  42906. }
  42907. }
  42908. declare module BABYLON.Debug {
  42909. /**
  42910. * Class used to render a debug view of a given skeleton
  42911. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42912. */
  42913. export class SkeletonViewer {
  42914. /** defines the skeleton to render */
  42915. skeleton: Skeleton;
  42916. /** defines the mesh attached to the skeleton */
  42917. mesh: AbstractMesh;
  42918. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42919. autoUpdateBonesMatrices: boolean;
  42920. /** defines the rendering group id to use with the viewer */
  42921. renderingGroupId: number;
  42922. /** Gets or sets the color used to render the skeleton */
  42923. color: Color3;
  42924. private _scene;
  42925. private _debugLines;
  42926. private _debugMesh;
  42927. private _isEnabled;
  42928. private _renderFunction;
  42929. private _utilityLayer;
  42930. /**
  42931. * Returns the mesh used to render the bones
  42932. */
  42933. readonly debugMesh: Nullable<LinesMesh>;
  42934. /**
  42935. * Creates a new SkeletonViewer
  42936. * @param skeleton defines the skeleton to render
  42937. * @param mesh defines the mesh attached to the skeleton
  42938. * @param scene defines the hosting scene
  42939. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42940. * @param renderingGroupId defines the rendering group id to use with the viewer
  42941. */
  42942. constructor(
  42943. /** defines the skeleton to render */
  42944. skeleton: Skeleton,
  42945. /** defines the mesh attached to the skeleton */
  42946. mesh: AbstractMesh, scene: Scene,
  42947. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42948. autoUpdateBonesMatrices?: boolean,
  42949. /** defines the rendering group id to use with the viewer */
  42950. renderingGroupId?: number);
  42951. /** Gets or sets a boolean indicating if the viewer is enabled */
  42952. isEnabled: boolean;
  42953. private _getBonePosition;
  42954. private _getLinesForBonesWithLength;
  42955. private _getLinesForBonesNoLength;
  42956. /** Update the viewer to sync with current skeleton state */
  42957. update(): void;
  42958. /** Release associated resources */
  42959. dispose(): void;
  42960. }
  42961. }
  42962. declare module BABYLON {
  42963. /**
  42964. * Options to create the null engine
  42965. */
  42966. export class NullEngineOptions {
  42967. /**
  42968. * Render width (Default: 512)
  42969. */
  42970. renderWidth: number;
  42971. /**
  42972. * Render height (Default: 256)
  42973. */
  42974. renderHeight: number;
  42975. /**
  42976. * Texture size (Default: 512)
  42977. */
  42978. textureSize: number;
  42979. /**
  42980. * If delta time between frames should be constant
  42981. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42982. */
  42983. deterministicLockstep: boolean;
  42984. /**
  42985. * Maximum about of steps between frames (Default: 4)
  42986. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42987. */
  42988. lockstepMaxSteps: number;
  42989. }
  42990. /**
  42991. * The null engine class provides support for headless version of babylon.js.
  42992. * This can be used in server side scenario or for testing purposes
  42993. */
  42994. export class NullEngine extends Engine {
  42995. private _options;
  42996. /**
  42997. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  42998. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42999. * @returns true if engine is in deterministic lock step mode
  43000. */
  43001. isDeterministicLockStep(): boolean;
  43002. /**
  43003. * Gets the max steps when engine is running in deterministic lock step
  43004. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43005. * @returns the max steps
  43006. */
  43007. getLockstepMaxSteps(): number;
  43008. /**
  43009. * Gets the current hardware scaling level.
  43010. * By default the hardware scaling level is computed from the window device ratio.
  43011. * 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.
  43012. * @returns a number indicating the current hardware scaling level
  43013. */
  43014. getHardwareScalingLevel(): number;
  43015. constructor(options?: NullEngineOptions);
  43016. /**
  43017. * Creates a vertex buffer
  43018. * @param vertices the data for the vertex buffer
  43019. * @returns the new WebGL static buffer
  43020. */
  43021. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43022. /**
  43023. * Creates a new index buffer
  43024. * @param indices defines the content of the index buffer
  43025. * @param updatable defines if the index buffer must be updatable
  43026. * @returns a new webGL buffer
  43027. */
  43028. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43029. /**
  43030. * Clear the current render buffer or the current render target (if any is set up)
  43031. * @param color defines the color to use
  43032. * @param backBuffer defines if the back buffer must be cleared
  43033. * @param depth defines if the depth buffer must be cleared
  43034. * @param stencil defines if the stencil buffer must be cleared
  43035. */
  43036. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43037. /**
  43038. * Gets the current render width
  43039. * @param useScreen defines if screen size must be used (or the current render target if any)
  43040. * @returns a number defining the current render width
  43041. */
  43042. getRenderWidth(useScreen?: boolean): number;
  43043. /**
  43044. * Gets the current render height
  43045. * @param useScreen defines if screen size must be used (or the current render target if any)
  43046. * @returns a number defining the current render height
  43047. */
  43048. getRenderHeight(useScreen?: boolean): number;
  43049. /**
  43050. * Set the WebGL's viewport
  43051. * @param viewport defines the viewport element to be used
  43052. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  43053. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  43054. */
  43055. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  43056. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43057. /**
  43058. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  43059. * @param pipelineContext defines the pipeline context to use
  43060. * @param uniformsNames defines the list of uniform names
  43061. * @returns an array of webGL uniform locations
  43062. */
  43063. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43064. /**
  43065. * Gets the lsit of active attributes for a given webGL program
  43066. * @param pipelineContext defines the pipeline context to use
  43067. * @param attributesNames defines the list of attribute names to get
  43068. * @returns an array of indices indicating the offset of each attribute
  43069. */
  43070. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43071. /**
  43072. * Binds an effect to the webGL context
  43073. * @param effect defines the effect to bind
  43074. */
  43075. bindSamplers(effect: Effect): void;
  43076. /**
  43077. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  43078. * @param effect defines the effect to activate
  43079. */
  43080. enableEffect(effect: Effect): void;
  43081. /**
  43082. * Set various states to the webGL context
  43083. * @param culling defines backface culling state
  43084. * @param zOffset defines the value to apply to zOffset (0 by default)
  43085. * @param force defines if states must be applied even if cache is up to date
  43086. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  43087. */
  43088. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43089. /**
  43090. * Set the value of an uniform to an array of int32
  43091. * @param uniform defines the webGL uniform location where to store the value
  43092. * @param array defines the array of int32 to store
  43093. */
  43094. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43095. /**
  43096. * Set the value of an uniform to an array of int32 (stored as vec2)
  43097. * @param uniform defines the webGL uniform location where to store the value
  43098. * @param array defines the array of int32 to store
  43099. */
  43100. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43101. /**
  43102. * Set the value of an uniform to an array of int32 (stored as vec3)
  43103. * @param uniform defines the webGL uniform location where to store the value
  43104. * @param array defines the array of int32 to store
  43105. */
  43106. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43107. /**
  43108. * Set the value of an uniform to an array of int32 (stored as vec4)
  43109. * @param uniform defines the webGL uniform location where to store the value
  43110. * @param array defines the array of int32 to store
  43111. */
  43112. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43113. /**
  43114. * Set the value of an uniform to an array of float32
  43115. * @param uniform defines the webGL uniform location where to store the value
  43116. * @param array defines the array of float32 to store
  43117. */
  43118. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43119. /**
  43120. * Set the value of an uniform to an array of float32 (stored as vec2)
  43121. * @param uniform defines the webGL uniform location where to store the value
  43122. * @param array defines the array of float32 to store
  43123. */
  43124. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43125. /**
  43126. * Set the value of an uniform to an array of float32 (stored as vec3)
  43127. * @param uniform defines the webGL uniform location where to store the value
  43128. * @param array defines the array of float32 to store
  43129. */
  43130. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43131. /**
  43132. * Set the value of an uniform to an array of float32 (stored as vec4)
  43133. * @param uniform defines the webGL uniform location where to store the value
  43134. * @param array defines the array of float32 to store
  43135. */
  43136. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43137. /**
  43138. * Set the value of an uniform to an array of number
  43139. * @param uniform defines the webGL uniform location where to store the value
  43140. * @param array defines the array of number to store
  43141. */
  43142. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43143. /**
  43144. * Set the value of an uniform to an array of number (stored as vec2)
  43145. * @param uniform defines the webGL uniform location where to store the value
  43146. * @param array defines the array of number to store
  43147. */
  43148. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43149. /**
  43150. * Set the value of an uniform to an array of number (stored as vec3)
  43151. * @param uniform defines the webGL uniform location where to store the value
  43152. * @param array defines the array of number to store
  43153. */
  43154. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43155. /**
  43156. * Set the value of an uniform to an array of number (stored as vec4)
  43157. * @param uniform defines the webGL uniform location where to store the value
  43158. * @param array defines the array of number to store
  43159. */
  43160. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43161. /**
  43162. * Set the value of an uniform to an array of float32 (stored as matrices)
  43163. * @param uniform defines the webGL uniform location where to store the value
  43164. * @param matrices defines the array of float32 to store
  43165. */
  43166. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43167. /**
  43168. * Set the value of an uniform to a matrix (3x3)
  43169. * @param uniform defines the webGL uniform location where to store the value
  43170. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  43171. */
  43172. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43173. /**
  43174. * Set the value of an uniform to a matrix (2x2)
  43175. * @param uniform defines the webGL uniform location where to store the value
  43176. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  43177. */
  43178. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43179. /**
  43180. * Set the value of an uniform to a number (float)
  43181. * @param uniform defines the webGL uniform location where to store the value
  43182. * @param value defines the float number to store
  43183. */
  43184. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43185. /**
  43186. * Set the value of an uniform to a vec2
  43187. * @param uniform defines the webGL uniform location where to store the value
  43188. * @param x defines the 1st component of the value
  43189. * @param y defines the 2nd component of the value
  43190. */
  43191. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43192. /**
  43193. * Set the value of an uniform to a vec3
  43194. * @param uniform defines the webGL uniform location where to store the value
  43195. * @param x defines the 1st component of the value
  43196. * @param y defines the 2nd component of the value
  43197. * @param z defines the 3rd component of the value
  43198. */
  43199. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43200. /**
  43201. * Set the value of an uniform to a boolean
  43202. * @param uniform defines the webGL uniform location where to store the value
  43203. * @param bool defines the boolean to store
  43204. */
  43205. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43206. /**
  43207. * Set the value of an uniform to a vec4
  43208. * @param uniform defines the webGL uniform location where to store the value
  43209. * @param x defines the 1st component of the value
  43210. * @param y defines the 2nd component of the value
  43211. * @param z defines the 3rd component of the value
  43212. * @param w defines the 4th component of the value
  43213. */
  43214. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43215. /**
  43216. * Sets the current alpha mode
  43217. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  43218. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  43219. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  43220. */
  43221. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43222. /**
  43223. * Bind webGl buffers directly to the webGL context
  43224. * @param vertexBuffers defines the vertex buffer to bind
  43225. * @param indexBuffer defines the index buffer to bind
  43226. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  43227. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  43228. * @param effect defines the effect associated with the vertex buffer
  43229. */
  43230. bindBuffers(vertexBuffers: {
  43231. [key: string]: VertexBuffer;
  43232. }, indexBuffer: DataBuffer, effect: Effect): void;
  43233. /**
  43234. * Force the entire cache to be cleared
  43235. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  43236. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  43237. */
  43238. wipeCaches(bruteForce?: boolean): void;
  43239. /**
  43240. * Send a draw order
  43241. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  43242. * @param indexStart defines the starting index
  43243. * @param indexCount defines the number of index to draw
  43244. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43245. */
  43246. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43247. /**
  43248. * Draw a list of indexed primitives
  43249. * @param fillMode defines the primitive to use
  43250. * @param indexStart defines the starting index
  43251. * @param indexCount defines the number of index to draw
  43252. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43253. */
  43254. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43255. /**
  43256. * Draw a list of unindexed primitives
  43257. * @param fillMode defines the primitive to use
  43258. * @param verticesStart defines the index of first vertex to draw
  43259. * @param verticesCount defines the count of vertices to draw
  43260. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43261. */
  43262. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43263. /** @hidden */ private _createTexture(): WebGLTexture;
  43264. /** @hidden */ private _releaseTexture(texture: InternalTexture): void;
  43265. /**
  43266. * Usually called from Texture.ts.
  43267. * Passed information to create a WebGLTexture
  43268. * @param urlArg defines a value which contains one of the following:
  43269. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  43270. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  43271. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  43272. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  43273. * @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)
  43274. * @param scene needed for loading to the correct scene
  43275. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  43276. * @param onLoad optional callback to be called upon successful completion
  43277. * @param onError optional callback to be called upon failure
  43278. * @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
  43279. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  43280. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  43281. * @param forcedExtension defines the extension to use to pick the right loader
  43282. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  43283. * @returns a InternalTexture for assignment back into BABYLON.Texture
  43284. */
  43285. 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;
  43286. /**
  43287. * Creates a new render target texture
  43288. * @param size defines the size of the texture
  43289. * @param options defines the options used to create the texture
  43290. * @returns a new render target texture stored in an InternalTexture
  43291. */
  43292. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43293. /**
  43294. * Update the sampling mode of a given texture
  43295. * @param samplingMode defines the required sampling mode
  43296. * @param texture defines the texture to update
  43297. */
  43298. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43299. /**
  43300. * Binds the frame buffer to the specified texture.
  43301. * @param texture The texture to render to or null for the default canvas
  43302. * @param faceIndex The face of the texture to render to in case of cube texture
  43303. * @param requiredWidth The width of the target to render to
  43304. * @param requiredHeight The height of the target to render to
  43305. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  43306. * @param depthStencilTexture The depth stencil texture to use to render
  43307. * @param lodLevel defines le lod level to bind to the frame buffer
  43308. */
  43309. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43310. /**
  43311. * Unbind the current render target texture from the webGL context
  43312. * @param texture defines the render target texture to unbind
  43313. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43314. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43315. */
  43316. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43317. /**
  43318. * Creates a dynamic vertex buffer
  43319. * @param vertices the data for the dynamic vertex buffer
  43320. * @returns the new WebGL dynamic buffer
  43321. */
  43322. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43323. /**
  43324. * Update the content of a dynamic texture
  43325. * @param texture defines the texture to update
  43326. * @param canvas defines the canvas containing the source
  43327. * @param invertY defines if data must be stored with Y axis inverted
  43328. * @param premulAlpha defines if alpha is stored as premultiplied
  43329. * @param format defines the format of the data
  43330. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  43331. */
  43332. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43333. /**
  43334. * Gets a boolean indicating if all created effects are ready
  43335. * @returns true if all effects are ready
  43336. */
  43337. areAllEffectsReady(): boolean;
  43338. /**
  43339. * @hidden
  43340. * Get the current error code of the webGL context
  43341. * @returns the error code
  43342. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43343. */
  43344. getError(): number;
  43345. /** @hidden */ private _getUnpackAlignement(): number;
  43346. /** @hidden */ private _unpackFlipY(value: boolean): void;
  43347. /**
  43348. * Update a dynamic index buffer
  43349. * @param indexBuffer defines the target index buffer
  43350. * @param indices defines the data to update
  43351. * @param offset defines the offset in the target index buffer where update should start
  43352. */
  43353. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43354. /**
  43355. * Updates a dynamic vertex buffer.
  43356. * @param vertexBuffer the vertex buffer to update
  43357. * @param vertices the data used to update the vertex buffer
  43358. * @param byteOffset the byte offset of the data (optional)
  43359. * @param byteLength the byte length of the data (optional)
  43360. */
  43361. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43362. /** @hidden */ private _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43363. /** @hidden */ private _bindTexture(channel: number, texture: InternalTexture): void;
  43364. protected _deleteBuffer(buffer: WebGLBuffer): void;
  43365. /**
  43366. * 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
  43367. */
  43368. releaseEffects(): void;
  43369. displayLoadingUI(): void;
  43370. hideLoadingUI(): void;
  43371. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43372. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43373. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43374. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43375. }
  43376. }
  43377. declare module BABYLON {
  43378. /** @hidden */
  43379. export class _OcclusionDataStorage {
  43380. /** @hidden */
  43381. occlusionInternalRetryCounter: number;
  43382. /** @hidden */
  43383. isOcclusionQueryInProgress: boolean;
  43384. /** @hidden */
  43385. isOccluded: boolean;
  43386. /** @hidden */
  43387. occlusionRetryCount: number;
  43388. /** @hidden */
  43389. occlusionType: number;
  43390. /** @hidden */
  43391. occlusionQueryAlgorithmType: number;
  43392. }
  43393. interface Engine {
  43394. /**
  43395. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43396. * @return the new query
  43397. */
  43398. createQuery(): WebGLQuery;
  43399. /**
  43400. * Delete and release a webGL query
  43401. * @param query defines the query to delete
  43402. * @return the current engine
  43403. */
  43404. deleteQuery(query: WebGLQuery): Engine;
  43405. /**
  43406. * Check if a given query has resolved and got its value
  43407. * @param query defines the query to check
  43408. * @returns true if the query got its value
  43409. */
  43410. isQueryResultAvailable(query: WebGLQuery): boolean;
  43411. /**
  43412. * Gets the value of a given query
  43413. * @param query defines the query to check
  43414. * @returns the value of the query
  43415. */
  43416. getQueryResult(query: WebGLQuery): number;
  43417. /**
  43418. * Initiates an occlusion query
  43419. * @param algorithmType defines the algorithm to use
  43420. * @param query defines the query to use
  43421. * @returns the current engine
  43422. * @see http://doc.babylonjs.com/features/occlusionquery
  43423. */
  43424. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43425. /**
  43426. * Ends an occlusion query
  43427. * @see http://doc.babylonjs.com/features/occlusionquery
  43428. * @param algorithmType defines the algorithm to use
  43429. * @returns the current engine
  43430. */
  43431. endOcclusionQuery(algorithmType: number): Engine;
  43432. /**
  43433. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43434. * Please note that only one query can be issued at a time
  43435. * @returns a time token used to track the time span
  43436. */
  43437. startTimeQuery(): Nullable<_TimeToken>;
  43438. /**
  43439. * Ends a time query
  43440. * @param token defines the token used to measure the time span
  43441. * @returns the time spent (in ns)
  43442. */
  43443. endTimeQuery(token: _TimeToken): int;
  43444. /** @hidden */ private _currentNonTimestampToken: Nullable<_TimeToken>;
  43445. /** @hidden */ private _createTimeQuery(): WebGLQuery;
  43446. /** @hidden */ private _deleteTimeQuery(query: WebGLQuery): void;
  43447. /** @hidden */ private _getGlAlgorithmType(algorithmType: number): number;
  43448. /** @hidden */ private _getTimeQueryResult(query: WebGLQuery): any;
  43449. /** @hidden */ private _getTimeQueryAvailability(query: WebGLQuery): any;
  43450. }
  43451. interface AbstractMesh {
  43452. /**
  43453. * Backing filed
  43454. * @hidden
  43455. */ private __occlusionDataStorage: _OcclusionDataStorage;
  43456. /**
  43457. * Access property
  43458. * @hidden
  43459. */ private _occlusionDataStorage: _OcclusionDataStorage;
  43460. /**
  43461. * 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.
  43462. * The default value is -1 which means don't break the query and wait till the result
  43463. * @see http://doc.babylonjs.com/features/occlusionquery
  43464. */
  43465. occlusionRetryCount: number;
  43466. /**
  43467. * 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:
  43468. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43469. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43470. * * 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.
  43471. * @see http://doc.babylonjs.com/features/occlusionquery
  43472. */
  43473. occlusionType: number;
  43474. /**
  43475. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43476. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43477. * * 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.
  43478. * @see http://doc.babylonjs.com/features/occlusionquery
  43479. */
  43480. occlusionQueryAlgorithmType: number;
  43481. /**
  43482. * 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
  43483. * @see http://doc.babylonjs.com/features/occlusionquery
  43484. */
  43485. isOccluded: boolean;
  43486. /**
  43487. * Flag to check the progress status of the query
  43488. * @see http://doc.babylonjs.com/features/occlusionquery
  43489. */
  43490. isOcclusionQueryInProgress: boolean;
  43491. }
  43492. }
  43493. declare module BABYLON {
  43494. /** @hidden */
  43495. export var _forceTransformFeedbackToBundle: boolean;
  43496. interface Engine {
  43497. /**
  43498. * Creates a webGL transform feedback object
  43499. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43500. * @returns the webGL transform feedback object
  43501. */
  43502. createTransformFeedback(): WebGLTransformFeedback;
  43503. /**
  43504. * Delete a webGL transform feedback object
  43505. * @param value defines the webGL transform feedback object to delete
  43506. */
  43507. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43508. /**
  43509. * Bind a webGL transform feedback object to the webgl context
  43510. * @param value defines the webGL transform feedback object to bind
  43511. */
  43512. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43513. /**
  43514. * Begins a transform feedback operation
  43515. * @param usePoints defines if points or triangles must be used
  43516. */
  43517. beginTransformFeedback(usePoints: boolean): void;
  43518. /**
  43519. * Ends a transform feedback operation
  43520. */
  43521. endTransformFeedback(): void;
  43522. /**
  43523. * Specify the varyings to use with transform feedback
  43524. * @param program defines the associated webGL program
  43525. * @param value defines the list of strings representing the varying names
  43526. */
  43527. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43528. /**
  43529. * Bind a webGL buffer for a transform feedback operation
  43530. * @param value defines the webGL buffer to bind
  43531. */
  43532. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43533. }
  43534. }
  43535. declare module BABYLON {
  43536. /**
  43537. * Creation options of the multi render target texture.
  43538. */
  43539. export interface IMultiRenderTargetOptions {
  43540. /**
  43541. * Define if the texture needs to create mip maps after render.
  43542. */
  43543. generateMipMaps?: boolean;
  43544. /**
  43545. * Define the types of all the draw buffers we want to create
  43546. */
  43547. types?: number[];
  43548. /**
  43549. * Define the sampling modes of all the draw buffers we want to create
  43550. */
  43551. samplingModes?: number[];
  43552. /**
  43553. * Define if a depth buffer is required
  43554. */
  43555. generateDepthBuffer?: boolean;
  43556. /**
  43557. * Define if a stencil buffer is required
  43558. */
  43559. generateStencilBuffer?: boolean;
  43560. /**
  43561. * Define if a depth texture is required instead of a depth buffer
  43562. */
  43563. generateDepthTexture?: boolean;
  43564. /**
  43565. * Define the number of desired draw buffers
  43566. */
  43567. textureCount?: number;
  43568. /**
  43569. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43570. */
  43571. doNotChangeAspectRatio?: boolean;
  43572. /**
  43573. * Define the default type of the buffers we are creating
  43574. */
  43575. defaultType?: number;
  43576. }
  43577. /**
  43578. * A multi render target, like a render target provides the ability to render to a texture.
  43579. * Unlike the render target, it can render to several draw buffers in one draw.
  43580. * This is specially interesting in deferred rendering or for any effects requiring more than
  43581. * just one color from a single pass.
  43582. */
  43583. export class MultiRenderTarget extends RenderTargetTexture {
  43584. private _internalTextures;
  43585. private _textures;
  43586. private _multiRenderTargetOptions;
  43587. /**
  43588. * Get if draw buffers are currently supported by the used hardware and browser.
  43589. */
  43590. readonly isSupported: boolean;
  43591. /**
  43592. * Get the list of textures generated by the multi render target.
  43593. */
  43594. readonly textures: Texture[];
  43595. /**
  43596. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43597. */
  43598. readonly depthTexture: Texture;
  43599. /**
  43600. * Set the wrapping mode on U of all the textures we are rendering to.
  43601. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43602. */
  43603. wrapU: number;
  43604. /**
  43605. * Set the wrapping mode on V of all the textures we are rendering to.
  43606. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43607. */
  43608. wrapV: number;
  43609. /**
  43610. * Instantiate a new multi render target texture.
  43611. * A multi render target, like a render target provides the ability to render to a texture.
  43612. * Unlike the render target, it can render to several draw buffers in one draw.
  43613. * This is specially interesting in deferred rendering or for any effects requiring more than
  43614. * just one color from a single pass.
  43615. * @param name Define the name of the texture
  43616. * @param size Define the size of the buffers to render to
  43617. * @param count Define the number of target we are rendering into
  43618. * @param scene Define the scene the texture belongs to
  43619. * @param options Define the options used to create the multi render target
  43620. */
  43621. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43622. /** @hidden */ private _rebuild(): void;
  43623. private _createInternalTextures;
  43624. private _createTextures;
  43625. /**
  43626. * Define the number of samples used if MSAA is enabled.
  43627. */
  43628. samples: number;
  43629. /**
  43630. * Resize all the textures in the multi render target.
  43631. * Be carrefull as it will recreate all the data in the new texture.
  43632. * @param size Define the new size
  43633. */
  43634. resize(size: any): void;
  43635. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43636. /**
  43637. * Dispose the render targets and their associated resources
  43638. */
  43639. dispose(): void;
  43640. /**
  43641. * Release all the underlying texture used as draw buffers.
  43642. */
  43643. releaseInternalTextures(): void;
  43644. }
  43645. }
  43646. declare module BABYLON {
  43647. interface ThinEngine {
  43648. /**
  43649. * Unbind a list of render target textures from the webGL context
  43650. * This is used only when drawBuffer extension or webGL2 are active
  43651. * @param textures defines the render target textures to unbind
  43652. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43653. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43654. */
  43655. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43656. /**
  43657. * Create a multi render target texture
  43658. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43659. * @param size defines the size of the texture
  43660. * @param options defines the creation options
  43661. * @returns the cube texture as an InternalTexture
  43662. */
  43663. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43664. /**
  43665. * Update the sample count for a given multiple render target texture
  43666. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43667. * @param textures defines the textures to update
  43668. * @param samples defines the sample count to set
  43669. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43670. */
  43671. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43672. }
  43673. }
  43674. declare module BABYLON {
  43675. /**
  43676. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  43677. */
  43678. export interface CubeMapInfo {
  43679. /**
  43680. * The pixel array for the front face.
  43681. * This is stored in format, left to right, up to down format.
  43682. */
  43683. front: Nullable<ArrayBufferView>;
  43684. /**
  43685. * The pixel array for the back face.
  43686. * This is stored in format, left to right, up to down format.
  43687. */
  43688. back: Nullable<ArrayBufferView>;
  43689. /**
  43690. * The pixel array for the left face.
  43691. * This is stored in format, left to right, up to down format.
  43692. */
  43693. left: Nullable<ArrayBufferView>;
  43694. /**
  43695. * The pixel array for the right face.
  43696. * This is stored in format, left to right, up to down format.
  43697. */
  43698. right: Nullable<ArrayBufferView>;
  43699. /**
  43700. * The pixel array for the up face.
  43701. * This is stored in format, left to right, up to down format.
  43702. */
  43703. up: Nullable<ArrayBufferView>;
  43704. /**
  43705. * The pixel array for the down face.
  43706. * This is stored in format, left to right, up to down format.
  43707. */
  43708. down: Nullable<ArrayBufferView>;
  43709. /**
  43710. * The size of the cubemap stored.
  43711. *
  43712. * Each faces will be size * size pixels.
  43713. */
  43714. size: number;
  43715. /**
  43716. * The format of the texture.
  43717. *
  43718. * RGBA, RGB.
  43719. */
  43720. format: number;
  43721. /**
  43722. * The type of the texture data.
  43723. *
  43724. * UNSIGNED_INT, FLOAT.
  43725. */
  43726. type: number;
  43727. /**
  43728. * Specifies whether the texture is in gamma space.
  43729. */
  43730. gammaSpace: boolean;
  43731. }
  43732. /**
  43733. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  43734. */
  43735. export class PanoramaToCubeMapTools {
  43736. private static FACE_FRONT;
  43737. private static FACE_BACK;
  43738. private static FACE_RIGHT;
  43739. private static FACE_LEFT;
  43740. private static FACE_DOWN;
  43741. private static FACE_UP;
  43742. /**
  43743. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  43744. *
  43745. * @param float32Array The source data.
  43746. * @param inputWidth The width of the input panorama.
  43747. * @param inputHeight The height of the input panorama.
  43748. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  43749. * @return The cubemap data
  43750. */
  43751. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  43752. private static CreateCubemapTexture;
  43753. private static CalcProjectionSpherical;
  43754. }
  43755. }
  43756. declare module BABYLON {
  43757. /**
  43758. * Helper class dealing with the extraction of spherical polynomial dataArray
  43759. * from a cube map.
  43760. */
  43761. export class CubeMapToSphericalPolynomialTools {
  43762. private static FileFaces;
  43763. /**
  43764. * Converts a texture to the according Spherical Polynomial data.
  43765. * This extracts the first 3 orders only as they are the only one used in the lighting.
  43766. *
  43767. * @param texture The texture to extract the information from.
  43768. * @return The Spherical Polynomial data.
  43769. */
  43770. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  43771. /**
  43772. * Converts a cubemap to the according Spherical Polynomial data.
  43773. * This extracts the first 3 orders only as they are the only one used in the lighting.
  43774. *
  43775. * @param cubeInfo The Cube map to extract the information from.
  43776. * @return The Spherical Polynomial data.
  43777. */
  43778. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  43779. }
  43780. }
  43781. declare module BABYLON {
  43782. interface BaseTexture {
  43783. /**
  43784. * Get the polynomial representation of the texture data.
  43785. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  43786. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  43787. */
  43788. sphericalPolynomial: Nullable<SphericalPolynomial>;
  43789. }
  43790. }
  43791. declare module BABYLON {
  43792. /** @hidden */
  43793. export var rgbdEncodePixelShader: {
  43794. name: string;
  43795. shader: string;
  43796. };
  43797. }
  43798. declare module BABYLON {
  43799. /** @hidden */
  43800. export var rgbdDecodePixelShader: {
  43801. name: string;
  43802. shader: string;
  43803. };
  43804. }
  43805. declare module BABYLON {
  43806. /**
  43807. * Raw texture data and descriptor sufficient for WebGL texture upload
  43808. */
  43809. export interface EnvironmentTextureInfo {
  43810. /**
  43811. * Version of the environment map
  43812. */
  43813. version: number;
  43814. /**
  43815. * Width of image
  43816. */
  43817. width: number;
  43818. /**
  43819. * Irradiance information stored in the file.
  43820. */
  43821. irradiance: any;
  43822. /**
  43823. * Specular information stored in the file.
  43824. */
  43825. specular: any;
  43826. }
  43827. /**
  43828. * Defines One Image in the file. It requires only the position in the file
  43829. * as well as the length.
  43830. */
  43831. interface BufferImageData {
  43832. /**
  43833. * Length of the image data.
  43834. */
  43835. length: number;
  43836. /**
  43837. * Position of the data from the null terminator delimiting the end of the JSON.
  43838. */
  43839. position: number;
  43840. }
  43841. /**
  43842. * Defines the specular data enclosed in the file.
  43843. * This corresponds to the version 1 of the data.
  43844. */
  43845. export interface EnvironmentTextureSpecularInfoV1 {
  43846. /**
  43847. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  43848. */
  43849. specularDataPosition?: number;
  43850. /**
  43851. * This contains all the images data needed to reconstruct the cubemap.
  43852. */
  43853. mipmaps: Array<BufferImageData>;
  43854. /**
  43855. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  43856. */
  43857. lodGenerationScale: number;
  43858. }
  43859. /**
  43860. * Sets of helpers addressing the serialization and deserialization of environment texture
  43861. * stored in a BabylonJS env file.
  43862. * Those files are usually stored as .env files.
  43863. */
  43864. export class EnvironmentTextureTools {
  43865. /**
  43866. * Magic number identifying the env file.
  43867. */
  43868. private static _MagicBytes;
  43869. /**
  43870. * Gets the environment info from an env file.
  43871. * @param data The array buffer containing the .env bytes.
  43872. * @returns the environment file info (the json header) if successfully parsed.
  43873. */
  43874. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  43875. /**
  43876. * Creates an environment texture from a loaded cube texture.
  43877. * @param texture defines the cube texture to convert in env file
  43878. * @return a promise containing the environment data if succesfull.
  43879. */
  43880. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  43881. /**
  43882. * Creates a JSON representation of the spherical data.
  43883. * @param texture defines the texture containing the polynomials
  43884. * @return the JSON representation of the spherical info
  43885. */
  43886. private static _CreateEnvTextureIrradiance;
  43887. /**
  43888. * Creates the ArrayBufferViews used for initializing environment texture image data.
  43889. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  43890. * @param info parameters that determine what views will be created for accessing the underlying buffer
  43891. * @return the views described by info providing access to the underlying buffer
  43892. */
  43893. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  43894. /**
  43895. * Uploads the texture info contained in the env file to the GPU.
  43896. * @param texture defines the internal texture to upload to
  43897. * @param arrayBuffer defines the buffer cotaining the data to load
  43898. * @param info defines the texture info retrieved through the GetEnvInfo method
  43899. * @returns a promise
  43900. */
  43901. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  43902. private static _OnImageReadyAsync;
  43903. /**
  43904. * Uploads the levels of image data to the GPU.
  43905. * @param texture defines the internal texture to upload to
  43906. * @param imageData defines the array buffer views of image data [mipmap][face]
  43907. * @returns a promise
  43908. */
  43909. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  43910. /**
  43911. * Uploads spherical polynomials information to the texture.
  43912. * @param texture defines the texture we are trying to upload the information to
  43913. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  43914. */
  43915. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  43916. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  43917. }
  43918. }
  43919. declare module BABYLON {
  43920. /**
  43921. * Contains position and normal vectors for a vertex
  43922. */
  43923. export class PositionNormalVertex {
  43924. /** the position of the vertex (defaut: 0,0,0) */
  43925. position: Vector3;
  43926. /** the normal of the vertex (defaut: 0,1,0) */
  43927. normal: Vector3;
  43928. /**
  43929. * Creates a PositionNormalVertex
  43930. * @param position the position of the vertex (defaut: 0,0,0)
  43931. * @param normal the normal of the vertex (defaut: 0,1,0)
  43932. */
  43933. constructor(
  43934. /** the position of the vertex (defaut: 0,0,0) */
  43935. position?: Vector3,
  43936. /** the normal of the vertex (defaut: 0,1,0) */
  43937. normal?: Vector3);
  43938. /**
  43939. * Clones the PositionNormalVertex
  43940. * @returns the cloned PositionNormalVertex
  43941. */
  43942. clone(): PositionNormalVertex;
  43943. }
  43944. /**
  43945. * Contains position, normal and uv vectors for a vertex
  43946. */
  43947. export class PositionNormalTextureVertex {
  43948. /** the position of the vertex (defaut: 0,0,0) */
  43949. position: Vector3;
  43950. /** the normal of the vertex (defaut: 0,1,0) */
  43951. normal: Vector3;
  43952. /** the uv of the vertex (default: 0,0) */
  43953. uv: Vector2;
  43954. /**
  43955. * Creates a PositionNormalTextureVertex
  43956. * @param position the position of the vertex (defaut: 0,0,0)
  43957. * @param normal the normal of the vertex (defaut: 0,1,0)
  43958. * @param uv the uv of the vertex (default: 0,0)
  43959. */
  43960. constructor(
  43961. /** the position of the vertex (defaut: 0,0,0) */
  43962. position?: Vector3,
  43963. /** the normal of the vertex (defaut: 0,1,0) */
  43964. normal?: Vector3,
  43965. /** the uv of the vertex (default: 0,0) */
  43966. uv?: Vector2);
  43967. /**
  43968. * Clones the PositionNormalTextureVertex
  43969. * @returns the cloned PositionNormalTextureVertex
  43970. */
  43971. clone(): PositionNormalTextureVertex;
  43972. }
  43973. }
  43974. declare module BABYLON {
  43975. /** @hidden */
  43976. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  43977. private _genericAttributeLocation;
  43978. private _varyingLocationCount;
  43979. private _varyingLocationMap;
  43980. private _replacements;
  43981. private _textureCount;
  43982. private _uniforms;
  43983. lineProcessor(line: string): string;
  43984. attributeProcessor(attribute: string): string;
  43985. varyingProcessor(varying: string, isFragment: boolean): string;
  43986. uniformProcessor(uniform: string): string;
  43987. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  43988. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  43989. }
  43990. }
  43991. declare module BABYLON {
  43992. /**
  43993. * Container for accessors for natively-stored mesh data buffers.
  43994. */
  43995. class NativeDataBuffer extends DataBuffer {
  43996. /**
  43997. * Accessor value used to identify/retrieve a natively-stored index buffer.
  43998. */
  43999. nativeIndexBuffer?: any;
  44000. /**
  44001. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  44002. */
  44003. nativeVertexBuffer?: any;
  44004. }
  44005. /** @hidden */
  44006. export class NativeEngine extends Engine {
  44007. private readonly _native;
  44008. getHardwareScalingLevel(): number;
  44009. constructor();
  44010. /**
  44011. * Can be used to override the current requestAnimationFrame requester.
  44012. * @hidden
  44013. */
  44014. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  44015. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44016. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  44017. createVertexBuffer(data: DataArray): NativeDataBuffer;
  44018. recordVertexArrayObject(vertexBuffers: {
  44019. [key: string]: VertexBuffer;
  44020. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  44021. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44022. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44023. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44024. /**
  44025. * Draw a list of indexed primitives
  44026. * @param fillMode defines the primitive to use
  44027. * @param indexStart defines the starting index
  44028. * @param indexCount defines the number of index to draw
  44029. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44030. */
  44031. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44032. /**
  44033. * Draw a list of unindexed primitives
  44034. * @param fillMode defines the primitive to use
  44035. * @param verticesStart defines the index of first vertex to draw
  44036. * @param verticesCount defines the count of vertices to draw
  44037. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44038. */
  44039. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44040. createPipelineContext(): IPipelineContext; private _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  44041. /** @hidden */ private _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  44042. /** @hidden */ private _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  44043. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44044. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44045. protected _setProgram(program: WebGLProgram): void; private _releaseEffect(effect: Effect): void; private _deletePipelineContext(pipelineContext: IPipelineContext): void;
  44046. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  44047. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  44048. bindSamplers(effect: Effect): void;
  44049. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  44050. getRenderWidth(useScreen?: boolean): number;
  44051. getRenderHeight(useScreen?: boolean): number;
  44052. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  44053. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44054. /**
  44055. * Set the z offset to apply to current rendering
  44056. * @param value defines the offset to apply
  44057. */
  44058. setZOffset(value: number): void;
  44059. /**
  44060. * Gets the current value of the zOffset
  44061. * @returns the current zOffset state
  44062. */
  44063. getZOffset(): number;
  44064. /**
  44065. * Enable or disable depth buffering
  44066. * @param enable defines the state to set
  44067. */
  44068. setDepthBuffer(enable: boolean): void;
  44069. /**
  44070. * Gets a boolean indicating if depth writing is enabled
  44071. * @returns the current depth writing state
  44072. */
  44073. getDepthWrite(): boolean;
  44074. /**
  44075. * Enable or disable depth writing
  44076. * @param enable defines the state to set
  44077. */
  44078. setDepthWrite(enable: boolean): void;
  44079. /**
  44080. * Enable or disable color writing
  44081. * @param enable defines the state to set
  44082. */
  44083. setColorWrite(enable: boolean): void;
  44084. /**
  44085. * Gets a boolean indicating if color writing is enabled
  44086. * @returns the current color writing state
  44087. */
  44088. getColorWrite(): boolean;
  44089. /**
  44090. * Sets alpha constants used by some alpha blending modes
  44091. * @param r defines the red component
  44092. * @param g defines the green component
  44093. * @param b defines the blue component
  44094. * @param a defines the alpha component
  44095. */
  44096. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  44097. /**
  44098. * Sets the current alpha mode
  44099. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  44100. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  44101. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44102. */
  44103. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44104. /**
  44105. * Gets the current alpha mode
  44106. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44107. * @returns the current alpha mode
  44108. */
  44109. getAlphaMode(): number;
  44110. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44111. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44112. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44113. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44114. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44115. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44116. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44117. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44118. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44119. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44120. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44121. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44122. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44123. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44124. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44125. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44126. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44127. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44128. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44129. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44130. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  44131. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  44132. wipeCaches(bruteForce?: boolean): void; private _createTexture(): WebGLTexture;
  44133. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  44134. /**
  44135. * Usually called from BABYLON.Texture.ts.
  44136. * Passed information to create a WebGLTexture
  44137. * @param urlArg defines a value which contains one of the following:
  44138. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  44139. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  44140. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  44141. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  44142. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  44143. * @param scene needed for loading to the correct scene
  44144. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  44145. * @param onLoad optional callback to be called upon successful completion
  44146. * @param onError optional callback to be called upon failure
  44147. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  44148. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  44149. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  44150. * @param forcedExtension defines the extension to use to pick the right loader
  44151. * @returns a InternalTexture for assignment back into BABYLON.Texture
  44152. */
  44153. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  44154. /**
  44155. * Creates a cube texture
  44156. * @param rootUrl defines the url where the files to load is located
  44157. * @param scene defines the current scene
  44158. * @param files defines the list of files to load (1 per face)
  44159. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  44160. * @param onLoad defines an optional callback raised when the texture is loaded
  44161. * @param onError defines an optional callback raised if there is an issue to load the texture
  44162. * @param format defines the format of the data
  44163. * @param forcedExtension defines the extension to use to pick the right loader
  44164. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  44165. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  44166. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  44167. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  44168. * @returns the cube texture as an InternalTexture
  44169. */
  44170. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  44171. private _getSamplingFilter;
  44172. private static _GetNativeTextureFormat;
  44173. createRenderTargetTexture(size: number | {
  44174. width: number;
  44175. height: number;
  44176. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44177. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44178. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44179. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44180. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  44181. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  44182. /**
  44183. * Updates a dynamic vertex buffer.
  44184. * @param vertexBuffer the vertex buffer to update
  44185. * @param data the data used to update the vertex buffer
  44186. * @param byteOffset the byte offset of the data (optional)
  44187. * @param byteLength the byte length of the data (optional)
  44188. */
  44189. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  44190. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  44191. private _updateAnisotropicLevel;
  44192. private _getAddressMode;
  44193. /** @hidden */ private _bindTexture(channel: number, texture: InternalTexture): void;
  44194. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  44195. releaseEffects(): void;
  44196. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44197. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44198. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44199. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44200. }
  44201. }
  44202. declare module BABYLON {
  44203. /**
  44204. * Gather the list of clipboard event types as constants.
  44205. */
  44206. export class ClipboardEventTypes {
  44207. /**
  44208. * The clipboard event is fired when a copy command is active (pressed).
  44209. */
  44210. static readonly COPY: number;
  44211. /**
  44212. * The clipboard event is fired when a cut command is active (pressed).
  44213. */
  44214. static readonly CUT: number;
  44215. /**
  44216. * The clipboard event is fired when a paste command is active (pressed).
  44217. */
  44218. static readonly PASTE: number;
  44219. }
  44220. /**
  44221. * This class is used to store clipboard related info for the onClipboardObservable event.
  44222. */
  44223. export class ClipboardInfo {
  44224. /**
  44225. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44226. */
  44227. type: number;
  44228. /**
  44229. * Defines the related dom event
  44230. */
  44231. event: ClipboardEvent;
  44232. /**
  44233. *Creates an instance of ClipboardInfo.
  44234. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  44235. * @param event Defines the related dom event
  44236. */
  44237. constructor(
  44238. /**
  44239. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44240. */
  44241. type: number,
  44242. /**
  44243. * Defines the related dom event
  44244. */
  44245. event: ClipboardEvent);
  44246. /**
  44247. * Get the clipboard event's type from the keycode.
  44248. * @param keyCode Defines the keyCode for the current keyboard event.
  44249. * @return {number}
  44250. */
  44251. static GetTypeFromCharacter(keyCode: number): number;
  44252. }
  44253. }
  44254. declare module BABYLON {
  44255. /**
  44256. * Google Daydream controller
  44257. */
  44258. export class DaydreamController extends WebVRController {
  44259. /**
  44260. * Base Url for the controller model.
  44261. */
  44262. static MODEL_BASE_URL: string;
  44263. /**
  44264. * File name for the controller model.
  44265. */
  44266. static MODEL_FILENAME: string;
  44267. /**
  44268. * Gamepad Id prefix used to identify Daydream Controller.
  44269. */
  44270. static readonly GAMEPAD_ID_PREFIX: string;
  44271. /**
  44272. * Creates a new DaydreamController from a gamepad
  44273. * @param vrGamepad the gamepad that the controller should be created from
  44274. */
  44275. constructor(vrGamepad: any);
  44276. /**
  44277. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44278. * @param scene scene in which to add meshes
  44279. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44280. */
  44281. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44282. /**
  44283. * Called once for each button that changed state since the last frame
  44284. * @param buttonIdx Which button index changed
  44285. * @param state New state of the button
  44286. * @param changes Which properties on the state changed since last frame
  44287. */
  44288. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44289. }
  44290. }
  44291. declare module BABYLON {
  44292. /**
  44293. * Gear VR Controller
  44294. */
  44295. export class GearVRController extends WebVRController {
  44296. /**
  44297. * Base Url for the controller model.
  44298. */
  44299. static MODEL_BASE_URL: string;
  44300. /**
  44301. * File name for the controller model.
  44302. */
  44303. static MODEL_FILENAME: string;
  44304. /**
  44305. * Gamepad Id prefix used to identify this controller.
  44306. */
  44307. static readonly GAMEPAD_ID_PREFIX: string;
  44308. private readonly _buttonIndexToObservableNameMap;
  44309. /**
  44310. * Creates a new GearVRController from a gamepad
  44311. * @param vrGamepad the gamepad that the controller should be created from
  44312. */
  44313. constructor(vrGamepad: any);
  44314. /**
  44315. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44316. * @param scene scene in which to add meshes
  44317. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44318. */
  44319. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44320. /**
  44321. * Called once for each button that changed state since the last frame
  44322. * @param buttonIdx Which button index changed
  44323. * @param state New state of the button
  44324. * @param changes Which properties on the state changed since last frame
  44325. */
  44326. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44327. }
  44328. }
  44329. declare module BABYLON {
  44330. /**
  44331. * Class containing static functions to help procedurally build meshes
  44332. */
  44333. export class PolyhedronBuilder {
  44334. /**
  44335. * Creates a polyhedron mesh
  44336. * * 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
  44337. * * The parameter `size` (positive float, default 1) sets the polygon size
  44338. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44339. * * 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`
  44340. * * 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
  44341. * * 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)`)
  44342. * * 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
  44343. * * 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
  44344. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44345. * * 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
  44346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44347. * @param name defines the name of the mesh
  44348. * @param options defines the options used to create the mesh
  44349. * @param scene defines the hosting scene
  44350. * @returns the polyhedron mesh
  44351. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44352. */
  44353. static CreatePolyhedron(name: string, options: {
  44354. type?: number;
  44355. size?: number;
  44356. sizeX?: number;
  44357. sizeY?: number;
  44358. sizeZ?: number;
  44359. custom?: any;
  44360. faceUV?: Vector4[];
  44361. faceColors?: Color4[];
  44362. flat?: boolean;
  44363. updatable?: boolean;
  44364. sideOrientation?: number;
  44365. frontUVs?: Vector4;
  44366. backUVs?: Vector4;
  44367. }, scene?: Nullable<Scene>): Mesh;
  44368. }
  44369. }
  44370. declare module BABYLON {
  44371. /**
  44372. * Gizmo that enables scaling a mesh along 3 axis
  44373. */
  44374. export class ScaleGizmo extends Gizmo {
  44375. /**
  44376. * Internal gizmo used for interactions on the x axis
  44377. */
  44378. xGizmo: AxisScaleGizmo;
  44379. /**
  44380. * Internal gizmo used for interactions on the y axis
  44381. */
  44382. yGizmo: AxisScaleGizmo;
  44383. /**
  44384. * Internal gizmo used for interactions on the z axis
  44385. */
  44386. zGizmo: AxisScaleGizmo;
  44387. /**
  44388. * Internal gizmo used to scale all axis equally
  44389. */
  44390. uniformScaleGizmo: AxisScaleGizmo;
  44391. private _meshAttached;
  44392. private _updateGizmoRotationToMatchAttachedMesh;
  44393. private _snapDistance;
  44394. private _scaleRatio;
  44395. private _uniformScalingMesh;
  44396. private _octahedron;
  44397. /** Fires an event when any of it's sub gizmos are dragged */
  44398. onDragStartObservable: Observable<unknown>;
  44399. /** Fires an event when any of it's sub gizmos are released from dragging */
  44400. onDragEndObservable: Observable<unknown>;
  44401. attachedMesh: Nullable<AbstractMesh>;
  44402. /**
  44403. * Creates a ScaleGizmo
  44404. * @param gizmoLayer The utility layer the gizmo will be added to
  44405. */
  44406. constructor(gizmoLayer?: UtilityLayerRenderer);
  44407. updateGizmoRotationToMatchAttachedMesh: boolean;
  44408. /**
  44409. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44410. */
  44411. snapDistance: number;
  44412. /**
  44413. * Ratio for the scale of the gizmo (Default: 1)
  44414. */
  44415. scaleRatio: number;
  44416. /**
  44417. * Disposes of the gizmo
  44418. */
  44419. dispose(): void;
  44420. }
  44421. }
  44422. declare module BABYLON {
  44423. /**
  44424. * Single axis scale gizmo
  44425. */
  44426. export class AxisScaleGizmo extends Gizmo {
  44427. /**
  44428. * Drag behavior responsible for the gizmos dragging interactions
  44429. */
  44430. dragBehavior: PointerDragBehavior;
  44431. private _pointerObserver;
  44432. /**
  44433. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44434. */
  44435. snapDistance: number;
  44436. /**
  44437. * Event that fires each time the gizmo snaps to a new location.
  44438. * * snapDistance is the the change in distance
  44439. */
  44440. onSnapObservable: Observable<{
  44441. snapDistance: number;
  44442. }>;
  44443. /**
  44444. * If the scaling operation should be done on all axis (default: false)
  44445. */
  44446. uniformScaling: boolean;
  44447. private _isEnabled;
  44448. private _parent;
  44449. private _arrow;
  44450. private _coloredMaterial;
  44451. private _hoverMaterial;
  44452. /**
  44453. * Creates an AxisScaleGizmo
  44454. * @param gizmoLayer The utility layer the gizmo will be added to
  44455. * @param dragAxis The axis which the gizmo will be able to scale on
  44456. * @param color The color of the gizmo
  44457. */
  44458. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  44459. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44460. /**
  44461. * If the gizmo is enabled
  44462. */
  44463. isEnabled: boolean;
  44464. /**
  44465. * Disposes of the gizmo
  44466. */
  44467. dispose(): void;
  44468. /**
  44469. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44470. * @param mesh The mesh to replace the default mesh of the gizmo
  44471. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44472. */
  44473. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44474. }
  44475. }
  44476. declare module BABYLON {
  44477. /**
  44478. * Bounding box gizmo
  44479. */
  44480. export class BoundingBoxGizmo extends Gizmo {
  44481. private _lineBoundingBox;
  44482. private _rotateSpheresParent;
  44483. private _scaleBoxesParent;
  44484. private _boundingDimensions;
  44485. private _renderObserver;
  44486. private _pointerObserver;
  44487. private _scaleDragSpeed;
  44488. private _tmpQuaternion;
  44489. private _tmpVector;
  44490. private _tmpRotationMatrix;
  44491. /**
  44492. * 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)
  44493. */
  44494. ignoreChildren: boolean;
  44495. /**
  44496. * 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)
  44497. */
  44498. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44499. /**
  44500. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44501. */
  44502. rotationSphereSize: number;
  44503. /**
  44504. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44505. */
  44506. scaleBoxSize: number;
  44507. /**
  44508. * 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)
  44509. */
  44510. fixedDragMeshScreenSize: boolean;
  44511. /**
  44512. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44513. */
  44514. fixedDragMeshScreenSizeDistanceFactor: number;
  44515. /**
  44516. * Fired when a rotation sphere or scale box is dragged
  44517. */
  44518. onDragStartObservable: Observable<{}>;
  44519. /**
  44520. * Fired when a scale box is dragged
  44521. */
  44522. onScaleBoxDragObservable: Observable<{}>;
  44523. /**
  44524. * Fired when a scale box drag is ended
  44525. */
  44526. onScaleBoxDragEndObservable: Observable<{}>;
  44527. /**
  44528. * Fired when a rotation sphere is dragged
  44529. */
  44530. onRotationSphereDragObservable: Observable<{}>;
  44531. /**
  44532. * Fired when a rotation sphere drag is ended
  44533. */
  44534. onRotationSphereDragEndObservable: Observable<{}>;
  44535. /**
  44536. * 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)
  44537. */
  44538. scalePivot: Nullable<Vector3>;
  44539. /**
  44540. * Mesh used as a pivot to rotate the attached mesh
  44541. */
  44542. private _anchorMesh;
  44543. private _existingMeshScale;
  44544. private _dragMesh;
  44545. private pointerDragBehavior;
  44546. private coloredMaterial;
  44547. private hoverColoredMaterial;
  44548. /**
  44549. * Sets the color of the bounding box gizmo
  44550. * @param color the color to set
  44551. */
  44552. setColor(color: Color3): void;
  44553. /**
  44554. * Creates an BoundingBoxGizmo
  44555. * @param gizmoLayer The utility layer the gizmo will be added to
  44556. * @param color The color of the gizmo
  44557. */
  44558. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44559. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44560. private _selectNode;
  44561. /**
  44562. * Updates the bounding box information for the Gizmo
  44563. */
  44564. updateBoundingBox(): void;
  44565. private _updateRotationSpheres;
  44566. private _updateScaleBoxes;
  44567. /**
  44568. * Enables rotation on the specified axis and disables rotation on the others
  44569. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44570. */
  44571. setEnabledRotationAxis(axis: string): void;
  44572. /**
  44573. * Enables/disables scaling
  44574. * @param enable if scaling should be enabled
  44575. */
  44576. setEnabledScaling(enable: boolean): void;
  44577. private _updateDummy;
  44578. /**
  44579. * Enables a pointer drag behavior on the bounding box of the gizmo
  44580. */
  44581. enableDragBehavior(): void;
  44582. /**
  44583. * Disposes of the gizmo
  44584. */
  44585. dispose(): void;
  44586. /**
  44587. * 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)
  44588. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44589. * @returns the bounding box mesh with the passed in mesh as a child
  44590. */
  44591. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44592. /**
  44593. * CustomMeshes are not supported by this gizmo
  44594. * @param mesh The mesh to replace the default mesh of the gizmo
  44595. */
  44596. setCustomMesh(mesh: Mesh): void;
  44597. }
  44598. }
  44599. declare module BABYLON {
  44600. /**
  44601. * Single plane rotation gizmo
  44602. */
  44603. export class PlaneRotationGizmo extends Gizmo {
  44604. /**
  44605. * Drag behavior responsible for the gizmos dragging interactions
  44606. */
  44607. dragBehavior: PointerDragBehavior;
  44608. private _pointerObserver;
  44609. /**
  44610. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44611. */
  44612. snapDistance: number;
  44613. /**
  44614. * Event that fires each time the gizmo snaps to a new location.
  44615. * * snapDistance is the the change in distance
  44616. */
  44617. onSnapObservable: Observable<{
  44618. snapDistance: number;
  44619. }>;
  44620. private _isEnabled;
  44621. private _parent;
  44622. /**
  44623. * Creates a PlaneRotationGizmo
  44624. * @param gizmoLayer The utility layer the gizmo will be added to
  44625. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44626. * @param color The color of the gizmo
  44627. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44628. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44629. */
  44630. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  44631. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44632. /**
  44633. * If the gizmo is enabled
  44634. */
  44635. isEnabled: boolean;
  44636. /**
  44637. * Disposes of the gizmo
  44638. */
  44639. dispose(): void;
  44640. }
  44641. }
  44642. declare module BABYLON {
  44643. /**
  44644. * Gizmo that enables rotating a mesh along 3 axis
  44645. */
  44646. export class RotationGizmo extends Gizmo {
  44647. /**
  44648. * Internal gizmo used for interactions on the x axis
  44649. */
  44650. xGizmo: PlaneRotationGizmo;
  44651. /**
  44652. * Internal gizmo used for interactions on the y axis
  44653. */
  44654. yGizmo: PlaneRotationGizmo;
  44655. /**
  44656. * Internal gizmo used for interactions on the z axis
  44657. */
  44658. zGizmo: PlaneRotationGizmo;
  44659. /** Fires an event when any of it's sub gizmos are dragged */
  44660. onDragStartObservable: Observable<unknown>;
  44661. /** Fires an event when any of it's sub gizmos are released from dragging */
  44662. onDragEndObservable: Observable<unknown>;
  44663. private _meshAttached;
  44664. attachedMesh: Nullable<AbstractMesh>;
  44665. /**
  44666. * Creates a RotationGizmo
  44667. * @param gizmoLayer The utility layer the gizmo will be added to
  44668. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44669. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44670. */
  44671. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  44672. updateGizmoRotationToMatchAttachedMesh: boolean;
  44673. /**
  44674. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44675. */
  44676. snapDistance: number;
  44677. /**
  44678. * Ratio for the scale of the gizmo (Default: 1)
  44679. */
  44680. scaleRatio: number;
  44681. /**
  44682. * Disposes of the gizmo
  44683. */
  44684. dispose(): void;
  44685. /**
  44686. * CustomMeshes are not supported by this gizmo
  44687. * @param mesh The mesh to replace the default mesh of the gizmo
  44688. */
  44689. setCustomMesh(mesh: Mesh): void;
  44690. }
  44691. }
  44692. declare module BABYLON {
  44693. /**
  44694. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44695. */
  44696. export class GizmoManager implements IDisposable {
  44697. private scene;
  44698. /**
  44699. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44700. */
  44701. gizmos: {
  44702. positionGizmo: Nullable<PositionGizmo>;
  44703. rotationGizmo: Nullable<RotationGizmo>;
  44704. scaleGizmo: Nullable<ScaleGizmo>;
  44705. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44706. };
  44707. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44708. clearGizmoOnEmptyPointerEvent: boolean;
  44709. /** Fires an event when the manager is attached to a mesh */
  44710. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44711. private _gizmosEnabled;
  44712. private _pointerObserver;
  44713. private _attachedMesh;
  44714. private _boundingBoxColor;
  44715. private _defaultUtilityLayer;
  44716. private _defaultKeepDepthUtilityLayer;
  44717. /**
  44718. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44719. */
  44720. boundingBoxDragBehavior: SixDofDragBehavior;
  44721. /**
  44722. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44723. */
  44724. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44725. /**
  44726. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44727. */
  44728. usePointerToAttachGizmos: boolean;
  44729. /**
  44730. * Utility layer that the bounding box gizmo belongs to
  44731. */
  44732. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  44733. /**
  44734. * Utility layer that all gizmos besides bounding box belong to
  44735. */
  44736. readonly utilityLayer: UtilityLayerRenderer;
  44737. /**
  44738. * Instatiates a gizmo manager
  44739. * @param scene the scene to overlay the gizmos on top of
  44740. */
  44741. constructor(scene: Scene);
  44742. /**
  44743. * Attaches a set of gizmos to the specified mesh
  44744. * @param mesh The mesh the gizmo's should be attached to
  44745. */
  44746. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44747. /**
  44748. * If the position gizmo is enabled
  44749. */
  44750. positionGizmoEnabled: boolean;
  44751. /**
  44752. * If the rotation gizmo is enabled
  44753. */
  44754. rotationGizmoEnabled: boolean;
  44755. /**
  44756. * If the scale gizmo is enabled
  44757. */
  44758. scaleGizmoEnabled: boolean;
  44759. /**
  44760. * If the boundingBox gizmo is enabled
  44761. */
  44762. boundingBoxGizmoEnabled: boolean;
  44763. /**
  44764. * Disposes of the gizmo manager
  44765. */
  44766. dispose(): void;
  44767. }
  44768. }
  44769. declare module BABYLON {
  44770. /**
  44771. * A directional light is defined by a direction (what a surprise!).
  44772. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44773. * 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.
  44774. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44775. */
  44776. export class DirectionalLight extends ShadowLight {
  44777. private _shadowFrustumSize;
  44778. /**
  44779. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44780. */
  44781. /**
  44782. * Specifies a fix frustum size for the shadow generation.
  44783. */
  44784. shadowFrustumSize: number;
  44785. private _shadowOrthoScale;
  44786. /**
  44787. * Gets the shadow projection scale against the optimal computed one.
  44788. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44789. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44790. */
  44791. /**
  44792. * Sets the shadow projection scale against the optimal computed one.
  44793. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44794. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44795. */
  44796. shadowOrthoScale: number;
  44797. /**
  44798. * Automatically compute the projection matrix to best fit (including all the casters)
  44799. * on each frame.
  44800. */
  44801. autoUpdateExtends: boolean;
  44802. private _orthoLeft;
  44803. private _orthoRight;
  44804. private _orthoTop;
  44805. private _orthoBottom;
  44806. /**
  44807. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44808. * The directional light is emitted from everywhere in the given direction.
  44809. * It can cast shadows.
  44810. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44811. * @param name The friendly name of the light
  44812. * @param direction The direction of the light
  44813. * @param scene The scene the light belongs to
  44814. */
  44815. constructor(name: string, direction: Vector3, scene: Scene);
  44816. /**
  44817. * Returns the string "DirectionalLight".
  44818. * @return The class name
  44819. */
  44820. getClassName(): string;
  44821. /**
  44822. * Returns the integer 1.
  44823. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44824. */
  44825. getTypeID(): number;
  44826. /**
  44827. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44828. * Returns the DirectionalLight Shadow projection matrix.
  44829. */
  44830. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44831. /**
  44832. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44833. * Returns the DirectionalLight Shadow projection matrix.
  44834. */
  44835. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44836. /**
  44837. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44838. * Returns the DirectionalLight Shadow projection matrix.
  44839. */
  44840. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44841. protected _buildUniformLayout(): void;
  44842. /**
  44843. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44844. * @param effect The effect to update
  44845. * @param lightIndex The index of the light in the effect to update
  44846. * @returns The directional light
  44847. */
  44848. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44849. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  44850. /**
  44851. * Gets the minZ used for shadow according to both the scene and the light.
  44852. *
  44853. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44854. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44855. * @param activeCamera The camera we are returning the min for
  44856. * @returns the depth min z
  44857. */
  44858. getDepthMinZ(activeCamera: Camera): number;
  44859. /**
  44860. * Gets the maxZ used for shadow according to both the scene and the light.
  44861. *
  44862. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44863. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44864. * @param activeCamera The camera we are returning the max for
  44865. * @returns the depth max z
  44866. */
  44867. getDepthMaxZ(activeCamera: Camera): number;
  44868. /**
  44869. * Prepares the list of defines specific to the light type.
  44870. * @param defines the list of defines
  44871. * @param lightIndex defines the index of the light for the effect
  44872. */
  44873. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44874. }
  44875. }
  44876. declare module BABYLON {
  44877. /**
  44878. * Class containing static functions to help procedurally build meshes
  44879. */
  44880. export class HemisphereBuilder {
  44881. /**
  44882. * Creates a hemisphere mesh
  44883. * @param name defines the name of the mesh
  44884. * @param options defines the options used to create the mesh
  44885. * @param scene defines the hosting scene
  44886. * @returns the hemisphere mesh
  44887. */
  44888. static CreateHemisphere(name: string, options: {
  44889. segments?: number;
  44890. diameter?: number;
  44891. sideOrientation?: number;
  44892. }, scene: any): Mesh;
  44893. }
  44894. }
  44895. declare module BABYLON {
  44896. /**
  44897. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44898. * These values define a cone of light starting from the position, emitting toward the direction.
  44899. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44900. * and the exponent defines the speed of the decay of the light with distance (reach).
  44901. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44902. */
  44903. export class SpotLight extends ShadowLight {
  44904. private _angle;
  44905. private _innerAngle;
  44906. private _cosHalfAngle;
  44907. private _lightAngleScale;
  44908. private _lightAngleOffset;
  44909. /**
  44910. * Gets the cone angle of the spot light in Radians.
  44911. */
  44912. /**
  44913. * Sets the cone angle of the spot light in Radians.
  44914. */
  44915. angle: number;
  44916. /**
  44917. * Only used in gltf falloff mode, this defines the angle where
  44918. * the directional falloff will start before cutting at angle which could be seen
  44919. * as outer angle.
  44920. */
  44921. /**
  44922. * Only used in gltf falloff mode, this defines the angle where
  44923. * the directional falloff will start before cutting at angle which could be seen
  44924. * as outer angle.
  44925. */
  44926. innerAngle: number;
  44927. private _shadowAngleScale;
  44928. /**
  44929. * Allows scaling the angle of the light for shadow generation only.
  44930. */
  44931. /**
  44932. * Allows scaling the angle of the light for shadow generation only.
  44933. */
  44934. shadowAngleScale: number;
  44935. /**
  44936. * The light decay speed with the distance from the emission spot.
  44937. */
  44938. exponent: number;
  44939. private _projectionTextureMatrix;
  44940. /**
  44941. * Allows reading the projecton texture
  44942. */
  44943. readonly projectionTextureMatrix: Matrix;
  44944. protected _projectionTextureLightNear: number;
  44945. /**
  44946. * Gets the near clip of the Spotlight for texture projection.
  44947. */
  44948. /**
  44949. * Sets the near clip of the Spotlight for texture projection.
  44950. */
  44951. projectionTextureLightNear: number;
  44952. protected _projectionTextureLightFar: number;
  44953. /**
  44954. * Gets the far clip of the Spotlight for texture projection.
  44955. */
  44956. /**
  44957. * Sets the far clip of the Spotlight for texture projection.
  44958. */
  44959. projectionTextureLightFar: number;
  44960. protected _projectionTextureUpDirection: Vector3;
  44961. /**
  44962. * Gets the Up vector of the Spotlight for texture projection.
  44963. */
  44964. /**
  44965. * Sets the Up vector of the Spotlight for texture projection.
  44966. */
  44967. projectionTextureUpDirection: Vector3;
  44968. private _projectionTexture;
  44969. /**
  44970. * Gets the projection texture of the light.
  44971. */
  44972. /**
  44973. * Sets the projection texture of the light.
  44974. */
  44975. projectionTexture: Nullable<BaseTexture>;
  44976. private _projectionTextureViewLightDirty;
  44977. private _projectionTextureProjectionLightDirty;
  44978. private _projectionTextureDirty;
  44979. private _projectionTextureViewTargetVector;
  44980. private _projectionTextureViewLightMatrix;
  44981. private _projectionTextureProjectionLightMatrix;
  44982. private _projectionTextureScalingMatrix;
  44983. /**
  44984. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44985. * It can cast shadows.
  44986. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44987. * @param name The light friendly name
  44988. * @param position The position of the spot light in the scene
  44989. * @param direction The direction of the light in the scene
  44990. * @param angle The cone angle of the light in Radians
  44991. * @param exponent The light decay speed with the distance from the emission spot
  44992. * @param scene The scene the lights belongs to
  44993. */
  44994. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44995. /**
  44996. * Returns the string "SpotLight".
  44997. * @returns the class name
  44998. */
  44999. getClassName(): string;
  45000. /**
  45001. * Returns the integer 2.
  45002. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45003. */
  45004. getTypeID(): number;
  45005. /**
  45006. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45007. */
  45008. protected _setDirection(value: Vector3): void;
  45009. /**
  45010. * Overrides the position setter to recompute the projection texture view light Matrix.
  45011. */
  45012. protected _setPosition(value: Vector3): void;
  45013. /**
  45014. * 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.
  45015. * Returns the SpotLight.
  45016. */
  45017. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45018. protected _computeProjectionTextureViewLightMatrix(): void;
  45019. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45020. /**
  45021. * Main function for light texture projection matrix computing.
  45022. */
  45023. protected _computeProjectionTextureMatrix(): void;
  45024. protected _buildUniformLayout(): void;
  45025. private _computeAngleValues;
  45026. /**
  45027. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45028. * @param effect The effect to update
  45029. * @param lightIndex The index of the light in the effect to update
  45030. * @returns The spot light
  45031. */
  45032. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45033. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  45034. /**
  45035. * Disposes the light and the associated resources.
  45036. */
  45037. dispose(): void;
  45038. /**
  45039. * Prepares the list of defines specific to the light type.
  45040. * @param defines the list of defines
  45041. * @param lightIndex defines the index of the light for the effect
  45042. */
  45043. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45044. }
  45045. }
  45046. declare module BABYLON {
  45047. /**
  45048. * Gizmo that enables viewing a light
  45049. */
  45050. export class LightGizmo extends Gizmo {
  45051. private _lightMesh;
  45052. private _material;
  45053. private cachedPosition;
  45054. private cachedForward;
  45055. /**
  45056. * Creates a LightGizmo
  45057. * @param gizmoLayer The utility layer the gizmo will be added to
  45058. */
  45059. constructor(gizmoLayer?: UtilityLayerRenderer);
  45060. private _light;
  45061. /**
  45062. * The light that the gizmo is attached to
  45063. */
  45064. light: Nullable<Light>;
  45065. /**
  45066. * Gets the material used to render the light gizmo
  45067. */
  45068. readonly material: StandardMaterial;
  45069. /**
  45070. * @hidden
  45071. * Updates the gizmo to match the attached mesh's position/rotation
  45072. */
  45073. protected _update(): void;
  45074. private static _Scale;
  45075. /**
  45076. * Creates the lines for a light mesh
  45077. */
  45078. private static _createLightLines;
  45079. /**
  45080. * Disposes of the light gizmo
  45081. */
  45082. dispose(): void;
  45083. private static _CreateHemisphericLightMesh;
  45084. private static _CreatePointLightMesh;
  45085. private static _CreateSpotLightMesh;
  45086. private static _CreateDirectionalLightMesh;
  45087. }
  45088. }
  45089. declare module BABYLON {
  45090. /** @hidden */
  45091. export var backgroundFragmentDeclaration: {
  45092. name: string;
  45093. shader: string;
  45094. };
  45095. }
  45096. declare module BABYLON {
  45097. /** @hidden */
  45098. export var backgroundUboDeclaration: {
  45099. name: string;
  45100. shader: string;
  45101. };
  45102. }
  45103. declare module BABYLON {
  45104. /** @hidden */
  45105. export var backgroundPixelShader: {
  45106. name: string;
  45107. shader: string;
  45108. };
  45109. }
  45110. declare module BABYLON {
  45111. /** @hidden */
  45112. export var backgroundVertexDeclaration: {
  45113. name: string;
  45114. shader: string;
  45115. };
  45116. }
  45117. declare module BABYLON {
  45118. /** @hidden */
  45119. export var backgroundVertexShader: {
  45120. name: string;
  45121. shader: string;
  45122. };
  45123. }
  45124. declare module BABYLON {
  45125. /**
  45126. * Background material used to create an efficient environement around your scene.
  45127. */
  45128. export class BackgroundMaterial extends PushMaterial {
  45129. /**
  45130. * Standard reflectance value at parallel view angle.
  45131. */
  45132. static StandardReflectance0: number;
  45133. /**
  45134. * Standard reflectance value at grazing angle.
  45135. */
  45136. static StandardReflectance90: number;
  45137. protected _primaryColor: Color3;
  45138. /**
  45139. * Key light Color (multiply against the environement texture)
  45140. */
  45141. primaryColor: Color3;
  45142. protected __perceptualColor: Nullable<Color3>;
  45143. /**
  45144. * Experimental Internal Use Only.
  45145. *
  45146. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45147. * This acts as a helper to set the primary color to a more "human friendly" value.
  45148. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45149. * output color as close as possible from the chosen value.
  45150. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45151. * part of lighting setup.)
  45152. */ private _perceptualColor: Nullable<Color3>;
  45153. protected _primaryColorShadowLevel: float;
  45154. /**
  45155. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45156. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45157. */
  45158. primaryColorShadowLevel: float;
  45159. protected _primaryColorHighlightLevel: float;
  45160. /**
  45161. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45162. * The primary color is used at the level chosen to define what the white area would look.
  45163. */
  45164. primaryColorHighlightLevel: float;
  45165. protected _reflectionTexture: Nullable<BaseTexture>;
  45166. /**
  45167. * Reflection Texture used in the material.
  45168. * Should be author in a specific way for the best result (refer to the documentation).
  45169. */
  45170. reflectionTexture: Nullable<BaseTexture>;
  45171. protected _reflectionBlur: float;
  45172. /**
  45173. * Reflection Texture level of blur.
  45174. *
  45175. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45176. * texture twice.
  45177. */
  45178. reflectionBlur: float;
  45179. protected _diffuseTexture: Nullable<BaseTexture>;
  45180. /**
  45181. * Diffuse Texture used in the material.
  45182. * Should be author in a specific way for the best result (refer to the documentation).
  45183. */
  45184. diffuseTexture: Nullable<BaseTexture>;
  45185. protected _shadowLights: Nullable<IShadowLight[]>;
  45186. /**
  45187. * Specify the list of lights casting shadow on the material.
  45188. * All scene shadow lights will be included if null.
  45189. */
  45190. shadowLights: Nullable<IShadowLight[]>;
  45191. protected _shadowLevel: float;
  45192. /**
  45193. * Helps adjusting the shadow to a softer level if required.
  45194. * 0 means black shadows and 1 means no shadows.
  45195. */
  45196. shadowLevel: float;
  45197. protected _sceneCenter: Vector3;
  45198. /**
  45199. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45200. * It is usually zero but might be interesting to modify according to your setup.
  45201. */
  45202. sceneCenter: Vector3;
  45203. protected _opacityFresnel: boolean;
  45204. /**
  45205. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45206. * This helps ensuring a nice transition when the camera goes under the ground.
  45207. */
  45208. opacityFresnel: boolean;
  45209. protected _reflectionFresnel: boolean;
  45210. /**
  45211. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45212. * This helps adding a mirror texture on the ground.
  45213. */
  45214. reflectionFresnel: boolean;
  45215. protected _reflectionFalloffDistance: number;
  45216. /**
  45217. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45218. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45219. */
  45220. reflectionFalloffDistance: number;
  45221. protected _reflectionAmount: number;
  45222. /**
  45223. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45224. */
  45225. reflectionAmount: number;
  45226. protected _reflectionReflectance0: number;
  45227. /**
  45228. * This specifies the weight of the reflection at grazing angle.
  45229. */
  45230. reflectionReflectance0: number;
  45231. protected _reflectionReflectance90: number;
  45232. /**
  45233. * This specifies the weight of the reflection at a perpendicular point of view.
  45234. */
  45235. reflectionReflectance90: number;
  45236. /**
  45237. * Sets the reflection reflectance fresnel values according to the default standard
  45238. * empirically know to work well :-)
  45239. */
  45240. reflectionStandardFresnelWeight: number;
  45241. protected _useRGBColor: boolean;
  45242. /**
  45243. * Helps to directly use the maps channels instead of their level.
  45244. */
  45245. useRGBColor: boolean;
  45246. protected _enableNoise: boolean;
  45247. /**
  45248. * This helps reducing the banding effect that could occur on the background.
  45249. */
  45250. enableNoise: boolean;
  45251. /**
  45252. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45253. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45254. * Recommended to be keep at 1.0 except for special cases.
  45255. */
  45256. fovMultiplier: number;
  45257. private _fovMultiplier;
  45258. /**
  45259. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45260. */
  45261. useEquirectangularFOV: boolean;
  45262. private _maxSimultaneousLights;
  45263. /**
  45264. * Number of Simultaneous lights allowed on the material.
  45265. */
  45266. maxSimultaneousLights: int;
  45267. /**
  45268. * Default configuration related to image processing available in the Background Material.
  45269. */
  45270. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45271. /**
  45272. * Keep track of the image processing observer to allow dispose and replace.
  45273. */
  45274. private _imageProcessingObserver;
  45275. /**
  45276. * Attaches a new image processing configuration to the PBR Material.
  45277. * @param configuration (if null the scene configuration will be use)
  45278. */
  45279. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45280. /**
  45281. * Gets the image processing configuration used either in this material.
  45282. */
  45283. /**
  45284. * Sets the Default image processing configuration used either in the this material.
  45285. *
  45286. * If sets to null, the scene one is in use.
  45287. */
  45288. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45289. /**
  45290. * Gets wether the color curves effect is enabled.
  45291. */
  45292. /**
  45293. * Sets wether the color curves effect is enabled.
  45294. */
  45295. cameraColorCurvesEnabled: boolean;
  45296. /**
  45297. * Gets wether the color grading effect is enabled.
  45298. */
  45299. /**
  45300. * Gets wether the color grading effect is enabled.
  45301. */
  45302. cameraColorGradingEnabled: boolean;
  45303. /**
  45304. * Gets wether tonemapping is enabled or not.
  45305. */
  45306. /**
  45307. * Sets wether tonemapping is enabled or not
  45308. */
  45309. cameraToneMappingEnabled: boolean;
  45310. /**
  45311. * The camera exposure used on this material.
  45312. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45313. * This corresponds to a photographic exposure.
  45314. */
  45315. /**
  45316. * The camera exposure used on this material.
  45317. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45318. * This corresponds to a photographic exposure.
  45319. */
  45320. cameraExposure: float;
  45321. /**
  45322. * Gets The camera contrast used on this material.
  45323. */
  45324. /**
  45325. * Sets The camera contrast used on this material.
  45326. */
  45327. cameraContrast: float;
  45328. /**
  45329. * Gets the Color Grading 2D Lookup Texture.
  45330. */
  45331. /**
  45332. * Sets the Color Grading 2D Lookup Texture.
  45333. */
  45334. cameraColorGradingTexture: Nullable<BaseTexture>;
  45335. /**
  45336. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45337. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45338. * 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;
  45339. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45340. */
  45341. /**
  45342. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45343. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45344. * 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;
  45345. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45346. */
  45347. cameraColorCurves: Nullable<ColorCurves>;
  45348. /**
  45349. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45350. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45351. */
  45352. switchToBGR: boolean;
  45353. private _renderTargets;
  45354. private _reflectionControls;
  45355. private _white;
  45356. private _primaryShadowColor;
  45357. private _primaryHighlightColor;
  45358. /**
  45359. * Instantiates a Background Material in the given scene
  45360. * @param name The friendly name of the material
  45361. * @param scene The scene to add the material to
  45362. */
  45363. constructor(name: string, scene: Scene);
  45364. /**
  45365. * Gets a boolean indicating that current material needs to register RTT
  45366. */
  45367. readonly hasRenderTargetTextures: boolean;
  45368. /**
  45369. * The entire material has been created in order to prevent overdraw.
  45370. * @returns false
  45371. */
  45372. needAlphaTesting(): boolean;
  45373. /**
  45374. * The entire material has been created in order to prevent overdraw.
  45375. * @returns true if blending is enable
  45376. */
  45377. needAlphaBlending(): boolean;
  45378. /**
  45379. * Checks wether the material is ready to be rendered for a given mesh.
  45380. * @param mesh The mesh to render
  45381. * @param subMesh The submesh to check against
  45382. * @param useInstances Specify wether or not the material is used with instances
  45383. * @returns true if all the dependencies are ready (Textures, Effects...)
  45384. */
  45385. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45386. /**
  45387. * Compute the primary color according to the chosen perceptual color.
  45388. */
  45389. private _computePrimaryColorFromPerceptualColor;
  45390. /**
  45391. * Compute the highlights and shadow colors according to their chosen levels.
  45392. */
  45393. private _computePrimaryColors;
  45394. /**
  45395. * Build the uniform buffer used in the material.
  45396. */
  45397. buildUniformLayout(): void;
  45398. /**
  45399. * Unbind the material.
  45400. */
  45401. unbind(): void;
  45402. /**
  45403. * Bind only the world matrix to the material.
  45404. * @param world The world matrix to bind.
  45405. */
  45406. bindOnlyWorldMatrix(world: Matrix): void;
  45407. /**
  45408. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45409. * @param world The world matrix to bind.
  45410. * @param subMesh The submesh to bind for.
  45411. */
  45412. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45413. /**
  45414. * Checks to see if a texture is used in the material.
  45415. * @param texture - Base texture to use.
  45416. * @returns - Boolean specifying if a texture is used in the material.
  45417. */
  45418. hasTexture(texture: BaseTexture): boolean;
  45419. /**
  45420. * Dispose the material.
  45421. * @param forceDisposeEffect Force disposal of the associated effect.
  45422. * @param forceDisposeTextures Force disposal of the associated textures.
  45423. */
  45424. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45425. /**
  45426. * Clones the material.
  45427. * @param name The cloned name.
  45428. * @returns The cloned material.
  45429. */
  45430. clone(name: string): BackgroundMaterial;
  45431. /**
  45432. * Serializes the current material to its JSON representation.
  45433. * @returns The JSON representation.
  45434. */
  45435. serialize(): any;
  45436. /**
  45437. * Gets the class name of the material
  45438. * @returns "BackgroundMaterial"
  45439. */
  45440. getClassName(): string;
  45441. /**
  45442. * Parse a JSON input to create back a background material.
  45443. * @param source The JSON data to parse
  45444. * @param scene The scene to create the parsed material in
  45445. * @param rootUrl The root url of the assets the material depends upon
  45446. * @returns the instantiated BackgroundMaterial.
  45447. */
  45448. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45449. }
  45450. }
  45451. declare module BABYLON {
  45452. /**
  45453. * Represents the different options available during the creation of
  45454. * a Environment helper.
  45455. *
  45456. * This can control the default ground, skybox and image processing setup of your scene.
  45457. */
  45458. export interface IEnvironmentHelperOptions {
  45459. /**
  45460. * Specifies wether or not to create a ground.
  45461. * True by default.
  45462. */
  45463. createGround: boolean;
  45464. /**
  45465. * Specifies the ground size.
  45466. * 15 by default.
  45467. */
  45468. groundSize: number;
  45469. /**
  45470. * The texture used on the ground for the main color.
  45471. * Comes from the BabylonJS CDN by default.
  45472. *
  45473. * Remarks: Can be either a texture or a url.
  45474. */
  45475. groundTexture: string | BaseTexture;
  45476. /**
  45477. * The color mixed in the ground texture by default.
  45478. * BabylonJS clearColor by default.
  45479. */
  45480. groundColor: Color3;
  45481. /**
  45482. * Specifies the ground opacity.
  45483. * 1 by default.
  45484. */
  45485. groundOpacity: number;
  45486. /**
  45487. * Enables the ground to receive shadows.
  45488. * True by default.
  45489. */
  45490. enableGroundShadow: boolean;
  45491. /**
  45492. * Helps preventing the shadow to be fully black on the ground.
  45493. * 0.5 by default.
  45494. */
  45495. groundShadowLevel: number;
  45496. /**
  45497. * Creates a mirror texture attach to the ground.
  45498. * false by default.
  45499. */
  45500. enableGroundMirror: boolean;
  45501. /**
  45502. * Specifies the ground mirror size ratio.
  45503. * 0.3 by default as the default kernel is 64.
  45504. */
  45505. groundMirrorSizeRatio: number;
  45506. /**
  45507. * Specifies the ground mirror blur kernel size.
  45508. * 64 by default.
  45509. */
  45510. groundMirrorBlurKernel: number;
  45511. /**
  45512. * Specifies the ground mirror visibility amount.
  45513. * 1 by default
  45514. */
  45515. groundMirrorAmount: number;
  45516. /**
  45517. * Specifies the ground mirror reflectance weight.
  45518. * This uses the standard weight of the background material to setup the fresnel effect
  45519. * of the mirror.
  45520. * 1 by default.
  45521. */
  45522. groundMirrorFresnelWeight: number;
  45523. /**
  45524. * Specifies the ground mirror Falloff distance.
  45525. * This can helps reducing the size of the reflection.
  45526. * 0 by Default.
  45527. */
  45528. groundMirrorFallOffDistance: number;
  45529. /**
  45530. * Specifies the ground mirror texture type.
  45531. * Unsigned Int by Default.
  45532. */
  45533. groundMirrorTextureType: number;
  45534. /**
  45535. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45536. * the shown objects.
  45537. */
  45538. groundYBias: number;
  45539. /**
  45540. * Specifies wether or not to create a skybox.
  45541. * True by default.
  45542. */
  45543. createSkybox: boolean;
  45544. /**
  45545. * Specifies the skybox size.
  45546. * 20 by default.
  45547. */
  45548. skyboxSize: number;
  45549. /**
  45550. * The texture used on the skybox for the main color.
  45551. * Comes from the BabylonJS CDN by default.
  45552. *
  45553. * Remarks: Can be either a texture or a url.
  45554. */
  45555. skyboxTexture: string | BaseTexture;
  45556. /**
  45557. * The color mixed in the skybox texture by default.
  45558. * BabylonJS clearColor by default.
  45559. */
  45560. skyboxColor: Color3;
  45561. /**
  45562. * The background rotation around the Y axis of the scene.
  45563. * This helps aligning the key lights of your scene with the background.
  45564. * 0 by default.
  45565. */
  45566. backgroundYRotation: number;
  45567. /**
  45568. * Compute automatically the size of the elements to best fit with the scene.
  45569. */
  45570. sizeAuto: boolean;
  45571. /**
  45572. * Default position of the rootMesh if autoSize is not true.
  45573. */
  45574. rootPosition: Vector3;
  45575. /**
  45576. * Sets up the image processing in the scene.
  45577. * true by default.
  45578. */
  45579. setupImageProcessing: boolean;
  45580. /**
  45581. * The texture used as your environment texture in the scene.
  45582. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45583. *
  45584. * Remarks: Can be either a texture or a url.
  45585. */
  45586. environmentTexture: string | BaseTexture;
  45587. /**
  45588. * The value of the exposure to apply to the scene.
  45589. * 0.6 by default if setupImageProcessing is true.
  45590. */
  45591. cameraExposure: number;
  45592. /**
  45593. * The value of the contrast to apply to the scene.
  45594. * 1.6 by default if setupImageProcessing is true.
  45595. */
  45596. cameraContrast: number;
  45597. /**
  45598. * Specifies wether or not tonemapping should be enabled in the scene.
  45599. * true by default if setupImageProcessing is true.
  45600. */
  45601. toneMappingEnabled: boolean;
  45602. }
  45603. /**
  45604. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45605. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45606. * It also helps with the default setup of your imageProcessing configuration.
  45607. */
  45608. export class EnvironmentHelper {
  45609. /**
  45610. * Default ground texture URL.
  45611. */
  45612. private static _groundTextureCDNUrl;
  45613. /**
  45614. * Default skybox texture URL.
  45615. */
  45616. private static _skyboxTextureCDNUrl;
  45617. /**
  45618. * Default environment texture URL.
  45619. */
  45620. private static _environmentTextureCDNUrl;
  45621. /**
  45622. * Creates the default options for the helper.
  45623. */
  45624. private static _getDefaultOptions;
  45625. private _rootMesh;
  45626. /**
  45627. * Gets the root mesh created by the helper.
  45628. */
  45629. readonly rootMesh: Mesh;
  45630. private _skybox;
  45631. /**
  45632. * Gets the skybox created by the helper.
  45633. */
  45634. readonly skybox: Nullable<Mesh>;
  45635. private _skyboxTexture;
  45636. /**
  45637. * Gets the skybox texture created by the helper.
  45638. */
  45639. readonly skyboxTexture: Nullable<BaseTexture>;
  45640. private _skyboxMaterial;
  45641. /**
  45642. * Gets the skybox material created by the helper.
  45643. */
  45644. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45645. private _ground;
  45646. /**
  45647. * Gets the ground mesh created by the helper.
  45648. */
  45649. readonly ground: Nullable<Mesh>;
  45650. private _groundTexture;
  45651. /**
  45652. * Gets the ground texture created by the helper.
  45653. */
  45654. readonly groundTexture: Nullable<BaseTexture>;
  45655. private _groundMirror;
  45656. /**
  45657. * Gets the ground mirror created by the helper.
  45658. */
  45659. readonly groundMirror: Nullable<MirrorTexture>;
  45660. /**
  45661. * Gets the ground mirror render list to helps pushing the meshes
  45662. * you wish in the ground reflection.
  45663. */
  45664. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45665. private _groundMaterial;
  45666. /**
  45667. * Gets the ground material created by the helper.
  45668. */
  45669. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45670. /**
  45671. * Stores the creation options.
  45672. */
  45673. private readonly _scene;
  45674. private _options;
  45675. /**
  45676. * This observable will be notified with any error during the creation of the environment,
  45677. * mainly texture creation errors.
  45678. */
  45679. onErrorObservable: Observable<{
  45680. message?: string;
  45681. exception?: any;
  45682. }>;
  45683. /**
  45684. * constructor
  45685. * @param options Defines the options we want to customize the helper
  45686. * @param scene The scene to add the material to
  45687. */
  45688. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45689. /**
  45690. * Updates the background according to the new options
  45691. * @param options
  45692. */
  45693. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45694. /**
  45695. * Sets the primary color of all the available elements.
  45696. * @param color the main color to affect to the ground and the background
  45697. */
  45698. setMainColor(color: Color3): void;
  45699. /**
  45700. * Setup the image processing according to the specified options.
  45701. */
  45702. private _setupImageProcessing;
  45703. /**
  45704. * Setup the environment texture according to the specified options.
  45705. */
  45706. private _setupEnvironmentTexture;
  45707. /**
  45708. * Setup the background according to the specified options.
  45709. */
  45710. private _setupBackground;
  45711. /**
  45712. * Get the scene sizes according to the setup.
  45713. */
  45714. private _getSceneSize;
  45715. /**
  45716. * Setup the ground according to the specified options.
  45717. */
  45718. private _setupGround;
  45719. /**
  45720. * Setup the ground material according to the specified options.
  45721. */
  45722. private _setupGroundMaterial;
  45723. /**
  45724. * Setup the ground diffuse texture according to the specified options.
  45725. */
  45726. private _setupGroundDiffuseTexture;
  45727. /**
  45728. * Setup the ground mirror texture according to the specified options.
  45729. */
  45730. private _setupGroundMirrorTexture;
  45731. /**
  45732. * Setup the ground to receive the mirror texture.
  45733. */
  45734. private _setupMirrorInGroundMaterial;
  45735. /**
  45736. * Setup the skybox according to the specified options.
  45737. */
  45738. private _setupSkybox;
  45739. /**
  45740. * Setup the skybox material according to the specified options.
  45741. */
  45742. private _setupSkyboxMaterial;
  45743. /**
  45744. * Setup the skybox reflection texture according to the specified options.
  45745. */
  45746. private _setupSkyboxReflectionTexture;
  45747. private _errorHandler;
  45748. /**
  45749. * Dispose all the elements created by the Helper.
  45750. */
  45751. dispose(): void;
  45752. }
  45753. }
  45754. declare module BABYLON {
  45755. /**
  45756. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45757. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45758. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45759. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45760. */
  45761. export class PhotoDome extends TransformNode {
  45762. /**
  45763. * Define the image as a Monoscopic panoramic 360 image.
  45764. */
  45765. static readonly MODE_MONOSCOPIC: number;
  45766. /**
  45767. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45768. */
  45769. static readonly MODE_TOPBOTTOM: number;
  45770. /**
  45771. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45772. */
  45773. static readonly MODE_SIDEBYSIDE: number;
  45774. private _useDirectMapping;
  45775. /**
  45776. * The texture being displayed on the sphere
  45777. */
  45778. protected _photoTexture: Texture;
  45779. /**
  45780. * Gets or sets the texture being displayed on the sphere
  45781. */
  45782. photoTexture: Texture;
  45783. /**
  45784. * Observable raised when an error occured while loading the 360 image
  45785. */
  45786. onLoadErrorObservable: Observable<string>;
  45787. /**
  45788. * The skybox material
  45789. */
  45790. protected _material: BackgroundMaterial;
  45791. /**
  45792. * The surface used for the skybox
  45793. */
  45794. protected _mesh: Mesh;
  45795. /**
  45796. * Gets the mesh used for the skybox.
  45797. */
  45798. readonly mesh: Mesh;
  45799. /**
  45800. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45801. * Also see the options.resolution property.
  45802. */
  45803. fovMultiplier: number;
  45804. private _imageMode;
  45805. /**
  45806. * Gets or set the current video mode for the video. It can be:
  45807. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  45808. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45809. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45810. */
  45811. imageMode: number;
  45812. /**
  45813. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45814. * @param name Element's name, child elements will append suffixes for their own names.
  45815. * @param urlsOfPhoto defines the url of the photo to display
  45816. * @param options defines an object containing optional or exposed sub element properties
  45817. * @param onError defines a callback called when an error occured while loading the texture
  45818. */
  45819. constructor(name: string, urlOfPhoto: string, options: {
  45820. resolution?: number;
  45821. size?: number;
  45822. useDirectMapping?: boolean;
  45823. faceForward?: boolean;
  45824. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45825. private _onBeforeCameraRenderObserver;
  45826. private _changeImageMode;
  45827. /**
  45828. * Releases resources associated with this node.
  45829. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45830. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45831. */
  45832. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45833. }
  45834. }
  45835. declare module BABYLON {
  45836. /**
  45837. * Class used to host RGBD texture specific utilities
  45838. */
  45839. export class RGBDTextureTools {
  45840. /**
  45841. * Expand the RGBD Texture from RGBD to Half Float if possible.
  45842. * @param texture the texture to expand.
  45843. */
  45844. static ExpandRGBDTexture(texture: Texture): void;
  45845. }
  45846. }
  45847. declare module BABYLON {
  45848. /**
  45849. * Class used to host texture specific utilities
  45850. */
  45851. export class BRDFTextureTools {
  45852. /**
  45853. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45854. * @param scene defines the hosting scene
  45855. * @returns the environment BRDF texture
  45856. */
  45857. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45858. private static _environmentBRDFBase64Texture;
  45859. }
  45860. }
  45861. declare module BABYLON {
  45862. /**
  45863. * @hidden
  45864. */
  45865. export interface IMaterialClearCoatDefines {
  45866. CLEARCOAT: boolean;
  45867. CLEARCOAT_DEFAULTIOR: boolean;
  45868. CLEARCOAT_TEXTURE: boolean;
  45869. CLEARCOAT_TEXTUREDIRECTUV: number;
  45870. CLEARCOAT_BUMP: boolean;
  45871. CLEARCOAT_BUMPDIRECTUV: number;
  45872. CLEARCOAT_TINT: boolean;
  45873. CLEARCOAT_TINT_TEXTURE: boolean;
  45874. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45875. /** @hidden */ private _areTexturesDirty: boolean;
  45876. }
  45877. /**
  45878. * Define the code related to the clear coat parameters of the pbr material.
  45879. */
  45880. export class PBRClearCoatConfiguration {
  45881. /**
  45882. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45883. * The default fits with a polyurethane material.
  45884. */
  45885. private static readonly _DefaultIndexOfRefraction;
  45886. private _isEnabled;
  45887. /**
  45888. * Defines if the clear coat is enabled in the material.
  45889. */
  45890. isEnabled: boolean;
  45891. /**
  45892. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45893. */
  45894. intensity: number;
  45895. /**
  45896. * Defines the clear coat layer roughness.
  45897. */
  45898. roughness: number;
  45899. private _indexOfRefraction;
  45900. /**
  45901. * Defines the index of refraction of the clear coat.
  45902. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45903. * The default fits with a polyurethane material.
  45904. * Changing the default value is more performance intensive.
  45905. */
  45906. indexOfRefraction: number;
  45907. private _texture;
  45908. /**
  45909. * Stores the clear coat values in a texture.
  45910. */
  45911. texture: Nullable<BaseTexture>;
  45912. private _bumpTexture;
  45913. /**
  45914. * Define the clear coat specific bump texture.
  45915. */
  45916. bumpTexture: Nullable<BaseTexture>;
  45917. private _isTintEnabled;
  45918. /**
  45919. * Defines if the clear coat tint is enabled in the material.
  45920. */
  45921. isTintEnabled: boolean;
  45922. /**
  45923. * Defines the clear coat tint of the material.
  45924. * This is only use if tint is enabled
  45925. */
  45926. tintColor: Color3;
  45927. /**
  45928. * Defines the distance at which the tint color should be found in the
  45929. * clear coat media.
  45930. * This is only use if tint is enabled
  45931. */
  45932. tintColorAtDistance: number;
  45933. /**
  45934. * Defines the clear coat layer thickness.
  45935. * This is only use if tint is enabled
  45936. */
  45937. tintThickness: number;
  45938. private _tintTexture;
  45939. /**
  45940. * Stores the clear tint values in a texture.
  45941. * rgb is tint
  45942. * a is a thickness factor
  45943. */
  45944. tintTexture: Nullable<BaseTexture>;
  45945. /** @hidden */
  45946. private _internalMarkAllSubMeshesAsTexturesDirty;
  45947. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  45948. /**
  45949. * Instantiate a new istance of clear coat configuration.
  45950. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45951. */
  45952. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45953. /**
  45954. * Gets wehter the submesh is ready to be used or not.
  45955. * @param defines the list of "defines" to update.
  45956. * @param scene defines the scene the material belongs to.
  45957. * @param engine defines the engine the material belongs to.
  45958. * @param disableBumpMap defines wether the material disables bump or not.
  45959. * @returns - boolean indicating that the submesh is ready or not.
  45960. */
  45961. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45962. /**
  45963. * Checks to see if a texture is used in the material.
  45964. * @param defines the list of "defines" to update.
  45965. * @param scene defines the scene to the material belongs to.
  45966. */
  45967. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45968. /**
  45969. * Binds the material data.
  45970. * @param uniformBuffer defines the Uniform buffer to fill in.
  45971. * @param scene defines the scene the material belongs to.
  45972. * @param engine defines the engine the material belongs to.
  45973. * @param disableBumpMap defines wether the material disables bump or not.
  45974. * @param isFrozen defines wether the material is frozen or not.
  45975. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45976. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45977. */
  45978. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45979. /**
  45980. * Checks to see if a texture is used in the material.
  45981. * @param texture - Base texture to use.
  45982. * @returns - Boolean specifying if a texture is used in the material.
  45983. */
  45984. hasTexture(texture: BaseTexture): boolean;
  45985. /**
  45986. * Returns an array of the actively used textures.
  45987. * @param activeTextures Array of BaseTextures
  45988. */
  45989. getActiveTextures(activeTextures: BaseTexture[]): void;
  45990. /**
  45991. * Returns the animatable textures.
  45992. * @param animatables Array of animatable textures.
  45993. */
  45994. getAnimatables(animatables: IAnimatable[]): void;
  45995. /**
  45996. * Disposes the resources of the material.
  45997. * @param forceDisposeTextures - Forces the disposal of all textures.
  45998. */
  45999. dispose(forceDisposeTextures?: boolean): void;
  46000. /**
  46001. * Get the current class name of the texture useful for serialization or dynamic coding.
  46002. * @returns "PBRClearCoatConfiguration"
  46003. */
  46004. getClassName(): string;
  46005. /**
  46006. * Add fallbacks to the effect fallbacks list.
  46007. * @param defines defines the Base texture to use.
  46008. * @param fallbacks defines the current fallback list.
  46009. * @param currentRank defines the current fallback rank.
  46010. * @returns the new fallback rank.
  46011. */
  46012. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46013. /**
  46014. * Add the required uniforms to the current list.
  46015. * @param uniforms defines the current uniform list.
  46016. */
  46017. static AddUniforms(uniforms: string[]): void;
  46018. /**
  46019. * Add the required samplers to the current list.
  46020. * @param samplers defines the current sampler list.
  46021. */
  46022. static AddSamplers(samplers: string[]): void;
  46023. /**
  46024. * Add the required uniforms to the current buffer.
  46025. * @param uniformBuffer defines the current uniform buffer.
  46026. */
  46027. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46028. /**
  46029. * Makes a duplicate of the current configuration into another one.
  46030. * @param clearCoatConfiguration define the config where to copy the info
  46031. */
  46032. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46033. /**
  46034. * Serializes this clear coat configuration.
  46035. * @returns - An object with the serialized config.
  46036. */
  46037. serialize(): any;
  46038. /**
  46039. * Parses a anisotropy Configuration from a serialized object.
  46040. * @param source - Serialized object.
  46041. * @param scene Defines the scene we are parsing for
  46042. * @param rootUrl Defines the rootUrl to load from
  46043. */
  46044. parse(source: any, scene: Scene, rootUrl: string): void;
  46045. }
  46046. }
  46047. declare module BABYLON {
  46048. /**
  46049. * @hidden
  46050. */
  46051. export interface IMaterialAnisotropicDefines {
  46052. ANISOTROPIC: boolean;
  46053. ANISOTROPIC_TEXTURE: boolean;
  46054. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46055. MAINUV1: boolean; private _areTexturesDirty: boolean; private _needUVs: boolean;
  46056. }
  46057. /**
  46058. * Define the code related to the anisotropic parameters of the pbr material.
  46059. */
  46060. export class PBRAnisotropicConfiguration {
  46061. private _isEnabled;
  46062. /**
  46063. * Defines if the anisotropy is enabled in the material.
  46064. */
  46065. isEnabled: boolean;
  46066. /**
  46067. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46068. */
  46069. intensity: number;
  46070. /**
  46071. * Defines if the effect is along the tangents, bitangents or in between.
  46072. * By default, the effect is "strectching" the highlights along the tangents.
  46073. */
  46074. direction: Vector2;
  46075. private _texture;
  46076. /**
  46077. * Stores the anisotropy values in a texture.
  46078. * rg is direction (like normal from -1 to 1)
  46079. * b is a intensity
  46080. */
  46081. texture: Nullable<BaseTexture>;
  46082. /** @hidden */
  46083. private _internalMarkAllSubMeshesAsTexturesDirty;
  46084. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  46085. /**
  46086. * Instantiate a new istance of anisotropy configuration.
  46087. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46088. */
  46089. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46090. /**
  46091. * Specifies that the submesh is ready to be used.
  46092. * @param defines the list of "defines" to update.
  46093. * @param scene defines the scene the material belongs to.
  46094. * @returns - boolean indicating that the submesh is ready or not.
  46095. */
  46096. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46097. /**
  46098. * Checks to see if a texture is used in the material.
  46099. * @param defines the list of "defines" to update.
  46100. * @param mesh the mesh we are preparing the defines for.
  46101. * @param scene defines the scene the material belongs to.
  46102. */
  46103. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46104. /**
  46105. * Binds the material data.
  46106. * @param uniformBuffer defines the Uniform buffer to fill in.
  46107. * @param scene defines the scene the material belongs to.
  46108. * @param isFrozen defines wether the material is frozen or not.
  46109. */
  46110. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46111. /**
  46112. * Checks to see if a texture is used in the material.
  46113. * @param texture - Base texture to use.
  46114. * @returns - Boolean specifying if a texture is used in the material.
  46115. */
  46116. hasTexture(texture: BaseTexture): boolean;
  46117. /**
  46118. * Returns an array of the actively used textures.
  46119. * @param activeTextures Array of BaseTextures
  46120. */
  46121. getActiveTextures(activeTextures: BaseTexture[]): void;
  46122. /**
  46123. * Returns the animatable textures.
  46124. * @param animatables Array of animatable textures.
  46125. */
  46126. getAnimatables(animatables: IAnimatable[]): void;
  46127. /**
  46128. * Disposes the resources of the material.
  46129. * @param forceDisposeTextures - Forces the disposal of all textures.
  46130. */
  46131. dispose(forceDisposeTextures?: boolean): void;
  46132. /**
  46133. * Get the current class name of the texture useful for serialization or dynamic coding.
  46134. * @returns "PBRAnisotropicConfiguration"
  46135. */
  46136. getClassName(): string;
  46137. /**
  46138. * Add fallbacks to the effect fallbacks list.
  46139. * @param defines defines the Base texture to use.
  46140. * @param fallbacks defines the current fallback list.
  46141. * @param currentRank defines the current fallback rank.
  46142. * @returns the new fallback rank.
  46143. */
  46144. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46145. /**
  46146. * Add the required uniforms to the current list.
  46147. * @param uniforms defines the current uniform list.
  46148. */
  46149. static AddUniforms(uniforms: string[]): void;
  46150. /**
  46151. * Add the required uniforms to the current buffer.
  46152. * @param uniformBuffer defines the current uniform buffer.
  46153. */
  46154. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46155. /**
  46156. * Add the required samplers to the current list.
  46157. * @param samplers defines the current sampler list.
  46158. */
  46159. static AddSamplers(samplers: string[]): void;
  46160. /**
  46161. * Makes a duplicate of the current configuration into another one.
  46162. * @param anisotropicConfiguration define the config where to copy the info
  46163. */
  46164. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46165. /**
  46166. * Serializes this anisotropy configuration.
  46167. * @returns - An object with the serialized config.
  46168. */
  46169. serialize(): any;
  46170. /**
  46171. * Parses a anisotropy Configuration from a serialized object.
  46172. * @param source - Serialized object.
  46173. * @param scene Defines the scene we are parsing for
  46174. * @param rootUrl Defines the rootUrl to load from
  46175. */
  46176. parse(source: any, scene: Scene, rootUrl: string): void;
  46177. }
  46178. }
  46179. declare module BABYLON {
  46180. /**
  46181. * @hidden
  46182. */
  46183. export interface IMaterialBRDFDefines {
  46184. BRDF_V_HEIGHT_CORRELATED: boolean;
  46185. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46186. SPHERICAL_HARMONICS: boolean;
  46187. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  46188. /** @hidden */ private _areMiscDirty: boolean;
  46189. }
  46190. /**
  46191. * Define the code related to the BRDF parameters of the pbr material.
  46192. */
  46193. export class PBRBRDFConfiguration {
  46194. /**
  46195. * Default value used for the energy conservation.
  46196. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46197. */
  46198. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46199. /**
  46200. * Default value used for the Smith Visibility Height Correlated mode.
  46201. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46202. */
  46203. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46204. /**
  46205. * Default value used for the IBL diffuse part.
  46206. * This can help switching back to the polynomials mode globally which is a tiny bit
  46207. * less GPU intensive at the drawback of a lower quality.
  46208. */
  46209. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46210. /**
  46211. * Default value used for activating energy conservation for the specular workflow.
  46212. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  46213. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  46214. */
  46215. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  46216. private _useEnergyConservation;
  46217. /**
  46218. * Defines if the material uses energy conservation.
  46219. */
  46220. useEnergyConservation: boolean;
  46221. private _useSmithVisibilityHeightCorrelated;
  46222. /**
  46223. * LEGACY Mode set to false
  46224. * Defines if the material uses height smith correlated visibility term.
  46225. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46226. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46227. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46228. * Not relying on height correlated will also disable energy conservation.
  46229. */
  46230. useSmithVisibilityHeightCorrelated: boolean;
  46231. private _useSphericalHarmonics;
  46232. /**
  46233. * LEGACY Mode set to false
  46234. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46235. * diffuse part of the IBL.
  46236. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46237. * to the ground truth.
  46238. */
  46239. useSphericalHarmonics: boolean;
  46240. private _useSpecularGlossinessInputEnergyConservation;
  46241. /**
  46242. * Defines if the material uses energy conservation, when the specular workflow is active.
  46243. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  46244. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  46245. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  46246. */
  46247. useSpecularGlossinessInputEnergyConservation: boolean;
  46248. /** @hidden */
  46249. private _internalMarkAllSubMeshesAsMiscDirty;
  46250. /** @hidden */ private _markAllSubMeshesAsMiscDirty(): void;
  46251. /**
  46252. * Instantiate a new istance of clear coat configuration.
  46253. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46254. */
  46255. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46256. /**
  46257. * Checks to see if a texture is used in the material.
  46258. * @param defines the list of "defines" to update.
  46259. */
  46260. prepareDefines(defines: IMaterialBRDFDefines): void;
  46261. /**
  46262. * Get the current class name of the texture useful for serialization or dynamic coding.
  46263. * @returns "PBRClearCoatConfiguration"
  46264. */
  46265. getClassName(): string;
  46266. /**
  46267. * Makes a duplicate of the current configuration into another one.
  46268. * @param brdfConfiguration define the config where to copy the info
  46269. */
  46270. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46271. /**
  46272. * Serializes this BRDF configuration.
  46273. * @returns - An object with the serialized config.
  46274. */
  46275. serialize(): any;
  46276. /**
  46277. * Parses a anisotropy Configuration from a serialized object.
  46278. * @param source - Serialized object.
  46279. * @param scene Defines the scene we are parsing for
  46280. * @param rootUrl Defines the rootUrl to load from
  46281. */
  46282. parse(source: any, scene: Scene, rootUrl: string): void;
  46283. }
  46284. }
  46285. declare module BABYLON {
  46286. /**
  46287. * @hidden
  46288. */
  46289. export interface IMaterialSheenDefines {
  46290. SHEEN: boolean;
  46291. SHEEN_TEXTURE: boolean;
  46292. SHEEN_TEXTUREDIRECTUV: number;
  46293. SHEEN_LINKWITHALBEDO: boolean;
  46294. /** @hidden */ private _areTexturesDirty: boolean;
  46295. }
  46296. /**
  46297. * Define the code related to the Sheen parameters of the pbr material.
  46298. */
  46299. export class PBRSheenConfiguration {
  46300. private _isEnabled;
  46301. /**
  46302. * Defines if the material uses sheen.
  46303. */
  46304. isEnabled: boolean;
  46305. private _linkSheenWithAlbedo;
  46306. /**
  46307. * Defines if the sheen is linked to the sheen color.
  46308. */
  46309. linkSheenWithAlbedo: boolean;
  46310. /**
  46311. * Defines the sheen intensity.
  46312. */
  46313. intensity: number;
  46314. /**
  46315. * Defines the sheen color.
  46316. */
  46317. color: Color3;
  46318. private _texture;
  46319. /**
  46320. * Stores the sheen tint values in a texture.
  46321. * rgb is tint
  46322. * a is a intensity
  46323. */
  46324. texture: Nullable<BaseTexture>;
  46325. /** @hidden */
  46326. private _internalMarkAllSubMeshesAsTexturesDirty;
  46327. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  46328. /**
  46329. * Instantiate a new istance of clear coat configuration.
  46330. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46331. */
  46332. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46333. /**
  46334. * Specifies that the submesh is ready to be used.
  46335. * @param defines the list of "defines" to update.
  46336. * @param scene defines the scene the material belongs to.
  46337. * @returns - boolean indicating that the submesh is ready or not.
  46338. */
  46339. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46340. /**
  46341. * Checks to see if a texture is used in the material.
  46342. * @param defines the list of "defines" to update.
  46343. * @param scene defines the scene the material belongs to.
  46344. */
  46345. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46346. /**
  46347. * Binds the material data.
  46348. * @param uniformBuffer defines the Uniform buffer to fill in.
  46349. * @param scene defines the scene the material belongs to.
  46350. * @param isFrozen defines wether the material is frozen or not.
  46351. */
  46352. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46353. /**
  46354. * Checks to see if a texture is used in the material.
  46355. * @param texture - Base texture to use.
  46356. * @returns - Boolean specifying if a texture is used in the material.
  46357. */
  46358. hasTexture(texture: BaseTexture): boolean;
  46359. /**
  46360. * Returns an array of the actively used textures.
  46361. * @param activeTextures Array of BaseTextures
  46362. */
  46363. getActiveTextures(activeTextures: BaseTexture[]): void;
  46364. /**
  46365. * Returns the animatable textures.
  46366. * @param animatables Array of animatable textures.
  46367. */
  46368. getAnimatables(animatables: IAnimatable[]): void;
  46369. /**
  46370. * Disposes the resources of the material.
  46371. * @param forceDisposeTextures - Forces the disposal of all textures.
  46372. */
  46373. dispose(forceDisposeTextures?: boolean): void;
  46374. /**
  46375. * Get the current class name of the texture useful for serialization or dynamic coding.
  46376. * @returns "PBRSheenConfiguration"
  46377. */
  46378. getClassName(): string;
  46379. /**
  46380. * Add fallbacks to the effect fallbacks list.
  46381. * @param defines defines the Base texture to use.
  46382. * @param fallbacks defines the current fallback list.
  46383. * @param currentRank defines the current fallback rank.
  46384. * @returns the new fallback rank.
  46385. */
  46386. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46387. /**
  46388. * Add the required uniforms to the current list.
  46389. * @param uniforms defines the current uniform list.
  46390. */
  46391. static AddUniforms(uniforms: string[]): void;
  46392. /**
  46393. * Add the required uniforms to the current buffer.
  46394. * @param uniformBuffer defines the current uniform buffer.
  46395. */
  46396. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46397. /**
  46398. * Add the required samplers to the current list.
  46399. * @param samplers defines the current sampler list.
  46400. */
  46401. static AddSamplers(samplers: string[]): void;
  46402. /**
  46403. * Makes a duplicate of the current configuration into another one.
  46404. * @param sheenConfiguration define the config where to copy the info
  46405. */
  46406. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46407. /**
  46408. * Serializes this BRDF configuration.
  46409. * @returns - An object with the serialized config.
  46410. */
  46411. serialize(): any;
  46412. /**
  46413. * Parses a anisotropy Configuration from a serialized object.
  46414. * @param source - Serialized object.
  46415. * @param scene Defines the scene we are parsing for
  46416. * @param rootUrl Defines the rootUrl to load from
  46417. */
  46418. parse(source: any, scene: Scene, rootUrl: string): void;
  46419. }
  46420. }
  46421. declare module BABYLON {
  46422. /**
  46423. * @hidden
  46424. */
  46425. export interface IMaterialSubSurfaceDefines {
  46426. SUBSURFACE: boolean;
  46427. SS_REFRACTION: boolean;
  46428. SS_TRANSLUCENCY: boolean;
  46429. SS_SCATERRING: boolean;
  46430. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46431. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46432. SS_REFRACTIONMAP_3D: boolean;
  46433. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46434. SS_LODINREFRACTIONALPHA: boolean;
  46435. SS_GAMMAREFRACTION: boolean;
  46436. SS_RGBDREFRACTION: boolean;
  46437. SS_LINEARSPECULARREFRACTION: boolean;
  46438. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46439. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46440. /** @hidden */ private _areTexturesDirty: boolean;
  46441. }
  46442. /**
  46443. * Define the code related to the sub surface parameters of the pbr material.
  46444. */
  46445. export class PBRSubSurfaceConfiguration {
  46446. private _isRefractionEnabled;
  46447. /**
  46448. * Defines if the refraction is enabled in the material.
  46449. */
  46450. isRefractionEnabled: boolean;
  46451. private _isTranslucencyEnabled;
  46452. /**
  46453. * Defines if the translucency is enabled in the material.
  46454. */
  46455. isTranslucencyEnabled: boolean;
  46456. private _isScatteringEnabled;
  46457. /**
  46458. * Defines the refraction intensity of the material.
  46459. * The refraction when enabled replaces the Diffuse part of the material.
  46460. * The intensity helps transitionning between diffuse and refraction.
  46461. */
  46462. refractionIntensity: number;
  46463. /**
  46464. * Defines the translucency intensity of the material.
  46465. * When translucency has been enabled, this defines how much of the "translucency"
  46466. * is addded to the diffuse part of the material.
  46467. */
  46468. translucencyIntensity: number;
  46469. /**
  46470. * Defines the scattering intensity of the material.
  46471. * When scattering has been enabled, this defines how much of the "scattered light"
  46472. * is addded to the diffuse part of the material.
  46473. */
  46474. scatteringIntensity: number;
  46475. private _thicknessTexture;
  46476. /**
  46477. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46478. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46479. * 0 would mean minimumThickness
  46480. * 1 would mean maximumThickness
  46481. * The other channels might be use as a mask to vary the different effects intensity.
  46482. */
  46483. thicknessTexture: Nullable<BaseTexture>;
  46484. private _refractionTexture;
  46485. /**
  46486. * Defines the texture to use for refraction.
  46487. */
  46488. refractionTexture: Nullable<BaseTexture>;
  46489. private _indexOfRefraction;
  46490. /**
  46491. * Defines the index of refraction used in the material.
  46492. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46493. */
  46494. indexOfRefraction: number;
  46495. private _invertRefractionY;
  46496. /**
  46497. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46498. */
  46499. invertRefractionY: boolean;
  46500. private _linkRefractionWithTransparency;
  46501. /**
  46502. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46503. * Materials half opaque for instance using refraction could benefit from this control.
  46504. */
  46505. linkRefractionWithTransparency: boolean;
  46506. /**
  46507. * Defines the minimum thickness stored in the thickness map.
  46508. * If no thickness map is defined, this value will be used to simulate thickness.
  46509. */
  46510. minimumThickness: number;
  46511. /**
  46512. * Defines the maximum thickness stored in the thickness map.
  46513. */
  46514. maximumThickness: number;
  46515. /**
  46516. * Defines the volume tint of the material.
  46517. * This is used for both translucency and scattering.
  46518. */
  46519. tintColor: Color3;
  46520. /**
  46521. * Defines the distance at which the tint color should be found in the media.
  46522. * This is used for refraction only.
  46523. */
  46524. tintColorAtDistance: number;
  46525. /**
  46526. * Defines how far each channel transmit through the media.
  46527. * It is defined as a color to simplify it selection.
  46528. */
  46529. diffusionDistance: Color3;
  46530. private _useMaskFromThicknessTexture;
  46531. /**
  46532. * Stores the intensity of the different subsurface effects in the thickness texture.
  46533. * * the green channel is the translucency intensity.
  46534. * * the blue channel is the scattering intensity.
  46535. * * the alpha channel is the refraction intensity.
  46536. */
  46537. useMaskFromThicknessTexture: boolean;
  46538. /** @hidden */
  46539. private _internalMarkAllSubMeshesAsTexturesDirty;
  46540. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  46541. /**
  46542. * Instantiate a new istance of sub surface configuration.
  46543. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46544. */
  46545. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46546. /**
  46547. * Gets wehter the submesh is ready to be used or not.
  46548. * @param defines the list of "defines" to update.
  46549. * @param scene defines the scene the material belongs to.
  46550. * @returns - boolean indicating that the submesh is ready or not.
  46551. */
  46552. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46553. /**
  46554. * Checks to see if a texture is used in the material.
  46555. * @param defines the list of "defines" to update.
  46556. * @param scene defines the scene to the material belongs to.
  46557. */
  46558. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46559. /**
  46560. * Binds the material data.
  46561. * @param uniformBuffer defines the Uniform buffer to fill in.
  46562. * @param scene defines the scene the material belongs to.
  46563. * @param engine defines the engine the material belongs to.
  46564. * @param isFrozen defines wether the material is frozen or not.
  46565. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46566. */
  46567. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46568. /**
  46569. * Unbinds the material from the mesh.
  46570. * @param activeEffect defines the effect that should be unbound from.
  46571. * @returns true if unbound, otherwise false
  46572. */
  46573. unbind(activeEffect: Effect): boolean;
  46574. /**
  46575. * Returns the texture used for refraction or null if none is used.
  46576. * @param scene defines the scene the material belongs to.
  46577. * @returns - Refraction texture if present. If no refraction texture and refraction
  46578. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46579. */
  46580. private _getRefractionTexture;
  46581. /**
  46582. * Returns true if alpha blending should be disabled.
  46583. */
  46584. readonly disableAlphaBlending: boolean;
  46585. /**
  46586. * Fills the list of render target textures.
  46587. * @param renderTargets the list of render targets to update
  46588. */
  46589. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46590. /**
  46591. * Checks to see if a texture is used in the material.
  46592. * @param texture - Base texture to use.
  46593. * @returns - Boolean specifying if a texture is used in the material.
  46594. */
  46595. hasTexture(texture: BaseTexture): boolean;
  46596. /**
  46597. * Gets a boolean indicating that current material needs to register RTT
  46598. * @returns true if this uses a render target otherwise false.
  46599. */
  46600. hasRenderTargetTextures(): boolean;
  46601. /**
  46602. * Returns an array of the actively used textures.
  46603. * @param activeTextures Array of BaseTextures
  46604. */
  46605. getActiveTextures(activeTextures: BaseTexture[]): void;
  46606. /**
  46607. * Returns the animatable textures.
  46608. * @param animatables Array of animatable textures.
  46609. */
  46610. getAnimatables(animatables: IAnimatable[]): void;
  46611. /**
  46612. * Disposes the resources of the material.
  46613. * @param forceDisposeTextures - Forces the disposal of all textures.
  46614. */
  46615. dispose(forceDisposeTextures?: boolean): void;
  46616. /**
  46617. * Get the current class name of the texture useful for serialization or dynamic coding.
  46618. * @returns "PBRSubSurfaceConfiguration"
  46619. */
  46620. getClassName(): string;
  46621. /**
  46622. * Add fallbacks to the effect fallbacks list.
  46623. * @param defines defines the Base texture to use.
  46624. * @param fallbacks defines the current fallback list.
  46625. * @param currentRank defines the current fallback rank.
  46626. * @returns the new fallback rank.
  46627. */
  46628. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46629. /**
  46630. * Add the required uniforms to the current list.
  46631. * @param uniforms defines the current uniform list.
  46632. */
  46633. static AddUniforms(uniforms: string[]): void;
  46634. /**
  46635. * Add the required samplers to the current list.
  46636. * @param samplers defines the current sampler list.
  46637. */
  46638. static AddSamplers(samplers: string[]): void;
  46639. /**
  46640. * Add the required uniforms to the current buffer.
  46641. * @param uniformBuffer defines the current uniform buffer.
  46642. */
  46643. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46644. /**
  46645. * Makes a duplicate of the current configuration into another one.
  46646. * @param configuration define the config where to copy the info
  46647. */
  46648. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46649. /**
  46650. * Serializes this Sub Surface configuration.
  46651. * @returns - An object with the serialized config.
  46652. */
  46653. serialize(): any;
  46654. /**
  46655. * Parses a anisotropy Configuration from a serialized object.
  46656. * @param source - Serialized object.
  46657. * @param scene Defines the scene we are parsing for
  46658. * @param rootUrl Defines the rootUrl to load from
  46659. */
  46660. parse(source: any, scene: Scene, rootUrl: string): void;
  46661. }
  46662. }
  46663. declare module BABYLON {
  46664. /** @hidden */
  46665. export var pbrFragmentDeclaration: {
  46666. name: string;
  46667. shader: string;
  46668. };
  46669. }
  46670. declare module BABYLON {
  46671. /** @hidden */
  46672. export var pbrUboDeclaration: {
  46673. name: string;
  46674. shader: string;
  46675. };
  46676. }
  46677. declare module BABYLON {
  46678. /** @hidden */
  46679. export var pbrFragmentExtraDeclaration: {
  46680. name: string;
  46681. shader: string;
  46682. };
  46683. }
  46684. declare module BABYLON {
  46685. /** @hidden */
  46686. export var pbrFragmentSamplersDeclaration: {
  46687. name: string;
  46688. shader: string;
  46689. };
  46690. }
  46691. declare module BABYLON {
  46692. /** @hidden */
  46693. export var pbrHelperFunctions: {
  46694. name: string;
  46695. shader: string;
  46696. };
  46697. }
  46698. declare module BABYLON {
  46699. /** @hidden */
  46700. export var harmonicsFunctions: {
  46701. name: string;
  46702. shader: string;
  46703. };
  46704. }
  46705. declare module BABYLON {
  46706. /** @hidden */
  46707. export var pbrDirectLightingSetupFunctions: {
  46708. name: string;
  46709. shader: string;
  46710. };
  46711. }
  46712. declare module BABYLON {
  46713. /** @hidden */
  46714. export var pbrDirectLightingFalloffFunctions: {
  46715. name: string;
  46716. shader: string;
  46717. };
  46718. }
  46719. declare module BABYLON {
  46720. /** @hidden */
  46721. export var pbrBRDFFunctions: {
  46722. name: string;
  46723. shader: string;
  46724. };
  46725. }
  46726. declare module BABYLON {
  46727. /** @hidden */
  46728. export var pbrDirectLightingFunctions: {
  46729. name: string;
  46730. shader: string;
  46731. };
  46732. }
  46733. declare module BABYLON {
  46734. /** @hidden */
  46735. export var pbrIBLFunctions: {
  46736. name: string;
  46737. shader: string;
  46738. };
  46739. }
  46740. declare module BABYLON {
  46741. /** @hidden */
  46742. export var pbrDebug: {
  46743. name: string;
  46744. shader: string;
  46745. };
  46746. }
  46747. declare module BABYLON {
  46748. /** @hidden */
  46749. export var pbrPixelShader: {
  46750. name: string;
  46751. shader: string;
  46752. };
  46753. }
  46754. declare module BABYLON {
  46755. /** @hidden */
  46756. export var pbrVertexDeclaration: {
  46757. name: string;
  46758. shader: string;
  46759. };
  46760. }
  46761. declare module BABYLON {
  46762. /** @hidden */
  46763. export var pbrVertexShader: {
  46764. name: string;
  46765. shader: string;
  46766. };
  46767. }
  46768. declare module BABYLON {
  46769. /**
  46770. * Manages the defines for the PBR Material.
  46771. * @hidden
  46772. */
  46773. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46774. PBR: boolean;
  46775. MAINUV1: boolean;
  46776. MAINUV2: boolean;
  46777. UV1: boolean;
  46778. UV2: boolean;
  46779. ALBEDO: boolean;
  46780. ALBEDODIRECTUV: number;
  46781. VERTEXCOLOR: boolean;
  46782. AMBIENT: boolean;
  46783. AMBIENTDIRECTUV: number;
  46784. AMBIENTINGRAYSCALE: boolean;
  46785. OPACITY: boolean;
  46786. VERTEXALPHA: boolean;
  46787. OPACITYDIRECTUV: number;
  46788. OPACITYRGB: boolean;
  46789. ALPHATEST: boolean;
  46790. DEPTHPREPASS: boolean;
  46791. ALPHABLEND: boolean;
  46792. ALPHAFROMALBEDO: boolean;
  46793. ALPHATESTVALUE: string;
  46794. SPECULAROVERALPHA: boolean;
  46795. RADIANCEOVERALPHA: boolean;
  46796. ALPHAFRESNEL: boolean;
  46797. LINEARALPHAFRESNEL: boolean;
  46798. PREMULTIPLYALPHA: boolean;
  46799. EMISSIVE: boolean;
  46800. EMISSIVEDIRECTUV: number;
  46801. REFLECTIVITY: boolean;
  46802. REFLECTIVITYDIRECTUV: number;
  46803. SPECULARTERM: boolean;
  46804. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46805. MICROSURFACEAUTOMATIC: boolean;
  46806. LODBASEDMICROSFURACE: boolean;
  46807. MICROSURFACEMAP: boolean;
  46808. MICROSURFACEMAPDIRECTUV: number;
  46809. METALLICWORKFLOW: boolean;
  46810. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46811. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46812. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46813. AOSTOREINMETALMAPRED: boolean;
  46814. ENVIRONMENTBRDF: boolean;
  46815. ENVIRONMENTBRDF_RGBD: boolean;
  46816. NORMAL: boolean;
  46817. TANGENT: boolean;
  46818. BUMP: boolean;
  46819. BUMPDIRECTUV: number;
  46820. OBJECTSPACE_NORMALMAP: boolean;
  46821. PARALLAX: boolean;
  46822. PARALLAXOCCLUSION: boolean;
  46823. NORMALXYSCALE: boolean;
  46824. LIGHTMAP: boolean;
  46825. LIGHTMAPDIRECTUV: number;
  46826. USELIGHTMAPASSHADOWMAP: boolean;
  46827. GAMMALIGHTMAP: boolean;
  46828. RGBDLIGHTMAP: boolean;
  46829. REFLECTION: boolean;
  46830. REFLECTIONMAP_3D: boolean;
  46831. REFLECTIONMAP_SPHERICAL: boolean;
  46832. REFLECTIONMAP_PLANAR: boolean;
  46833. REFLECTIONMAP_CUBIC: boolean;
  46834. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46835. REFLECTIONMAP_PROJECTION: boolean;
  46836. REFLECTIONMAP_SKYBOX: boolean;
  46837. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46838. REFLECTIONMAP_EXPLICIT: boolean;
  46839. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46840. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46841. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46842. INVERTCUBICMAP: boolean;
  46843. USESPHERICALFROMREFLECTIONMAP: boolean;
  46844. USEIRRADIANCEMAP: boolean;
  46845. SPHERICAL_HARMONICS: boolean;
  46846. USESPHERICALINVERTEX: boolean;
  46847. REFLECTIONMAP_OPPOSITEZ: boolean;
  46848. LODINREFLECTIONALPHA: boolean;
  46849. GAMMAREFLECTION: boolean;
  46850. RGBDREFLECTION: boolean;
  46851. LINEARSPECULARREFLECTION: boolean;
  46852. RADIANCEOCCLUSION: boolean;
  46853. HORIZONOCCLUSION: boolean;
  46854. INSTANCES: boolean;
  46855. NUM_BONE_INFLUENCERS: number;
  46856. BonesPerMesh: number;
  46857. BONETEXTURE: boolean;
  46858. NONUNIFORMSCALING: boolean;
  46859. MORPHTARGETS: boolean;
  46860. MORPHTARGETS_NORMAL: boolean;
  46861. MORPHTARGETS_TANGENT: boolean;
  46862. MORPHTARGETS_UV: boolean;
  46863. NUM_MORPH_INFLUENCERS: number;
  46864. IMAGEPROCESSING: boolean;
  46865. VIGNETTE: boolean;
  46866. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46867. VIGNETTEBLENDMODEOPAQUE: boolean;
  46868. TONEMAPPING: boolean;
  46869. TONEMAPPING_ACES: boolean;
  46870. CONTRAST: boolean;
  46871. COLORCURVES: boolean;
  46872. COLORGRADING: boolean;
  46873. COLORGRADING3D: boolean;
  46874. SAMPLER3DGREENDEPTH: boolean;
  46875. SAMPLER3DBGRMAP: boolean;
  46876. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46877. EXPOSURE: boolean;
  46878. MULTIVIEW: boolean;
  46879. USEPHYSICALLIGHTFALLOFF: boolean;
  46880. USEGLTFLIGHTFALLOFF: boolean;
  46881. TWOSIDEDLIGHTING: boolean;
  46882. SHADOWFLOAT: boolean;
  46883. CLIPPLANE: boolean;
  46884. CLIPPLANE2: boolean;
  46885. CLIPPLANE3: boolean;
  46886. CLIPPLANE4: boolean;
  46887. POINTSIZE: boolean;
  46888. FOG: boolean;
  46889. LOGARITHMICDEPTH: boolean;
  46890. FORCENORMALFORWARD: boolean;
  46891. SPECULARAA: boolean;
  46892. CLEARCOAT: boolean;
  46893. CLEARCOAT_DEFAULTIOR: boolean;
  46894. CLEARCOAT_TEXTURE: boolean;
  46895. CLEARCOAT_TEXTUREDIRECTUV: number;
  46896. CLEARCOAT_BUMP: boolean;
  46897. CLEARCOAT_BUMPDIRECTUV: number;
  46898. CLEARCOAT_TINT: boolean;
  46899. CLEARCOAT_TINT_TEXTURE: boolean;
  46900. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46901. ANISOTROPIC: boolean;
  46902. ANISOTROPIC_TEXTURE: boolean;
  46903. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46904. BRDF_V_HEIGHT_CORRELATED: boolean;
  46905. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46906. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  46907. SHEEN: boolean;
  46908. SHEEN_TEXTURE: boolean;
  46909. SHEEN_TEXTUREDIRECTUV: number;
  46910. SHEEN_LINKWITHALBEDO: boolean;
  46911. SUBSURFACE: boolean;
  46912. SS_REFRACTION: boolean;
  46913. SS_TRANSLUCENCY: boolean;
  46914. SS_SCATERRING: boolean;
  46915. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46916. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46917. SS_REFRACTIONMAP_3D: boolean;
  46918. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46919. SS_LODINREFRACTIONALPHA: boolean;
  46920. SS_GAMMAREFRACTION: boolean;
  46921. SS_RGBDREFRACTION: boolean;
  46922. SS_LINEARSPECULARREFRACTION: boolean;
  46923. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46924. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46925. UNLIT: boolean;
  46926. DEBUGMODE: number;
  46927. /**
  46928. * Initializes the PBR Material defines.
  46929. */
  46930. constructor();
  46931. /**
  46932. * Resets the PBR Material defines.
  46933. */
  46934. reset(): void;
  46935. }
  46936. /**
  46937. * The Physically based material base class of BJS.
  46938. *
  46939. * This offers the main features of a standard PBR material.
  46940. * For more information, please refer to the documentation :
  46941. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46942. */
  46943. export abstract class PBRBaseMaterial extends PushMaterial {
  46944. /**
  46945. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46946. */
  46947. static readonly PBRMATERIAL_OPAQUE: number;
  46948. /**
  46949. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46950. */
  46951. static readonly PBRMATERIAL_ALPHATEST: number;
  46952. /**
  46953. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46954. */
  46955. static readonly PBRMATERIAL_ALPHABLEND: number;
  46956. /**
  46957. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46958. * They are also discarded below the alpha cutoff threshold to improve performances.
  46959. */
  46960. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46961. /**
  46962. * Defines the default value of how much AO map is occluding the analytical lights
  46963. * (point spot...).
  46964. */
  46965. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46966. /**
  46967. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46968. */
  46969. static readonly LIGHTFALLOFF_PHYSICAL: number;
  46970. /**
  46971. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  46972. * to enhance interoperability with other engines.
  46973. */
  46974. static readonly LIGHTFALLOFF_GLTF: number;
  46975. /**
  46976. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  46977. * to enhance interoperability with other materials.
  46978. */
  46979. static readonly LIGHTFALLOFF_STANDARD: number;
  46980. /**
  46981. * Intensity of the direct lights e.g. the four lights available in your scene.
  46982. * This impacts both the direct diffuse and specular highlights.
  46983. */
  46984. protected _directIntensity: number;
  46985. /**
  46986. * Intensity of the emissive part of the material.
  46987. * This helps controlling the emissive effect without modifying the emissive color.
  46988. */
  46989. protected _emissiveIntensity: number;
  46990. /**
  46991. * Intensity of the environment e.g. how much the environment will light the object
  46992. * either through harmonics for rough material or through the refelction for shiny ones.
  46993. */
  46994. protected _environmentIntensity: number;
  46995. /**
  46996. * This is a special control allowing the reduction of the specular highlights coming from the
  46997. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46998. */
  46999. protected _specularIntensity: number;
  47000. /**
  47001. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47002. */
  47003. private _lightingInfos;
  47004. /**
  47005. * Debug Control allowing disabling the bump map on this material.
  47006. */
  47007. protected _disableBumpMap: boolean;
  47008. /**
  47009. * AKA Diffuse Texture in standard nomenclature.
  47010. */
  47011. protected _albedoTexture: Nullable<BaseTexture>;
  47012. /**
  47013. * AKA Occlusion Texture in other nomenclature.
  47014. */
  47015. protected _ambientTexture: Nullable<BaseTexture>;
  47016. /**
  47017. * AKA Occlusion Texture Intensity in other nomenclature.
  47018. */
  47019. protected _ambientTextureStrength: number;
  47020. /**
  47021. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47022. * 1 means it completely occludes it
  47023. * 0 mean it has no impact
  47024. */
  47025. protected _ambientTextureImpactOnAnalyticalLights: number;
  47026. /**
  47027. * Stores the alpha values in a texture.
  47028. */
  47029. protected _opacityTexture: Nullable<BaseTexture>;
  47030. /**
  47031. * Stores the reflection values in a texture.
  47032. */
  47033. protected _reflectionTexture: Nullable<BaseTexture>;
  47034. /**
  47035. * Stores the emissive values in a texture.
  47036. */
  47037. protected _emissiveTexture: Nullable<BaseTexture>;
  47038. /**
  47039. * AKA Specular texture in other nomenclature.
  47040. */
  47041. protected _reflectivityTexture: Nullable<BaseTexture>;
  47042. /**
  47043. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47044. */
  47045. protected _metallicTexture: Nullable<BaseTexture>;
  47046. /**
  47047. * Specifies the metallic scalar of the metallic/roughness workflow.
  47048. * Can also be used to scale the metalness values of the metallic texture.
  47049. */
  47050. protected _metallic: Nullable<number>;
  47051. /**
  47052. * Specifies the roughness scalar of the metallic/roughness workflow.
  47053. * Can also be used to scale the roughness values of the metallic texture.
  47054. */
  47055. protected _roughness: Nullable<number>;
  47056. /**
  47057. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47058. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47059. */
  47060. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47061. /**
  47062. * Stores surface normal data used to displace a mesh in a texture.
  47063. */
  47064. protected _bumpTexture: Nullable<BaseTexture>;
  47065. /**
  47066. * Stores the pre-calculated light information of a mesh in a texture.
  47067. */
  47068. protected _lightmapTexture: Nullable<BaseTexture>;
  47069. /**
  47070. * The color of a material in ambient lighting.
  47071. */
  47072. protected _ambientColor: Color3;
  47073. /**
  47074. * AKA Diffuse Color in other nomenclature.
  47075. */
  47076. protected _albedoColor: Color3;
  47077. /**
  47078. * AKA Specular Color in other nomenclature.
  47079. */
  47080. protected _reflectivityColor: Color3;
  47081. /**
  47082. * The color applied when light is reflected from a material.
  47083. */
  47084. protected _reflectionColor: Color3;
  47085. /**
  47086. * The color applied when light is emitted from a material.
  47087. */
  47088. protected _emissiveColor: Color3;
  47089. /**
  47090. * AKA Glossiness in other nomenclature.
  47091. */
  47092. protected _microSurface: number;
  47093. /**
  47094. * Specifies that the material will use the light map as a show map.
  47095. */
  47096. protected _useLightmapAsShadowmap: boolean;
  47097. /**
  47098. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47099. * makes the reflect vector face the model (under horizon).
  47100. */
  47101. protected _useHorizonOcclusion: boolean;
  47102. /**
  47103. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47104. * too much the area relying on ambient texture to define their ambient occlusion.
  47105. */
  47106. protected _useRadianceOcclusion: boolean;
  47107. /**
  47108. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47109. */
  47110. protected _useAlphaFromAlbedoTexture: boolean;
  47111. /**
  47112. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47113. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47114. */
  47115. protected _useSpecularOverAlpha: boolean;
  47116. /**
  47117. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47118. */
  47119. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47120. /**
  47121. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47122. */
  47123. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47124. /**
  47125. * Specifies if the metallic texture contains the roughness information in its green channel.
  47126. */
  47127. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47128. /**
  47129. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47130. */
  47131. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47132. /**
  47133. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47134. */
  47135. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47136. /**
  47137. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47138. */
  47139. protected _useAmbientInGrayScale: boolean;
  47140. /**
  47141. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47142. * The material will try to infer what glossiness each pixel should be.
  47143. */
  47144. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47145. /**
  47146. * Defines the falloff type used in this material.
  47147. * It by default is Physical.
  47148. */
  47149. protected _lightFalloff: number;
  47150. /**
  47151. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47152. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47153. */
  47154. protected _useRadianceOverAlpha: boolean;
  47155. /**
  47156. * Allows using an object space normal map (instead of tangent space).
  47157. */
  47158. protected _useObjectSpaceNormalMap: boolean;
  47159. /**
  47160. * Allows using the bump map in parallax mode.
  47161. */
  47162. protected _useParallax: boolean;
  47163. /**
  47164. * Allows using the bump map in parallax occlusion mode.
  47165. */
  47166. protected _useParallaxOcclusion: boolean;
  47167. /**
  47168. * Controls the scale bias of the parallax mode.
  47169. */
  47170. protected _parallaxScaleBias: number;
  47171. /**
  47172. * If sets to true, disables all the lights affecting the material.
  47173. */
  47174. protected _disableLighting: boolean;
  47175. /**
  47176. * Number of Simultaneous lights allowed on the material.
  47177. */
  47178. protected _maxSimultaneousLights: number;
  47179. /**
  47180. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47181. */
  47182. protected _invertNormalMapX: boolean;
  47183. /**
  47184. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47185. */
  47186. protected _invertNormalMapY: boolean;
  47187. /**
  47188. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47189. */
  47190. protected _twoSidedLighting: boolean;
  47191. /**
  47192. * Defines the alpha limits in alpha test mode.
  47193. */
  47194. protected _alphaCutOff: number;
  47195. /**
  47196. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47197. */
  47198. protected _forceAlphaTest: boolean;
  47199. /**
  47200. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47201. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47202. */
  47203. protected _useAlphaFresnel: boolean;
  47204. /**
  47205. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47206. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47207. */
  47208. protected _useLinearAlphaFresnel: boolean;
  47209. /**
  47210. * The transparency mode of the material.
  47211. */
  47212. protected _transparencyMode: Nullable<number>;
  47213. /**
  47214. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47215. * from cos thetav and roughness:
  47216. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47217. */
  47218. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47219. /**
  47220. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47221. */
  47222. protected _forceIrradianceInFragment: boolean;
  47223. /**
  47224. * Force normal to face away from face.
  47225. */
  47226. protected _forceNormalForward: boolean;
  47227. /**
  47228. * Enables specular anti aliasing in the PBR shader.
  47229. * It will both interacts on the Geometry for analytical and IBL lighting.
  47230. * It also prefilter the roughness map based on the bump values.
  47231. */
  47232. protected _enableSpecularAntiAliasing: boolean;
  47233. /**
  47234. * Default configuration related to image processing available in the PBR Material.
  47235. */
  47236. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47237. /**
  47238. * Keep track of the image processing observer to allow dispose and replace.
  47239. */
  47240. private _imageProcessingObserver;
  47241. /**
  47242. * Attaches a new image processing configuration to the PBR Material.
  47243. * @param configuration
  47244. */
  47245. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47246. /**
  47247. * Stores the available render targets.
  47248. */
  47249. private _renderTargets;
  47250. /**
  47251. * Sets the global ambient color for the material used in lighting calculations.
  47252. */
  47253. private _globalAmbientColor;
  47254. /**
  47255. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47256. */
  47257. private _useLogarithmicDepth;
  47258. /**
  47259. * If set to true, no lighting calculations will be applied.
  47260. */
  47261. private _unlit;
  47262. private _debugMode;
  47263. /**
  47264. * @hidden
  47265. * This is reserved for the inspector.
  47266. * Defines the material debug mode.
  47267. * It helps seeing only some components of the material while troubleshooting.
  47268. */
  47269. debugMode: number;
  47270. /**
  47271. * @hidden
  47272. * This is reserved for the inspector.
  47273. * Specify from where on screen the debug mode should start.
  47274. * The value goes from -1 (full screen) to 1 (not visible)
  47275. * It helps with side by side comparison against the final render
  47276. * This defaults to -1
  47277. */
  47278. private debugLimit;
  47279. /**
  47280. * @hidden
  47281. * This is reserved for the inspector.
  47282. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47283. * You can use the factor to better multiply the final value.
  47284. */
  47285. private debugFactor;
  47286. /**
  47287. * Defines the clear coat layer parameters for the material.
  47288. */
  47289. readonly clearCoat: PBRClearCoatConfiguration;
  47290. /**
  47291. * Defines the anisotropic parameters for the material.
  47292. */
  47293. readonly anisotropy: PBRAnisotropicConfiguration;
  47294. /**
  47295. * Defines the BRDF parameters for the material.
  47296. */
  47297. readonly brdf: PBRBRDFConfiguration;
  47298. /**
  47299. * Defines the Sheen parameters for the material.
  47300. */
  47301. readonly sheen: PBRSheenConfiguration;
  47302. /**
  47303. * Defines the SubSurface parameters for the material.
  47304. */
  47305. readonly subSurface: PBRSubSurfaceConfiguration;
  47306. /**
  47307. * Custom callback helping to override the default shader used in the material.
  47308. */
  47309. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47310. protected _rebuildInParallel: boolean;
  47311. /**
  47312. * Instantiates a new PBRMaterial instance.
  47313. *
  47314. * @param name The material name
  47315. * @param scene The scene the material will be use in.
  47316. */
  47317. constructor(name: string, scene: Scene);
  47318. /**
  47319. * Gets a boolean indicating that current material needs to register RTT
  47320. */
  47321. readonly hasRenderTargetTextures: boolean;
  47322. /**
  47323. * Gets the name of the material class.
  47324. */
  47325. getClassName(): string;
  47326. /**
  47327. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47328. */
  47329. /**
  47330. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47331. */
  47332. useLogarithmicDepth: boolean;
  47333. /**
  47334. * Gets the current transparency mode.
  47335. */
  47336. /**
  47337. * Sets the transparency mode of the material.
  47338. *
  47339. * | Value | Type | Description |
  47340. * | ----- | ----------------------------------- | ----------- |
  47341. * | 0 | OPAQUE | |
  47342. * | 1 | ALPHATEST | |
  47343. * | 2 | ALPHABLEND | |
  47344. * | 3 | ALPHATESTANDBLEND | |
  47345. *
  47346. */
  47347. transparencyMode: Nullable<number>;
  47348. /**
  47349. * Returns true if alpha blending should be disabled.
  47350. */
  47351. private readonly _disableAlphaBlending;
  47352. /**
  47353. * Specifies whether or not this material should be rendered in alpha blend mode.
  47354. */
  47355. needAlphaBlending(): boolean;
  47356. /**
  47357. * Specifies if the mesh will require alpha blending.
  47358. * @param mesh - BJS mesh.
  47359. */
  47360. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47361. /**
  47362. * Specifies whether or not this material should be rendered in alpha test mode.
  47363. */
  47364. needAlphaTesting(): boolean;
  47365. /**
  47366. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47367. */
  47368. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47369. /**
  47370. * Gets the texture used for the alpha test.
  47371. */
  47372. getAlphaTestTexture(): Nullable<BaseTexture>;
  47373. /**
  47374. * Specifies that the submesh is ready to be used.
  47375. * @param mesh - BJS mesh.
  47376. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47377. * @param useInstances - Specifies that instances should be used.
  47378. * @returns - boolean indicating that the submesh is ready or not.
  47379. */
  47380. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47381. /**
  47382. * Specifies if the material uses metallic roughness workflow.
  47383. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47384. */
  47385. isMetallicWorkflow(): boolean;
  47386. private _prepareEffect;
  47387. private _prepareDefines;
  47388. /**
  47389. * Force shader compilation
  47390. */
  47391. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  47392. /**
  47393. * Initializes the uniform buffer layout for the shader.
  47394. */
  47395. buildUniformLayout(): void;
  47396. /**
  47397. * Unbinds the material from the mesh
  47398. */
  47399. unbind(): void;
  47400. /**
  47401. * Binds the submesh data.
  47402. * @param world - The world matrix.
  47403. * @param mesh - The BJS mesh.
  47404. * @param subMesh - A submesh of the BJS mesh.
  47405. */
  47406. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47407. /**
  47408. * Returns the animatable textures.
  47409. * @returns - Array of animatable textures.
  47410. */
  47411. getAnimatables(): IAnimatable[];
  47412. /**
  47413. * Returns the texture used for reflections.
  47414. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47415. */
  47416. private _getReflectionTexture;
  47417. /**
  47418. * Returns an array of the actively used textures.
  47419. * @returns - Array of BaseTextures
  47420. */
  47421. getActiveTextures(): BaseTexture[];
  47422. /**
  47423. * Checks to see if a texture is used in the material.
  47424. * @param texture - Base texture to use.
  47425. * @returns - Boolean specifying if a texture is used in the material.
  47426. */
  47427. hasTexture(texture: BaseTexture): boolean;
  47428. /**
  47429. * Disposes the resources of the material.
  47430. * @param forceDisposeEffect - Forces the disposal of effects.
  47431. * @param forceDisposeTextures - Forces the disposal of all textures.
  47432. */
  47433. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47434. }
  47435. }
  47436. declare module BABYLON {
  47437. /**
  47438. * The Physically based material of BJS.
  47439. *
  47440. * This offers the main features of a standard PBR material.
  47441. * For more information, please refer to the documentation :
  47442. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47443. */
  47444. export class PBRMaterial extends PBRBaseMaterial {
  47445. /**
  47446. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47447. */
  47448. static readonly PBRMATERIAL_OPAQUE: number;
  47449. /**
  47450. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47451. */
  47452. static readonly PBRMATERIAL_ALPHATEST: number;
  47453. /**
  47454. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47455. */
  47456. static readonly PBRMATERIAL_ALPHABLEND: number;
  47457. /**
  47458. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47459. * They are also discarded below the alpha cutoff threshold to improve performances.
  47460. */
  47461. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47462. /**
  47463. * Defines the default value of how much AO map is occluding the analytical lights
  47464. * (point spot...).
  47465. */
  47466. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47467. /**
  47468. * Intensity of the direct lights e.g. the four lights available in your scene.
  47469. * This impacts both the direct diffuse and specular highlights.
  47470. */
  47471. directIntensity: number;
  47472. /**
  47473. * Intensity of the emissive part of the material.
  47474. * This helps controlling the emissive effect without modifying the emissive color.
  47475. */
  47476. emissiveIntensity: number;
  47477. /**
  47478. * Intensity of the environment e.g. how much the environment will light the object
  47479. * either through harmonics for rough material or through the refelction for shiny ones.
  47480. */
  47481. environmentIntensity: number;
  47482. /**
  47483. * This is a special control allowing the reduction of the specular highlights coming from the
  47484. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47485. */
  47486. specularIntensity: number;
  47487. /**
  47488. * Debug Control allowing disabling the bump map on this material.
  47489. */
  47490. disableBumpMap: boolean;
  47491. /**
  47492. * AKA Diffuse Texture in standard nomenclature.
  47493. */
  47494. albedoTexture: BaseTexture;
  47495. /**
  47496. * AKA Occlusion Texture in other nomenclature.
  47497. */
  47498. ambientTexture: BaseTexture;
  47499. /**
  47500. * AKA Occlusion Texture Intensity in other nomenclature.
  47501. */
  47502. ambientTextureStrength: number;
  47503. /**
  47504. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47505. * 1 means it completely occludes it
  47506. * 0 mean it has no impact
  47507. */
  47508. ambientTextureImpactOnAnalyticalLights: number;
  47509. /**
  47510. * Stores the alpha values in a texture.
  47511. */
  47512. opacityTexture: BaseTexture;
  47513. /**
  47514. * Stores the reflection values in a texture.
  47515. */
  47516. reflectionTexture: Nullable<BaseTexture>;
  47517. /**
  47518. * Stores the emissive values in a texture.
  47519. */
  47520. emissiveTexture: BaseTexture;
  47521. /**
  47522. * AKA Specular texture in other nomenclature.
  47523. */
  47524. reflectivityTexture: BaseTexture;
  47525. /**
  47526. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47527. */
  47528. metallicTexture: BaseTexture;
  47529. /**
  47530. * Specifies the metallic scalar of the metallic/roughness workflow.
  47531. * Can also be used to scale the metalness values of the metallic texture.
  47532. */
  47533. metallic: Nullable<number>;
  47534. /**
  47535. * Specifies the roughness scalar of the metallic/roughness workflow.
  47536. * Can also be used to scale the roughness values of the metallic texture.
  47537. */
  47538. roughness: Nullable<number>;
  47539. /**
  47540. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47541. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47542. */
  47543. microSurfaceTexture: BaseTexture;
  47544. /**
  47545. * Stores surface normal data used to displace a mesh in a texture.
  47546. */
  47547. bumpTexture: BaseTexture;
  47548. /**
  47549. * Stores the pre-calculated light information of a mesh in a texture.
  47550. */
  47551. lightmapTexture: BaseTexture;
  47552. /**
  47553. * Stores the refracted light information in a texture.
  47554. */
  47555. refractionTexture: Nullable<BaseTexture>;
  47556. /**
  47557. * The color of a material in ambient lighting.
  47558. */
  47559. ambientColor: Color3;
  47560. /**
  47561. * AKA Diffuse Color in other nomenclature.
  47562. */
  47563. albedoColor: Color3;
  47564. /**
  47565. * AKA Specular Color in other nomenclature.
  47566. */
  47567. reflectivityColor: Color3;
  47568. /**
  47569. * The color reflected from the material.
  47570. */
  47571. reflectionColor: Color3;
  47572. /**
  47573. * The color emitted from the material.
  47574. */
  47575. emissiveColor: Color3;
  47576. /**
  47577. * AKA Glossiness in other nomenclature.
  47578. */
  47579. microSurface: number;
  47580. /**
  47581. * source material index of refraction (IOR)' / 'destination material IOR.
  47582. */
  47583. indexOfRefraction: number;
  47584. /**
  47585. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47586. */
  47587. invertRefractionY: boolean;
  47588. /**
  47589. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47590. * Materials half opaque for instance using refraction could benefit from this control.
  47591. */
  47592. linkRefractionWithTransparency: boolean;
  47593. /**
  47594. * If true, the light map contains occlusion information instead of lighting info.
  47595. */
  47596. useLightmapAsShadowmap: boolean;
  47597. /**
  47598. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47599. */
  47600. useAlphaFromAlbedoTexture: boolean;
  47601. /**
  47602. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47603. */
  47604. forceAlphaTest: boolean;
  47605. /**
  47606. * Defines the alpha limits in alpha test mode.
  47607. */
  47608. alphaCutOff: number;
  47609. /**
  47610. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47611. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47612. */
  47613. useSpecularOverAlpha: boolean;
  47614. /**
  47615. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47616. */
  47617. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47618. /**
  47619. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47620. */
  47621. useRoughnessFromMetallicTextureAlpha: boolean;
  47622. /**
  47623. * Specifies if the metallic texture contains the roughness information in its green channel.
  47624. */
  47625. useRoughnessFromMetallicTextureGreen: boolean;
  47626. /**
  47627. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47628. */
  47629. useMetallnessFromMetallicTextureBlue: boolean;
  47630. /**
  47631. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47632. */
  47633. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47634. /**
  47635. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47636. */
  47637. useAmbientInGrayScale: boolean;
  47638. /**
  47639. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47640. * The material will try to infer what glossiness each pixel should be.
  47641. */
  47642. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47643. /**
  47644. * BJS is using an harcoded light falloff based on a manually sets up range.
  47645. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47646. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47647. */
  47648. /**
  47649. * BJS is using an harcoded light falloff based on a manually sets up range.
  47650. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47651. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47652. */
  47653. usePhysicalLightFalloff: boolean;
  47654. /**
  47655. * In order to support the falloff compatibility with gltf, a special mode has been added
  47656. * to reproduce the gltf light falloff.
  47657. */
  47658. /**
  47659. * In order to support the falloff compatibility with gltf, a special mode has been added
  47660. * to reproduce the gltf light falloff.
  47661. */
  47662. useGLTFLightFalloff: boolean;
  47663. /**
  47664. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47665. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47666. */
  47667. useRadianceOverAlpha: boolean;
  47668. /**
  47669. * Allows using an object space normal map (instead of tangent space).
  47670. */
  47671. useObjectSpaceNormalMap: boolean;
  47672. /**
  47673. * Allows using the bump map in parallax mode.
  47674. */
  47675. useParallax: boolean;
  47676. /**
  47677. * Allows using the bump map in parallax occlusion mode.
  47678. */
  47679. useParallaxOcclusion: boolean;
  47680. /**
  47681. * Controls the scale bias of the parallax mode.
  47682. */
  47683. parallaxScaleBias: number;
  47684. /**
  47685. * If sets to true, disables all the lights affecting the material.
  47686. */
  47687. disableLighting: boolean;
  47688. /**
  47689. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47690. */
  47691. forceIrradianceInFragment: boolean;
  47692. /**
  47693. * Number of Simultaneous lights allowed on the material.
  47694. */
  47695. maxSimultaneousLights: number;
  47696. /**
  47697. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47698. */
  47699. invertNormalMapX: boolean;
  47700. /**
  47701. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47702. */
  47703. invertNormalMapY: boolean;
  47704. /**
  47705. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47706. */
  47707. twoSidedLighting: boolean;
  47708. /**
  47709. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47710. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47711. */
  47712. useAlphaFresnel: boolean;
  47713. /**
  47714. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47715. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47716. */
  47717. useLinearAlphaFresnel: boolean;
  47718. /**
  47719. * Let user defines the brdf lookup texture used for IBL.
  47720. * A default 8bit version is embedded but you could point at :
  47721. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  47722. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47723. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  47724. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47725. */
  47726. environmentBRDFTexture: Nullable<BaseTexture>;
  47727. /**
  47728. * Force normal to face away from face.
  47729. */
  47730. forceNormalForward: boolean;
  47731. /**
  47732. * Enables specular anti aliasing in the PBR shader.
  47733. * It will both interacts on the Geometry for analytical and IBL lighting.
  47734. * It also prefilter the roughness map based on the bump values.
  47735. */
  47736. enableSpecularAntiAliasing: boolean;
  47737. /**
  47738. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47739. * makes the reflect vector face the model (under horizon).
  47740. */
  47741. useHorizonOcclusion: boolean;
  47742. /**
  47743. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47744. * too much the area relying on ambient texture to define their ambient occlusion.
  47745. */
  47746. useRadianceOcclusion: boolean;
  47747. /**
  47748. * If set to true, no lighting calculations will be applied.
  47749. */
  47750. unlit: boolean;
  47751. /**
  47752. * Gets the image processing configuration used either in this material.
  47753. */
  47754. /**
  47755. * Sets the Default image processing configuration used either in the this material.
  47756. *
  47757. * If sets to null, the scene one is in use.
  47758. */
  47759. imageProcessingConfiguration: ImageProcessingConfiguration;
  47760. /**
  47761. * Gets wether the color curves effect is enabled.
  47762. */
  47763. /**
  47764. * Sets wether the color curves effect is enabled.
  47765. */
  47766. cameraColorCurvesEnabled: boolean;
  47767. /**
  47768. * Gets wether the color grading effect is enabled.
  47769. */
  47770. /**
  47771. * Gets wether the color grading effect is enabled.
  47772. */
  47773. cameraColorGradingEnabled: boolean;
  47774. /**
  47775. * Gets wether tonemapping is enabled or not.
  47776. */
  47777. /**
  47778. * Sets wether tonemapping is enabled or not
  47779. */
  47780. cameraToneMappingEnabled: boolean;
  47781. /**
  47782. * The camera exposure used on this material.
  47783. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47784. * This corresponds to a photographic exposure.
  47785. */
  47786. /**
  47787. * The camera exposure used on this material.
  47788. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47789. * This corresponds to a photographic exposure.
  47790. */
  47791. cameraExposure: number;
  47792. /**
  47793. * Gets The camera contrast used on this material.
  47794. */
  47795. /**
  47796. * Sets The camera contrast used on this material.
  47797. */
  47798. cameraContrast: number;
  47799. /**
  47800. * Gets the Color Grading 2D Lookup Texture.
  47801. */
  47802. /**
  47803. * Sets the Color Grading 2D Lookup Texture.
  47804. */
  47805. cameraColorGradingTexture: Nullable<BaseTexture>;
  47806. /**
  47807. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47808. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47809. * 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;
  47810. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47811. */
  47812. /**
  47813. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47814. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47815. * 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;
  47816. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47817. */
  47818. cameraColorCurves: Nullable<ColorCurves>;
  47819. /**
  47820. * Instantiates a new PBRMaterial instance.
  47821. *
  47822. * @param name The material name
  47823. * @param scene The scene the material will be use in.
  47824. */
  47825. constructor(name: string, scene: Scene);
  47826. /**
  47827. * Returns the name of this material class.
  47828. */
  47829. getClassName(): string;
  47830. /**
  47831. * Makes a duplicate of the current material.
  47832. * @param name - name to use for the new material.
  47833. */
  47834. clone(name: string): PBRMaterial;
  47835. /**
  47836. * Serializes this PBR Material.
  47837. * @returns - An object with the serialized material.
  47838. */
  47839. serialize(): any;
  47840. /**
  47841. * Parses a PBR Material from a serialized object.
  47842. * @param source - Serialized object.
  47843. * @param scene - BJS scene instance.
  47844. * @param rootUrl - url for the scene object
  47845. * @returns - PBRMaterial
  47846. */
  47847. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47848. }
  47849. }
  47850. declare module BABYLON {
  47851. /**
  47852. * Direct draw surface info
  47853. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47854. */
  47855. export interface DDSInfo {
  47856. /**
  47857. * Width of the texture
  47858. */
  47859. width: number;
  47860. /**
  47861. * Width of the texture
  47862. */
  47863. height: number;
  47864. /**
  47865. * Number of Mipmaps for the texture
  47866. * @see https://en.wikipedia.org/wiki/Mipmap
  47867. */
  47868. mipmapCount: number;
  47869. /**
  47870. * If the textures format is a known fourCC format
  47871. * @see https://www.fourcc.org/
  47872. */
  47873. isFourCC: boolean;
  47874. /**
  47875. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47876. */
  47877. isRGB: boolean;
  47878. /**
  47879. * If the texture is a lumincance format
  47880. */
  47881. isLuminance: boolean;
  47882. /**
  47883. * If this is a cube texture
  47884. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47885. */
  47886. isCube: boolean;
  47887. /**
  47888. * If the texture is a compressed format eg. FOURCC_DXT1
  47889. */
  47890. isCompressed: boolean;
  47891. /**
  47892. * The dxgiFormat of the texture
  47893. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47894. */
  47895. dxgiFormat: number;
  47896. /**
  47897. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47898. */
  47899. textureType: number;
  47900. /**
  47901. * Sphericle polynomial created for the dds texture
  47902. */
  47903. sphericalPolynomial?: SphericalPolynomial;
  47904. }
  47905. /**
  47906. * Class used to provide DDS decompression tools
  47907. */
  47908. export class DDSTools {
  47909. /**
  47910. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47911. */
  47912. static StoreLODInAlphaChannel: boolean;
  47913. /**
  47914. * Gets DDS information from an array buffer
  47915. * @param arrayBuffer defines the array buffer to read data from
  47916. * @returns the DDS information
  47917. */
  47918. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47919. private static _FloatView;
  47920. private static _Int32View;
  47921. private static _ToHalfFloat;
  47922. private static _FromHalfFloat;
  47923. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47924. private static _GetHalfFloatRGBAArrayBuffer;
  47925. private static _GetFloatRGBAArrayBuffer;
  47926. private static _GetFloatAsUIntRGBAArrayBuffer;
  47927. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47928. private static _GetRGBAArrayBuffer;
  47929. private static _ExtractLongWordOrder;
  47930. private static _GetRGBArrayBuffer;
  47931. private static _GetLuminanceArrayBuffer;
  47932. /**
  47933. * Uploads DDS Levels to a Babylon Texture
  47934. * @hidden
  47935. */
  47936. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47937. }
  47938. interface ThinEngine {
  47939. /**
  47940. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47941. * @param rootUrl defines the url where the file to load is located
  47942. * @param scene defines the current scene
  47943. * @param lodScale defines scale to apply to the mip map selection
  47944. * @param lodOffset defines offset to apply to the mip map selection
  47945. * @param onLoad defines an optional callback raised when the texture is loaded
  47946. * @param onError defines an optional callback raised if there is an issue to load the texture
  47947. * @param format defines the format of the data
  47948. * @param forcedExtension defines the extension to use to pick the right loader
  47949. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47950. * @returns the cube texture as an InternalTexture
  47951. */
  47952. 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;
  47953. }
  47954. }
  47955. declare module BABYLON {
  47956. /**
  47957. * Implementation of the DDS Texture Loader.
  47958. * @hidden
  47959. */
  47960. export class _DDSTextureLoader implements IInternalTextureLoader {
  47961. /**
  47962. * Defines wether the loader supports cascade loading the different faces.
  47963. */
  47964. readonly supportCascades: boolean;
  47965. /**
  47966. * This returns if the loader support the current file information.
  47967. * @param extension defines the file extension of the file being loaded
  47968. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47969. * @param fallback defines the fallback internal texture if any
  47970. * @param isBase64 defines whether the texture is encoded as a base64
  47971. * @param isBuffer defines whether the texture data are stored as a buffer
  47972. * @returns true if the loader can load the specified file
  47973. */
  47974. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47975. /**
  47976. * Transform the url before loading if required.
  47977. * @param rootUrl the url of the texture
  47978. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47979. * @returns the transformed texture
  47980. */
  47981. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47982. /**
  47983. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47984. * @param rootUrl the url of the texture
  47985. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47986. * @returns the fallback texture
  47987. */
  47988. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47989. /**
  47990. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47991. * @param data contains the texture data
  47992. * @param texture defines the BabylonJS internal texture
  47993. * @param createPolynomials will be true if polynomials have been requested
  47994. * @param onLoad defines the callback to trigger once the texture is ready
  47995. * @param onError defines the callback to trigger in case of error
  47996. */
  47997. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47998. /**
  47999. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48000. * @param data contains the texture data
  48001. * @param texture defines the BabylonJS internal texture
  48002. * @param callback defines the method to call once ready to upload
  48003. */
  48004. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48005. }
  48006. }
  48007. declare module BABYLON {
  48008. /**
  48009. * Implementation of the ENV Texture Loader.
  48010. * @hidden
  48011. */
  48012. export class _ENVTextureLoader implements IInternalTextureLoader {
  48013. /**
  48014. * Defines wether the loader supports cascade loading the different faces.
  48015. */
  48016. readonly supportCascades: boolean;
  48017. /**
  48018. * This returns if the loader support the current file information.
  48019. * @param extension defines the file extension of the file being loaded
  48020. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48021. * @param fallback defines the fallback internal texture if any
  48022. * @param isBase64 defines whether the texture is encoded as a base64
  48023. * @param isBuffer defines whether the texture data are stored as a buffer
  48024. * @returns true if the loader can load the specified file
  48025. */
  48026. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48027. /**
  48028. * Transform the url before loading if required.
  48029. * @param rootUrl the url of the texture
  48030. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48031. * @returns the transformed texture
  48032. */
  48033. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48034. /**
  48035. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48036. * @param rootUrl the url of the texture
  48037. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48038. * @returns the fallback texture
  48039. */
  48040. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48041. /**
  48042. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48043. * @param data contains the texture data
  48044. * @param texture defines the BabylonJS internal texture
  48045. * @param createPolynomials will be true if polynomials have been requested
  48046. * @param onLoad defines the callback to trigger once the texture is ready
  48047. * @param onError defines the callback to trigger in case of error
  48048. */
  48049. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48050. /**
  48051. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48052. * @param data contains the texture data
  48053. * @param texture defines the BabylonJS internal texture
  48054. * @param callback defines the method to call once ready to upload
  48055. */
  48056. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48057. }
  48058. }
  48059. declare module BABYLON {
  48060. /**
  48061. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48062. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48063. */
  48064. export class KhronosTextureContainer {
  48065. /** contents of the KTX container file */
  48066. arrayBuffer: any;
  48067. private static HEADER_LEN;
  48068. private static COMPRESSED_2D;
  48069. private static COMPRESSED_3D;
  48070. private static TEX_2D;
  48071. private static TEX_3D;
  48072. /**
  48073. * Gets the openGL type
  48074. */
  48075. glType: number;
  48076. /**
  48077. * Gets the openGL type size
  48078. */
  48079. glTypeSize: number;
  48080. /**
  48081. * Gets the openGL format
  48082. */
  48083. glFormat: number;
  48084. /**
  48085. * Gets the openGL internal format
  48086. */
  48087. glInternalFormat: number;
  48088. /**
  48089. * Gets the base internal format
  48090. */
  48091. glBaseInternalFormat: number;
  48092. /**
  48093. * Gets image width in pixel
  48094. */
  48095. pixelWidth: number;
  48096. /**
  48097. * Gets image height in pixel
  48098. */
  48099. pixelHeight: number;
  48100. /**
  48101. * Gets image depth in pixels
  48102. */
  48103. pixelDepth: number;
  48104. /**
  48105. * Gets the number of array elements
  48106. */
  48107. numberOfArrayElements: number;
  48108. /**
  48109. * Gets the number of faces
  48110. */
  48111. numberOfFaces: number;
  48112. /**
  48113. * Gets the number of mipmap levels
  48114. */
  48115. numberOfMipmapLevels: number;
  48116. /**
  48117. * Gets the bytes of key value data
  48118. */
  48119. bytesOfKeyValueData: number;
  48120. /**
  48121. * Gets the load type
  48122. */
  48123. loadType: number;
  48124. /**
  48125. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48126. */
  48127. isInvalid: boolean;
  48128. /**
  48129. * Creates a new KhronosTextureContainer
  48130. * @param arrayBuffer contents of the KTX container file
  48131. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48132. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48133. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48134. */
  48135. constructor(
  48136. /** contents of the KTX container file */
  48137. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48138. /**
  48139. * Uploads KTX content to a Babylon Texture.
  48140. * It is assumed that the texture has already been created & is currently bound
  48141. * @hidden
  48142. */
  48143. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48144. private _upload2DCompressedLevels;
  48145. }
  48146. }
  48147. declare module BABYLON {
  48148. /**
  48149. * Implementation of the KTX Texture Loader.
  48150. * @hidden
  48151. */
  48152. export class _KTXTextureLoader implements IInternalTextureLoader {
  48153. /**
  48154. * Defines wether the loader supports cascade loading the different faces.
  48155. */
  48156. readonly supportCascades: boolean;
  48157. /**
  48158. * This returns if the loader support the current file information.
  48159. * @param extension defines the file extension of the file being loaded
  48160. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48161. * @param fallback defines the fallback internal texture if any
  48162. * @param isBase64 defines whether the texture is encoded as a base64
  48163. * @param isBuffer defines whether the texture data are stored as a buffer
  48164. * @returns true if the loader can load the specified file
  48165. */
  48166. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48167. /**
  48168. * Transform the url before loading if required.
  48169. * @param rootUrl the url of the texture
  48170. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48171. * @returns the transformed texture
  48172. */
  48173. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48174. /**
  48175. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48176. * @param rootUrl the url of the texture
  48177. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48178. * @returns the fallback texture
  48179. */
  48180. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48181. /**
  48182. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48183. * @param data contains the texture data
  48184. * @param texture defines the BabylonJS internal texture
  48185. * @param createPolynomials will be true if polynomials have been requested
  48186. * @param onLoad defines the callback to trigger once the texture is ready
  48187. * @param onError defines the callback to trigger in case of error
  48188. */
  48189. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48190. /**
  48191. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48192. * @param data contains the texture data
  48193. * @param texture defines the BabylonJS internal texture
  48194. * @param callback defines the method to call once ready to upload
  48195. */
  48196. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48197. }
  48198. }
  48199. declare module BABYLON {
  48200. /**
  48201. * Options for the default xr helper
  48202. */
  48203. export class WebXRDefaultExperienceOptions {
  48204. /**
  48205. * Floor meshes that should be used for teleporting
  48206. */
  48207. floorMeshes: Array<AbstractMesh>;
  48208. }
  48209. /**
  48210. * Default experience which provides a similar setup to the previous webVRExperience
  48211. */
  48212. export class WebXRDefaultExperience {
  48213. /**
  48214. * Base experience
  48215. */
  48216. baseExperience: WebXRExperienceHelper;
  48217. /**
  48218. * Input experience extension
  48219. */
  48220. input: WebXRInput;
  48221. /**
  48222. * Loads the controller models
  48223. */
  48224. controllerModelLoader: WebXRControllerModelLoader;
  48225. /**
  48226. * Enables laser pointer and selection
  48227. */
  48228. pointerSelection: WebXRControllerPointerSelection;
  48229. /**
  48230. * Enables teleportation
  48231. */
  48232. teleportation: WebXRControllerTeleportation;
  48233. /**
  48234. * Enables ui for enetering/exiting xr
  48235. */
  48236. enterExitUI: WebXREnterExitUI;
  48237. /**
  48238. * Default output canvas xr should render to
  48239. */
  48240. outputCanvas: WebXRManagedOutputCanvas;
  48241. /**
  48242. * Creates the default xr experience
  48243. * @param scene scene
  48244. * @param options options for basic configuration
  48245. * @returns resulting WebXRDefaultExperience
  48246. */
  48247. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48248. private constructor();
  48249. /**
  48250. * DIsposes of the experience helper
  48251. */
  48252. dispose(): void;
  48253. }
  48254. }
  48255. declare module BABYLON {
  48256. /** @hidden */
  48257. export var _forceSceneHelpersToBundle: boolean;
  48258. interface Scene {
  48259. /**
  48260. * Creates a default light for the scene.
  48261. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48262. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48263. */
  48264. createDefaultLight(replace?: boolean): void;
  48265. /**
  48266. * Creates a default camera for the scene.
  48267. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48268. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48269. * @param replace has default false, when true replaces the active camera in the scene
  48270. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48271. */
  48272. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48273. /**
  48274. * Creates a default camera and a default light.
  48275. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48276. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48277. * @param replace has the default false, when true replaces the active camera/light in the scene
  48278. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48279. */
  48280. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48281. /**
  48282. * Creates a new sky box
  48283. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48284. * @param environmentTexture defines the texture to use as environment texture
  48285. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48286. * @param scale defines the overall scale of the skybox
  48287. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48288. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48289. * @returns a new mesh holding the sky box
  48290. */
  48291. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48292. /**
  48293. * Creates a new environment
  48294. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48295. * @param options defines the options you can use to configure the environment
  48296. * @returns the new EnvironmentHelper
  48297. */
  48298. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48299. /**
  48300. * Creates a new VREXperienceHelper
  48301. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48302. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48303. * @returns a new VREXperienceHelper
  48304. */
  48305. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48306. /**
  48307. * Creates a new WebXRDefaultExperience
  48308. * @see http://doc.babylonjs.com/how_to/webxr
  48309. * @param options experience options
  48310. * @returns a promise for a new WebXRDefaultExperience
  48311. */
  48312. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48313. }
  48314. }
  48315. declare module BABYLON {
  48316. /**
  48317. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48318. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48319. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48320. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48321. */
  48322. export class VideoDome extends TransformNode {
  48323. /**
  48324. * Define the video source as a Monoscopic panoramic 360 video.
  48325. */
  48326. static readonly MODE_MONOSCOPIC: number;
  48327. /**
  48328. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48329. */
  48330. static readonly MODE_TOPBOTTOM: number;
  48331. /**
  48332. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48333. */
  48334. static readonly MODE_SIDEBYSIDE: number;
  48335. private _halfDome;
  48336. private _useDirectMapping;
  48337. /**
  48338. * The video texture being displayed on the sphere
  48339. */
  48340. protected _videoTexture: VideoTexture;
  48341. /**
  48342. * Gets the video texture being displayed on the sphere
  48343. */
  48344. readonly videoTexture: VideoTexture;
  48345. /**
  48346. * The skybox material
  48347. */
  48348. protected _material: BackgroundMaterial;
  48349. /**
  48350. * The surface used for the skybox
  48351. */
  48352. protected _mesh: Mesh;
  48353. /**
  48354. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  48355. */
  48356. private _halfDomeMask;
  48357. /**
  48358. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48359. * Also see the options.resolution property.
  48360. */
  48361. fovMultiplier: number;
  48362. private _videoMode;
  48363. /**
  48364. * Gets or set the current video mode for the video. It can be:
  48365. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48366. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48367. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48368. */
  48369. videoMode: number;
  48370. /**
  48371. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  48372. *
  48373. */
  48374. /**
  48375. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  48376. */
  48377. halfDome: boolean;
  48378. /**
  48379. * Oberserver used in Stereoscopic VR Mode.
  48380. */
  48381. private _onBeforeCameraRenderObserver;
  48382. /**
  48383. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48384. * @param name Element's name, child elements will append suffixes for their own names.
  48385. * @param urlsOrVideo defines the url(s) or the video element to use
  48386. * @param options An object containing optional or exposed sub element properties
  48387. */
  48388. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48389. resolution?: number;
  48390. clickToPlay?: boolean;
  48391. autoPlay?: boolean;
  48392. loop?: boolean;
  48393. size?: number;
  48394. poster?: string;
  48395. faceForward?: boolean;
  48396. useDirectMapping?: boolean;
  48397. halfDomeMode?: boolean;
  48398. }, scene: Scene);
  48399. private _changeVideoMode;
  48400. /**
  48401. * Releases resources associated with this node.
  48402. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48403. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48404. */
  48405. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48406. }
  48407. }
  48408. declare module BABYLON {
  48409. /**
  48410. * This class can be used to get instrumentation data from a Babylon engine
  48411. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48412. */
  48413. export class EngineInstrumentation implements IDisposable {
  48414. /**
  48415. * Define the instrumented engine.
  48416. */
  48417. engine: Engine;
  48418. private _captureGPUFrameTime;
  48419. private _gpuFrameTimeToken;
  48420. private _gpuFrameTime;
  48421. private _captureShaderCompilationTime;
  48422. private _shaderCompilationTime;
  48423. private _onBeginFrameObserver;
  48424. private _onEndFrameObserver;
  48425. private _onBeforeShaderCompilationObserver;
  48426. private _onAfterShaderCompilationObserver;
  48427. /**
  48428. * Gets the perf counter used for GPU frame time
  48429. */
  48430. readonly gpuFrameTimeCounter: PerfCounter;
  48431. /**
  48432. * Gets the GPU frame time capture status
  48433. */
  48434. /**
  48435. * Enable or disable the GPU frame time capture
  48436. */
  48437. captureGPUFrameTime: boolean;
  48438. /**
  48439. * Gets the perf counter used for shader compilation time
  48440. */
  48441. readonly shaderCompilationTimeCounter: PerfCounter;
  48442. /**
  48443. * Gets the shader compilation time capture status
  48444. */
  48445. /**
  48446. * Enable or disable the shader compilation time capture
  48447. */
  48448. captureShaderCompilationTime: boolean;
  48449. /**
  48450. * Instantiates a new engine instrumentation.
  48451. * This class can be used to get instrumentation data from a Babylon engine
  48452. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48453. * @param engine Defines the engine to instrument
  48454. */
  48455. constructor(
  48456. /**
  48457. * Define the instrumented engine.
  48458. */
  48459. engine: Engine);
  48460. /**
  48461. * Dispose and release associated resources.
  48462. */
  48463. dispose(): void;
  48464. }
  48465. }
  48466. declare module BABYLON {
  48467. /**
  48468. * This class can be used to get instrumentation data from a Babylon engine
  48469. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48470. */
  48471. export class SceneInstrumentation implements IDisposable {
  48472. /**
  48473. * Defines the scene to instrument
  48474. */
  48475. scene: Scene;
  48476. private _captureActiveMeshesEvaluationTime;
  48477. private _activeMeshesEvaluationTime;
  48478. private _captureRenderTargetsRenderTime;
  48479. private _renderTargetsRenderTime;
  48480. private _captureFrameTime;
  48481. private _frameTime;
  48482. private _captureRenderTime;
  48483. private _renderTime;
  48484. private _captureInterFrameTime;
  48485. private _interFrameTime;
  48486. private _captureParticlesRenderTime;
  48487. private _particlesRenderTime;
  48488. private _captureSpritesRenderTime;
  48489. private _spritesRenderTime;
  48490. private _capturePhysicsTime;
  48491. private _physicsTime;
  48492. private _captureAnimationsTime;
  48493. private _animationsTime;
  48494. private _captureCameraRenderTime;
  48495. private _cameraRenderTime;
  48496. private _onBeforeActiveMeshesEvaluationObserver;
  48497. private _onAfterActiveMeshesEvaluationObserver;
  48498. private _onBeforeRenderTargetsRenderObserver;
  48499. private _onAfterRenderTargetsRenderObserver;
  48500. private _onAfterRenderObserver;
  48501. private _onBeforeDrawPhaseObserver;
  48502. private _onAfterDrawPhaseObserver;
  48503. private _onBeforeAnimationsObserver;
  48504. private _onBeforeParticlesRenderingObserver;
  48505. private _onAfterParticlesRenderingObserver;
  48506. private _onBeforeSpritesRenderingObserver;
  48507. private _onAfterSpritesRenderingObserver;
  48508. private _onBeforePhysicsObserver;
  48509. private _onAfterPhysicsObserver;
  48510. private _onAfterAnimationsObserver;
  48511. private _onBeforeCameraRenderObserver;
  48512. private _onAfterCameraRenderObserver;
  48513. /**
  48514. * Gets the perf counter used for active meshes evaluation time
  48515. */
  48516. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48517. /**
  48518. * Gets the active meshes evaluation time capture status
  48519. */
  48520. /**
  48521. * Enable or disable the active meshes evaluation time capture
  48522. */
  48523. captureActiveMeshesEvaluationTime: boolean;
  48524. /**
  48525. * Gets the perf counter used for render targets render time
  48526. */
  48527. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48528. /**
  48529. * Gets the render targets render time capture status
  48530. */
  48531. /**
  48532. * Enable or disable the render targets render time capture
  48533. */
  48534. captureRenderTargetsRenderTime: boolean;
  48535. /**
  48536. * Gets the perf counter used for particles render time
  48537. */
  48538. readonly particlesRenderTimeCounter: PerfCounter;
  48539. /**
  48540. * Gets the particles render time capture status
  48541. */
  48542. /**
  48543. * Enable or disable the particles render time capture
  48544. */
  48545. captureParticlesRenderTime: boolean;
  48546. /**
  48547. * Gets the perf counter used for sprites render time
  48548. */
  48549. readonly spritesRenderTimeCounter: PerfCounter;
  48550. /**
  48551. * Gets the sprites render time capture status
  48552. */
  48553. /**
  48554. * Enable or disable the sprites render time capture
  48555. */
  48556. captureSpritesRenderTime: boolean;
  48557. /**
  48558. * Gets the perf counter used for physics time
  48559. */
  48560. readonly physicsTimeCounter: PerfCounter;
  48561. /**
  48562. * Gets the physics time capture status
  48563. */
  48564. /**
  48565. * Enable or disable the physics time capture
  48566. */
  48567. capturePhysicsTime: boolean;
  48568. /**
  48569. * Gets the perf counter used for animations time
  48570. */
  48571. readonly animationsTimeCounter: PerfCounter;
  48572. /**
  48573. * Gets the animations time capture status
  48574. */
  48575. /**
  48576. * Enable or disable the animations time capture
  48577. */
  48578. captureAnimationsTime: boolean;
  48579. /**
  48580. * Gets the perf counter used for frame time capture
  48581. */
  48582. readonly frameTimeCounter: PerfCounter;
  48583. /**
  48584. * Gets the frame time capture status
  48585. */
  48586. /**
  48587. * Enable or disable the frame time capture
  48588. */
  48589. captureFrameTime: boolean;
  48590. /**
  48591. * Gets the perf counter used for inter-frames time capture
  48592. */
  48593. readonly interFrameTimeCounter: PerfCounter;
  48594. /**
  48595. * Gets the inter-frames time capture status
  48596. */
  48597. /**
  48598. * Enable or disable the inter-frames time capture
  48599. */
  48600. captureInterFrameTime: boolean;
  48601. /**
  48602. * Gets the perf counter used for render time capture
  48603. */
  48604. readonly renderTimeCounter: PerfCounter;
  48605. /**
  48606. * Gets the render time capture status
  48607. */
  48608. /**
  48609. * Enable or disable the render time capture
  48610. */
  48611. captureRenderTime: boolean;
  48612. /**
  48613. * Gets the perf counter used for camera render time capture
  48614. */
  48615. readonly cameraRenderTimeCounter: PerfCounter;
  48616. /**
  48617. * Gets the camera render time capture status
  48618. */
  48619. /**
  48620. * Enable or disable the camera render time capture
  48621. */
  48622. captureCameraRenderTime: boolean;
  48623. /**
  48624. * Gets the perf counter used for draw calls
  48625. */
  48626. readonly drawCallsCounter: PerfCounter;
  48627. /**
  48628. * Instantiates a new scene instrumentation.
  48629. * This class can be used to get instrumentation data from a Babylon engine
  48630. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48631. * @param scene Defines the scene to instrument
  48632. */
  48633. constructor(
  48634. /**
  48635. * Defines the scene to instrument
  48636. */
  48637. scene: Scene);
  48638. /**
  48639. * Dispose and release associated resources.
  48640. */
  48641. dispose(): void;
  48642. }
  48643. }
  48644. declare module BABYLON {
  48645. /** @hidden */
  48646. export var glowMapGenerationPixelShader: {
  48647. name: string;
  48648. shader: string;
  48649. };
  48650. }
  48651. declare module BABYLON {
  48652. /** @hidden */
  48653. export var glowMapGenerationVertexShader: {
  48654. name: string;
  48655. shader: string;
  48656. };
  48657. }
  48658. declare module BABYLON {
  48659. /**
  48660. * Effect layer options. This helps customizing the behaviour
  48661. * of the effect layer.
  48662. */
  48663. export interface IEffectLayerOptions {
  48664. /**
  48665. * Multiplication factor apply to the canvas size to compute the render target size
  48666. * used to generated the objects (the smaller the faster).
  48667. */
  48668. mainTextureRatio: number;
  48669. /**
  48670. * Enforces a fixed size texture to ensure effect stability across devices.
  48671. */
  48672. mainTextureFixedSize?: number;
  48673. /**
  48674. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48675. */
  48676. alphaBlendingMode: number;
  48677. /**
  48678. * The camera attached to the layer.
  48679. */
  48680. camera: Nullable<Camera>;
  48681. /**
  48682. * The rendering group to draw the layer in.
  48683. */
  48684. renderingGroupId: number;
  48685. }
  48686. /**
  48687. * The effect layer Helps adding post process effect blended with the main pass.
  48688. *
  48689. * This can be for instance use to generate glow or higlight effects on the scene.
  48690. *
  48691. * The effect layer class can not be used directly and is intented to inherited from to be
  48692. * customized per effects.
  48693. */
  48694. export abstract class EffectLayer {
  48695. private _vertexBuffers;
  48696. private _indexBuffer;
  48697. private _cachedDefines;
  48698. private _effectLayerMapGenerationEffect;
  48699. private _effectLayerOptions;
  48700. private _mergeEffect;
  48701. protected _scene: Scene;
  48702. protected _engine: Engine;
  48703. protected _maxSize: number;
  48704. protected _mainTextureDesiredSize: ISize;
  48705. protected _mainTexture: RenderTargetTexture;
  48706. protected _shouldRender: boolean;
  48707. protected _postProcesses: PostProcess[];
  48708. protected _textures: BaseTexture[];
  48709. protected _emissiveTextureAndColor: {
  48710. texture: Nullable<BaseTexture>;
  48711. color: Color4;
  48712. };
  48713. /**
  48714. * The name of the layer
  48715. */
  48716. name: string;
  48717. /**
  48718. * The clear color of the texture used to generate the glow map.
  48719. */
  48720. neutralColor: Color4;
  48721. /**
  48722. * Specifies wether the highlight layer is enabled or not.
  48723. */
  48724. isEnabled: boolean;
  48725. /**
  48726. * Gets the camera attached to the layer.
  48727. */
  48728. readonly camera: Nullable<Camera>;
  48729. /**
  48730. * Gets the rendering group id the layer should render in.
  48731. */
  48732. renderingGroupId: number;
  48733. /**
  48734. * An event triggered when the effect layer has been disposed.
  48735. */
  48736. onDisposeObservable: Observable<EffectLayer>;
  48737. /**
  48738. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48739. */
  48740. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48741. /**
  48742. * An event triggered when the generated texture is being merged in the scene.
  48743. */
  48744. onBeforeComposeObservable: Observable<EffectLayer>;
  48745. /**
  48746. * An event triggered when the generated texture has been merged in the scene.
  48747. */
  48748. onAfterComposeObservable: Observable<EffectLayer>;
  48749. /**
  48750. * An event triggered when the efffect layer changes its size.
  48751. */
  48752. onSizeChangedObservable: Observable<EffectLayer>;
  48753. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  48754. /**
  48755. * Instantiates a new effect Layer and references it in the scene.
  48756. * @param name The name of the layer
  48757. * @param scene The scene to use the layer in
  48758. */
  48759. constructor(
  48760. /** The Friendly of the effect in the scene */
  48761. name: string, scene: Scene);
  48762. /**
  48763. * Get the effect name of the layer.
  48764. * @return The effect name
  48765. */
  48766. abstract getEffectName(): string;
  48767. /**
  48768. * Checks for the readiness of the element composing the layer.
  48769. * @param subMesh the mesh to check for
  48770. * @param useInstances specify wether or not to use instances to render the mesh
  48771. * @return true if ready otherwise, false
  48772. */
  48773. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48774. /**
  48775. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48776. * @returns true if the effect requires stencil during the main canvas render pass.
  48777. */
  48778. abstract needStencil(): boolean;
  48779. /**
  48780. * Create the merge effect. This is the shader use to blit the information back
  48781. * to the main canvas at the end of the scene rendering.
  48782. * @returns The effect containing the shader used to merge the effect on the main canvas
  48783. */
  48784. protected abstract _createMergeEffect(): Effect;
  48785. /**
  48786. * Creates the render target textures and post processes used in the effect layer.
  48787. */
  48788. protected abstract _createTextureAndPostProcesses(): void;
  48789. /**
  48790. * Implementation specific of rendering the generating effect on the main canvas.
  48791. * @param effect The effect used to render through
  48792. */
  48793. protected abstract _internalRender(effect: Effect): void;
  48794. /**
  48795. * Sets the required values for both the emissive texture and and the main color.
  48796. */
  48797. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48798. /**
  48799. * Free any resources and references associated to a mesh.
  48800. * Internal use
  48801. * @param mesh The mesh to free.
  48802. */
  48803. abstract _disposeMesh(mesh: Mesh): void;
  48804. /**
  48805. * Serializes this layer (Glow or Highlight for example)
  48806. * @returns a serialized layer object
  48807. */
  48808. abstract serialize?(): any;
  48809. /**
  48810. * Initializes the effect layer with the required options.
  48811. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48812. */
  48813. protected _init(options: Partial<IEffectLayerOptions>): void;
  48814. /**
  48815. * Generates the index buffer of the full screen quad blending to the main canvas.
  48816. */
  48817. private _generateIndexBuffer;
  48818. /**
  48819. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48820. */
  48821. private _generateVertexBuffer;
  48822. /**
  48823. * Sets the main texture desired size which is the closest power of two
  48824. * of the engine canvas size.
  48825. */
  48826. private _setMainTextureSize;
  48827. /**
  48828. * Creates the main texture for the effect layer.
  48829. */
  48830. protected _createMainTexture(): void;
  48831. /**
  48832. * Adds specific effects defines.
  48833. * @param defines The defines to add specifics to.
  48834. */
  48835. protected _addCustomEffectDefines(defines: string[]): void;
  48836. /**
  48837. * Checks for the readiness of the element composing the layer.
  48838. * @param subMesh the mesh to check for
  48839. * @param useInstances specify wether or not to use instances to render the mesh
  48840. * @param emissiveTexture the associated emissive texture used to generate the glow
  48841. * @return true if ready otherwise, false
  48842. */
  48843. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48844. /**
  48845. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48846. */
  48847. render(): void;
  48848. /**
  48849. * Determine if a given mesh will be used in the current effect.
  48850. * @param mesh mesh to test
  48851. * @returns true if the mesh will be used
  48852. */
  48853. hasMesh(mesh: AbstractMesh): boolean;
  48854. /**
  48855. * Returns true if the layer contains information to display, otherwise false.
  48856. * @returns true if the glow layer should be rendered
  48857. */
  48858. shouldRender(): boolean;
  48859. /**
  48860. * Returns true if the mesh should render, otherwise false.
  48861. * @param mesh The mesh to render
  48862. * @returns true if it should render otherwise false
  48863. */
  48864. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48865. /**
  48866. * Returns true if the mesh can be rendered, otherwise false.
  48867. * @param mesh The mesh to render
  48868. * @param material The material used on the mesh
  48869. * @returns true if it can be rendered otherwise false
  48870. */
  48871. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48872. /**
  48873. * Returns true if the mesh should render, otherwise false.
  48874. * @param mesh The mesh to render
  48875. * @returns true if it should render otherwise false
  48876. */
  48877. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48878. /**
  48879. * Renders the submesh passed in parameter to the generation map.
  48880. */
  48881. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  48882. /**
  48883. * Rebuild the required buffers.
  48884. * @hidden Internal use only.
  48885. */ private _rebuild(): void;
  48886. /**
  48887. * Dispose only the render target textures and post process.
  48888. */
  48889. private _disposeTextureAndPostProcesses;
  48890. /**
  48891. * Dispose the highlight layer and free resources.
  48892. */
  48893. dispose(): void;
  48894. /**
  48895. * Gets the class name of the effect layer
  48896. * @returns the string with the class name of the effect layer
  48897. */
  48898. getClassName(): string;
  48899. /**
  48900. * Creates an effect layer from parsed effect layer data
  48901. * @param parsedEffectLayer defines effect layer data
  48902. * @param scene defines the current scene
  48903. * @param rootUrl defines the root URL containing the effect layer information
  48904. * @returns a parsed effect Layer
  48905. */
  48906. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  48907. }
  48908. }
  48909. declare module BABYLON {
  48910. interface AbstractScene {
  48911. /**
  48912. * The list of effect layers (highlights/glow) added to the scene
  48913. * @see http://doc.babylonjs.com/how_to/highlight_layer
  48914. * @see http://doc.babylonjs.com/how_to/glow_layer
  48915. */
  48916. effectLayers: Array<EffectLayer>;
  48917. /**
  48918. * Removes the given effect layer from this scene.
  48919. * @param toRemove defines the effect layer to remove
  48920. * @returns the index of the removed effect layer
  48921. */
  48922. removeEffectLayer(toRemove: EffectLayer): number;
  48923. /**
  48924. * Adds the given effect layer to this scene
  48925. * @param newEffectLayer defines the effect layer to add
  48926. */
  48927. addEffectLayer(newEffectLayer: EffectLayer): void;
  48928. }
  48929. /**
  48930. * Defines the layer scene component responsible to manage any effect layers
  48931. * in a given scene.
  48932. */
  48933. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  48934. /**
  48935. * The component name helpfull to identify the component in the list of scene components.
  48936. */
  48937. readonly name: string;
  48938. /**
  48939. * The scene the component belongs to.
  48940. */
  48941. scene: Scene;
  48942. private _engine;
  48943. private _renderEffects;
  48944. private _needStencil;
  48945. private _previousStencilState;
  48946. /**
  48947. * Creates a new instance of the component for the given scene
  48948. * @param scene Defines the scene to register the component in
  48949. */
  48950. constructor(scene: Scene);
  48951. /**
  48952. * Registers the component in a given scene
  48953. */
  48954. register(): void;
  48955. /**
  48956. * Rebuilds the elements related to this component in case of
  48957. * context lost for instance.
  48958. */
  48959. rebuild(): void;
  48960. /**
  48961. * Serializes the component data to the specified json object
  48962. * @param serializationObject The object to serialize to
  48963. */
  48964. serialize(serializationObject: any): void;
  48965. /**
  48966. * Adds all the elements from the container to the scene
  48967. * @param container the container holding the elements
  48968. */
  48969. addFromContainer(container: AbstractScene): void;
  48970. /**
  48971. * Removes all the elements in the container from the scene
  48972. * @param container contains the elements to remove
  48973. * @param dispose if the removed element should be disposed (default: false)
  48974. */
  48975. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48976. /**
  48977. * Disposes the component and the associated ressources.
  48978. */
  48979. dispose(): void;
  48980. private _isReadyForMesh;
  48981. private _renderMainTexture;
  48982. private _setStencil;
  48983. private _setStencilBack;
  48984. private _draw;
  48985. private _drawCamera;
  48986. private _drawRenderingGroup;
  48987. }
  48988. }
  48989. declare module BABYLON {
  48990. /** @hidden */
  48991. export var glowMapMergePixelShader: {
  48992. name: string;
  48993. shader: string;
  48994. };
  48995. }
  48996. declare module BABYLON {
  48997. /** @hidden */
  48998. export var glowMapMergeVertexShader: {
  48999. name: string;
  49000. shader: string;
  49001. };
  49002. }
  49003. declare module BABYLON {
  49004. interface AbstractScene {
  49005. /**
  49006. * Return a the first highlight layer of the scene with a given name.
  49007. * @param name The name of the highlight layer to look for.
  49008. * @return The highlight layer if found otherwise null.
  49009. */
  49010. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49011. }
  49012. /**
  49013. * Glow layer options. This helps customizing the behaviour
  49014. * of the glow layer.
  49015. */
  49016. export interface IGlowLayerOptions {
  49017. /**
  49018. * Multiplication factor apply to the canvas size to compute the render target size
  49019. * used to generated the glowing objects (the smaller the faster).
  49020. */
  49021. mainTextureRatio: number;
  49022. /**
  49023. * Enforces a fixed size texture to ensure resize independant blur.
  49024. */
  49025. mainTextureFixedSize?: number;
  49026. /**
  49027. * How big is the kernel of the blur texture.
  49028. */
  49029. blurKernelSize: number;
  49030. /**
  49031. * The camera attached to the layer.
  49032. */
  49033. camera: Nullable<Camera>;
  49034. /**
  49035. * Enable MSAA by chosing the number of samples.
  49036. */
  49037. mainTextureSamples?: number;
  49038. /**
  49039. * The rendering group to draw the layer in.
  49040. */
  49041. renderingGroupId: number;
  49042. }
  49043. /**
  49044. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49045. *
  49046. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  49047. * glowy meshes to your scene.
  49048. *
  49049. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49050. */
  49051. export class GlowLayer extends EffectLayer {
  49052. /**
  49053. * Effect Name of the layer.
  49054. */
  49055. static readonly EffectName: string;
  49056. /**
  49057. * The default blur kernel size used for the glow.
  49058. */
  49059. static DefaultBlurKernelSize: number;
  49060. /**
  49061. * The default texture size ratio used for the glow.
  49062. */
  49063. static DefaultTextureRatio: number;
  49064. /**
  49065. * Sets the kernel size of the blur.
  49066. */
  49067. /**
  49068. * Gets the kernel size of the blur.
  49069. */
  49070. blurKernelSize: number;
  49071. /**
  49072. * Sets the glow intensity.
  49073. */
  49074. /**
  49075. * Gets the glow intensity.
  49076. */
  49077. intensity: number;
  49078. private _options;
  49079. private _intensity;
  49080. private _horizontalBlurPostprocess1;
  49081. private _verticalBlurPostprocess1;
  49082. private _horizontalBlurPostprocess2;
  49083. private _verticalBlurPostprocess2;
  49084. private _blurTexture1;
  49085. private _blurTexture2;
  49086. private _postProcesses1;
  49087. private _postProcesses2;
  49088. private _includedOnlyMeshes;
  49089. private _excludedMeshes;
  49090. /**
  49091. * Callback used to let the user override the color selection on a per mesh basis
  49092. */
  49093. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49094. /**
  49095. * Callback used to let the user override the texture selection on a per mesh basis
  49096. */
  49097. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49098. /**
  49099. * Instantiates a new glow Layer and references it to the scene.
  49100. * @param name The name of the layer
  49101. * @param scene The scene to use the layer in
  49102. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49103. */
  49104. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49105. /**
  49106. * Get the effect name of the layer.
  49107. * @return The effect name
  49108. */
  49109. getEffectName(): string;
  49110. /**
  49111. * Create the merge effect. This is the shader use to blit the information back
  49112. * to the main canvas at the end of the scene rendering.
  49113. */
  49114. protected _createMergeEffect(): Effect;
  49115. /**
  49116. * Creates the render target textures and post processes used in the glow layer.
  49117. */
  49118. protected _createTextureAndPostProcesses(): void;
  49119. /**
  49120. * Checks for the readiness of the element composing the layer.
  49121. * @param subMesh the mesh to check for
  49122. * @param useInstances specify wether or not to use instances to render the mesh
  49123. * @param emissiveTexture the associated emissive texture used to generate the glow
  49124. * @return true if ready otherwise, false
  49125. */
  49126. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49127. /**
  49128. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49129. */
  49130. needStencil(): boolean;
  49131. /**
  49132. * Returns true if the mesh can be rendered, otherwise false.
  49133. * @param mesh The mesh to render
  49134. * @param material The material used on the mesh
  49135. * @returns true if it can be rendered otherwise false
  49136. */
  49137. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49138. /**
  49139. * Implementation specific of rendering the generating effect on the main canvas.
  49140. * @param effect The effect used to render through
  49141. */
  49142. protected _internalRender(effect: Effect): void;
  49143. /**
  49144. * Sets the required values for both the emissive texture and and the main color.
  49145. */
  49146. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49147. /**
  49148. * Returns true if the mesh should render, otherwise false.
  49149. * @param mesh The mesh to render
  49150. * @returns true if it should render otherwise false
  49151. */
  49152. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49153. /**
  49154. * Adds specific effects defines.
  49155. * @param defines The defines to add specifics to.
  49156. */
  49157. protected _addCustomEffectDefines(defines: string[]): void;
  49158. /**
  49159. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49160. * @param mesh The mesh to exclude from the glow layer
  49161. */
  49162. addExcludedMesh(mesh: Mesh): void;
  49163. /**
  49164. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49165. * @param mesh The mesh to remove
  49166. */
  49167. removeExcludedMesh(mesh: Mesh): void;
  49168. /**
  49169. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49170. * @param mesh The mesh to include in the glow layer
  49171. */
  49172. addIncludedOnlyMesh(mesh: Mesh): void;
  49173. /**
  49174. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49175. * @param mesh The mesh to remove
  49176. */
  49177. removeIncludedOnlyMesh(mesh: Mesh): void;
  49178. /**
  49179. * Determine if a given mesh will be used in the glow layer
  49180. * @param mesh The mesh to test
  49181. * @returns true if the mesh will be highlighted by the current glow layer
  49182. */
  49183. hasMesh(mesh: AbstractMesh): boolean;
  49184. /**
  49185. * Free any resources and references associated to a mesh.
  49186. * Internal use
  49187. * @param mesh The mesh to free.
  49188. * @hidden
  49189. */ private _disposeMesh(mesh: Mesh): void;
  49190. /**
  49191. * Gets the class name of the effect layer
  49192. * @returns the string with the class name of the effect layer
  49193. */
  49194. getClassName(): string;
  49195. /**
  49196. * Serializes this glow layer
  49197. * @returns a serialized glow layer object
  49198. */
  49199. serialize(): any;
  49200. /**
  49201. * Creates a Glow Layer from parsed glow layer data
  49202. * @param parsedGlowLayer defines glow layer data
  49203. * @param scene defines the current scene
  49204. * @param rootUrl defines the root URL containing the glow layer information
  49205. * @returns a parsed Glow Layer
  49206. */
  49207. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49208. }
  49209. }
  49210. declare module BABYLON {
  49211. /** @hidden */
  49212. export var glowBlurPostProcessPixelShader: {
  49213. name: string;
  49214. shader: string;
  49215. };
  49216. }
  49217. declare module BABYLON {
  49218. interface AbstractScene {
  49219. /**
  49220. * Return a the first highlight layer of the scene with a given name.
  49221. * @param name The name of the highlight layer to look for.
  49222. * @return The highlight layer if found otherwise null.
  49223. */
  49224. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49225. }
  49226. /**
  49227. * Highlight layer options. This helps customizing the behaviour
  49228. * of the highlight layer.
  49229. */
  49230. export interface IHighlightLayerOptions {
  49231. /**
  49232. * Multiplication factor apply to the canvas size to compute the render target size
  49233. * used to generated the glowing objects (the smaller the faster).
  49234. */
  49235. mainTextureRatio: number;
  49236. /**
  49237. * Enforces a fixed size texture to ensure resize independant blur.
  49238. */
  49239. mainTextureFixedSize?: number;
  49240. /**
  49241. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49242. * of the picture to blur (the smaller the faster).
  49243. */
  49244. blurTextureSizeRatio: number;
  49245. /**
  49246. * How big in texel of the blur texture is the vertical blur.
  49247. */
  49248. blurVerticalSize: number;
  49249. /**
  49250. * How big in texel of the blur texture is the horizontal blur.
  49251. */
  49252. blurHorizontalSize: number;
  49253. /**
  49254. * Alpha blending mode used to apply the blur. Default is combine.
  49255. */
  49256. alphaBlendingMode: number;
  49257. /**
  49258. * The camera attached to the layer.
  49259. */
  49260. camera: Nullable<Camera>;
  49261. /**
  49262. * Should we display highlight as a solid stroke?
  49263. */
  49264. isStroke?: boolean;
  49265. /**
  49266. * The rendering group to draw the layer in.
  49267. */
  49268. renderingGroupId: number;
  49269. }
  49270. /**
  49271. * The highlight layer Helps adding a glow effect around a mesh.
  49272. *
  49273. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  49274. * glowy meshes to your scene.
  49275. *
  49276. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49277. */
  49278. export class HighlightLayer extends EffectLayer {
  49279. name: string;
  49280. /**
  49281. * Effect Name of the highlight layer.
  49282. */
  49283. static readonly EffectName: string;
  49284. /**
  49285. * The neutral color used during the preparation of the glow effect.
  49286. * This is black by default as the blend operation is a blend operation.
  49287. */
  49288. static NeutralColor: Color4;
  49289. /**
  49290. * Stencil value used for glowing meshes.
  49291. */
  49292. static GlowingMeshStencilReference: number;
  49293. /**
  49294. * Stencil value used for the other meshes in the scene.
  49295. */
  49296. static NormalMeshStencilReference: number;
  49297. /**
  49298. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49299. */
  49300. innerGlow: boolean;
  49301. /**
  49302. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49303. */
  49304. outerGlow: boolean;
  49305. /**
  49306. * Specifies the horizontal size of the blur.
  49307. */
  49308. /**
  49309. * Gets the horizontal size of the blur.
  49310. */
  49311. blurHorizontalSize: number;
  49312. /**
  49313. * Specifies the vertical size of the blur.
  49314. */
  49315. /**
  49316. * Gets the vertical size of the blur.
  49317. */
  49318. blurVerticalSize: number;
  49319. /**
  49320. * An event triggered when the highlight layer is being blurred.
  49321. */
  49322. onBeforeBlurObservable: Observable<HighlightLayer>;
  49323. /**
  49324. * An event triggered when the highlight layer has been blurred.
  49325. */
  49326. onAfterBlurObservable: Observable<HighlightLayer>;
  49327. private _instanceGlowingMeshStencilReference;
  49328. private _options;
  49329. private _downSamplePostprocess;
  49330. private _horizontalBlurPostprocess;
  49331. private _verticalBlurPostprocess;
  49332. private _blurTexture;
  49333. private _meshes;
  49334. private _excludedMeshes;
  49335. /**
  49336. * Instantiates a new highlight Layer and references it to the scene..
  49337. * @param name The name of the layer
  49338. * @param scene The scene to use the layer in
  49339. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49340. */
  49341. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49342. /**
  49343. * Get the effect name of the layer.
  49344. * @return The effect name
  49345. */
  49346. getEffectName(): string;
  49347. /**
  49348. * Create the merge effect. This is the shader use to blit the information back
  49349. * to the main canvas at the end of the scene rendering.
  49350. */
  49351. protected _createMergeEffect(): Effect;
  49352. /**
  49353. * Creates the render target textures and post processes used in the highlight layer.
  49354. */
  49355. protected _createTextureAndPostProcesses(): void;
  49356. /**
  49357. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49358. */
  49359. needStencil(): boolean;
  49360. /**
  49361. * Checks for the readiness of the element composing the layer.
  49362. * @param subMesh the mesh to check for
  49363. * @param useInstances specify wether or not to use instances to render the mesh
  49364. * @param emissiveTexture the associated emissive texture used to generate the glow
  49365. * @return true if ready otherwise, false
  49366. */
  49367. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49368. /**
  49369. * Implementation specific of rendering the generating effect on the main canvas.
  49370. * @param effect The effect used to render through
  49371. */
  49372. protected _internalRender(effect: Effect): void;
  49373. /**
  49374. * Returns true if the layer contains information to display, otherwise false.
  49375. */
  49376. shouldRender(): boolean;
  49377. /**
  49378. * Returns true if the mesh should render, otherwise false.
  49379. * @param mesh The mesh to render
  49380. * @returns true if it should render otherwise false
  49381. */
  49382. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49383. /**
  49384. * Sets the required values for both the emissive texture and and the main color.
  49385. */
  49386. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49387. /**
  49388. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49389. * @param mesh The mesh to exclude from the highlight layer
  49390. */
  49391. addExcludedMesh(mesh: Mesh): void;
  49392. /**
  49393. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49394. * @param mesh The mesh to highlight
  49395. */
  49396. removeExcludedMesh(mesh: Mesh): void;
  49397. /**
  49398. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49399. * @param mesh mesh to test
  49400. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49401. */
  49402. hasMesh(mesh: AbstractMesh): boolean;
  49403. /**
  49404. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49405. * @param mesh The mesh to highlight
  49406. * @param color The color of the highlight
  49407. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49408. */
  49409. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49410. /**
  49411. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49412. * @param mesh The mesh to highlight
  49413. */
  49414. removeMesh(mesh: Mesh): void;
  49415. /**
  49416. * Force the stencil to the normal expected value for none glowing parts
  49417. */
  49418. private _defaultStencilReference;
  49419. /**
  49420. * Free any resources and references associated to a mesh.
  49421. * Internal use
  49422. * @param mesh The mesh to free.
  49423. * @hidden
  49424. */ private _disposeMesh(mesh: Mesh): void;
  49425. /**
  49426. * Dispose the highlight layer and free resources.
  49427. */
  49428. dispose(): void;
  49429. /**
  49430. * Gets the class name of the effect layer
  49431. * @returns the string with the class name of the effect layer
  49432. */
  49433. getClassName(): string;
  49434. /**
  49435. * Serializes this Highlight layer
  49436. * @returns a serialized Highlight layer object
  49437. */
  49438. serialize(): any;
  49439. /**
  49440. * Creates a Highlight layer from parsed Highlight layer data
  49441. * @param parsedHightlightLayer defines the Highlight layer data
  49442. * @param scene defines the current scene
  49443. * @param rootUrl defines the root URL containing the Highlight layer information
  49444. * @returns a parsed Highlight layer
  49445. */
  49446. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49447. }
  49448. }
  49449. declare module BABYLON {
  49450. interface AbstractScene {
  49451. /**
  49452. * The list of layers (background and foreground) of the scene
  49453. */
  49454. layers: Array<Layer>;
  49455. }
  49456. /**
  49457. * Defines the layer scene component responsible to manage any layers
  49458. * in a given scene.
  49459. */
  49460. export class LayerSceneComponent implements ISceneComponent {
  49461. /**
  49462. * The component name helpfull to identify the component in the list of scene components.
  49463. */
  49464. readonly name: string;
  49465. /**
  49466. * The scene the component belongs to.
  49467. */
  49468. scene: Scene;
  49469. private _engine;
  49470. /**
  49471. * Creates a new instance of the component for the given scene
  49472. * @param scene Defines the scene to register the component in
  49473. */
  49474. constructor(scene: Scene);
  49475. /**
  49476. * Registers the component in a given scene
  49477. */
  49478. register(): void;
  49479. /**
  49480. * Rebuilds the elements related to this component in case of
  49481. * context lost for instance.
  49482. */
  49483. rebuild(): void;
  49484. /**
  49485. * Disposes the component and the associated ressources.
  49486. */
  49487. dispose(): void;
  49488. private _draw;
  49489. private _drawCameraPredicate;
  49490. private _drawCameraBackground;
  49491. private _drawCameraForeground;
  49492. private _drawRenderTargetPredicate;
  49493. private _drawRenderTargetBackground;
  49494. private _drawRenderTargetForeground;
  49495. /**
  49496. * Adds all the elements from the container to the scene
  49497. * @param container the container holding the elements
  49498. */
  49499. addFromContainer(container: AbstractScene): void;
  49500. /**
  49501. * Removes all the elements in the container from the scene
  49502. * @param container contains the elements to remove
  49503. * @param dispose if the removed element should be disposed (default: false)
  49504. */
  49505. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49506. }
  49507. }
  49508. declare module BABYLON {
  49509. /** @hidden */
  49510. export var layerPixelShader: {
  49511. name: string;
  49512. shader: string;
  49513. };
  49514. }
  49515. declare module BABYLON {
  49516. /** @hidden */
  49517. export var layerVertexShader: {
  49518. name: string;
  49519. shader: string;
  49520. };
  49521. }
  49522. declare module BABYLON {
  49523. /**
  49524. * This represents a full screen 2d layer.
  49525. * This can be useful to display a picture in the background of your scene for instance.
  49526. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49527. */
  49528. export class Layer {
  49529. /**
  49530. * Define the name of the layer.
  49531. */
  49532. name: string;
  49533. /**
  49534. * Define the texture the layer should display.
  49535. */
  49536. texture: Nullable<Texture>;
  49537. /**
  49538. * Is the layer in background or foreground.
  49539. */
  49540. isBackground: boolean;
  49541. /**
  49542. * Define the color of the layer (instead of texture).
  49543. */
  49544. color: Color4;
  49545. /**
  49546. * Define the scale of the layer in order to zoom in out of the texture.
  49547. */
  49548. scale: Vector2;
  49549. /**
  49550. * Define an offset for the layer in order to shift the texture.
  49551. */
  49552. offset: Vector2;
  49553. /**
  49554. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  49555. */
  49556. alphaBlendingMode: number;
  49557. /**
  49558. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  49559. * Alpha test will not mix with the background color in case of transparency.
  49560. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  49561. */
  49562. alphaTest: boolean;
  49563. /**
  49564. * Define a mask to restrict the layer to only some of the scene cameras.
  49565. */
  49566. layerMask: number;
  49567. /**
  49568. * Define the list of render target the layer is visible into.
  49569. */
  49570. renderTargetTextures: RenderTargetTexture[];
  49571. /**
  49572. * Define if the layer is only used in renderTarget or if it also
  49573. * renders in the main frame buffer of the canvas.
  49574. */
  49575. renderOnlyInRenderTargetTextures: boolean;
  49576. private _scene;
  49577. private _vertexBuffers;
  49578. private _indexBuffer;
  49579. private _effect;
  49580. private _alphaTestEffect;
  49581. /**
  49582. * An event triggered when the layer is disposed.
  49583. */
  49584. onDisposeObservable: Observable<Layer>;
  49585. private _onDisposeObserver;
  49586. /**
  49587. * Back compatibility with callback before the onDisposeObservable existed.
  49588. * The set callback will be triggered when the layer has been disposed.
  49589. */
  49590. onDispose: () => void;
  49591. /**
  49592. * An event triggered before rendering the scene
  49593. */
  49594. onBeforeRenderObservable: Observable<Layer>;
  49595. private _onBeforeRenderObserver;
  49596. /**
  49597. * Back compatibility with callback before the onBeforeRenderObservable existed.
  49598. * The set callback will be triggered just before rendering the layer.
  49599. */
  49600. onBeforeRender: () => void;
  49601. /**
  49602. * An event triggered after rendering the scene
  49603. */
  49604. onAfterRenderObservable: Observable<Layer>;
  49605. private _onAfterRenderObserver;
  49606. /**
  49607. * Back compatibility with callback before the onAfterRenderObservable existed.
  49608. * The set callback will be triggered just after rendering the layer.
  49609. */
  49610. onAfterRender: () => void;
  49611. /**
  49612. * Instantiates a new layer.
  49613. * This represents a full screen 2d layer.
  49614. * This can be useful to display a picture in the background of your scene for instance.
  49615. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49616. * @param name Define the name of the layer in the scene
  49617. * @param imgUrl Define the url of the texture to display in the layer
  49618. * @param scene Define the scene the layer belongs to
  49619. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  49620. * @param color Defines a color for the layer
  49621. */
  49622. constructor(
  49623. /**
  49624. * Define the name of the layer.
  49625. */
  49626. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  49627. private _createIndexBuffer;
  49628. /** @hidden */ private _rebuild(): void;
  49629. /**
  49630. * Renders the layer in the scene.
  49631. */
  49632. render(): void;
  49633. /**
  49634. * Disposes and releases the associated ressources.
  49635. */
  49636. dispose(): void;
  49637. }
  49638. }
  49639. declare module BABYLON {
  49640. /** @hidden */
  49641. export var lensFlarePixelShader: {
  49642. name: string;
  49643. shader: string;
  49644. };
  49645. }
  49646. declare module BABYLON {
  49647. /** @hidden */
  49648. export var lensFlareVertexShader: {
  49649. name: string;
  49650. shader: string;
  49651. };
  49652. }
  49653. declare module BABYLON {
  49654. /**
  49655. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49656. * It is usually composed of several `lensFlare`.
  49657. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49658. */
  49659. export class LensFlareSystem {
  49660. /**
  49661. * Define the name of the lens flare system
  49662. */
  49663. name: string;
  49664. /**
  49665. * List of lens flares used in this system.
  49666. */
  49667. lensFlares: LensFlare[];
  49668. /**
  49669. * Define a limit from the border the lens flare can be visible.
  49670. */
  49671. borderLimit: number;
  49672. /**
  49673. * Define a viewport border we do not want to see the lens flare in.
  49674. */
  49675. viewportBorder: number;
  49676. /**
  49677. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49678. */
  49679. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49680. /**
  49681. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49682. */
  49683. layerMask: number;
  49684. /**
  49685. * Define the id of the lens flare system in the scene.
  49686. * (equal to name by default)
  49687. */
  49688. id: string;
  49689. private _scene;
  49690. private _emitter;
  49691. private _vertexBuffers;
  49692. private _indexBuffer;
  49693. private _effect;
  49694. private _positionX;
  49695. private _positionY;
  49696. private _isEnabled;
  49697. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  49698. /**
  49699. * Instantiates a lens flare system.
  49700. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49701. * It is usually composed of several `lensFlare`.
  49702. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49703. * @param name Define the name of the lens flare system in the scene
  49704. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49705. * @param scene Define the scene the lens flare system belongs to
  49706. */
  49707. constructor(
  49708. /**
  49709. * Define the name of the lens flare system
  49710. */
  49711. name: string, emitter: any, scene: Scene);
  49712. /**
  49713. * Define if the lens flare system is enabled.
  49714. */
  49715. isEnabled: boolean;
  49716. /**
  49717. * Get the scene the effects belongs to.
  49718. * @returns the scene holding the lens flare system
  49719. */
  49720. getScene(): Scene;
  49721. /**
  49722. * Get the emitter of the lens flare system.
  49723. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49724. * @returns the emitter of the lens flare system
  49725. */
  49726. getEmitter(): any;
  49727. /**
  49728. * Set the emitter of the lens flare system.
  49729. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49730. * @param newEmitter Define the new emitter of the system
  49731. */
  49732. setEmitter(newEmitter: any): void;
  49733. /**
  49734. * Get the lens flare system emitter position.
  49735. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49736. * @returns the position
  49737. */
  49738. getEmitterPosition(): Vector3;
  49739. /**
  49740. * @hidden
  49741. */
  49742. computeEffectivePosition(globalViewport: Viewport): boolean;
  49743. /** @hidden */ private _isVisible(): boolean;
  49744. /**
  49745. * @hidden
  49746. */
  49747. render(): boolean;
  49748. /**
  49749. * Dispose and release the lens flare with its associated resources.
  49750. */
  49751. dispose(): void;
  49752. /**
  49753. * Parse a lens flare system from a JSON repressentation
  49754. * @param parsedLensFlareSystem Define the JSON to parse
  49755. * @param scene Define the scene the parsed system should be instantiated in
  49756. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49757. * @returns the parsed system
  49758. */
  49759. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49760. /**
  49761. * Serialize the current Lens Flare System into a JSON representation.
  49762. * @returns the serialized JSON
  49763. */
  49764. serialize(): any;
  49765. }
  49766. }
  49767. declare module BABYLON {
  49768. /**
  49769. * This represents one of the lens effect in a `lensFlareSystem`.
  49770. * It controls one of the indiviual texture used in the effect.
  49771. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49772. */
  49773. export class LensFlare {
  49774. /**
  49775. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49776. */
  49777. size: number;
  49778. /**
  49779. * 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.
  49780. */
  49781. position: number;
  49782. /**
  49783. * Define the lens color.
  49784. */
  49785. color: Color3;
  49786. /**
  49787. * Define the lens texture.
  49788. */
  49789. texture: Nullable<Texture>;
  49790. /**
  49791. * Define the alpha mode to render this particular lens.
  49792. */
  49793. alphaMode: number;
  49794. private _system;
  49795. /**
  49796. * Creates a new Lens Flare.
  49797. * This represents one of the lens effect in a `lensFlareSystem`.
  49798. * It controls one of the indiviual texture used in the effect.
  49799. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49800. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49801. * @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.
  49802. * @param color Define the lens color
  49803. * @param imgUrl Define the lens texture url
  49804. * @param system Define the `lensFlareSystem` this flare is part of
  49805. * @returns The newly created Lens Flare
  49806. */
  49807. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49808. /**
  49809. * Instantiates a new Lens Flare.
  49810. * This represents one of the lens effect in a `lensFlareSystem`.
  49811. * It controls one of the indiviual texture used in the effect.
  49812. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49813. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49814. * @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.
  49815. * @param color Define the lens color
  49816. * @param imgUrl Define the lens texture url
  49817. * @param system Define the `lensFlareSystem` this flare is part of
  49818. */
  49819. constructor(
  49820. /**
  49821. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49822. */
  49823. size: number,
  49824. /**
  49825. * 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.
  49826. */
  49827. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49828. /**
  49829. * Dispose and release the lens flare with its associated resources.
  49830. */
  49831. dispose(): void;
  49832. }
  49833. }
  49834. declare module BABYLON {
  49835. interface AbstractScene {
  49836. /**
  49837. * The list of lens flare system added to the scene
  49838. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49839. */
  49840. lensFlareSystems: Array<LensFlareSystem>;
  49841. /**
  49842. * Removes the given lens flare system from this scene.
  49843. * @param toRemove The lens flare system to remove
  49844. * @returns The index of the removed lens flare system
  49845. */
  49846. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49847. /**
  49848. * Adds the given lens flare system to this scene
  49849. * @param newLensFlareSystem The lens flare system to add
  49850. */
  49851. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49852. /**
  49853. * Gets a lens flare system using its name
  49854. * @param name defines the name to look for
  49855. * @returns the lens flare system or null if not found
  49856. */
  49857. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49858. /**
  49859. * Gets a lens flare system using its id
  49860. * @param id defines the id to look for
  49861. * @returns the lens flare system or null if not found
  49862. */
  49863. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49864. }
  49865. /**
  49866. * Defines the lens flare scene component responsible to manage any lens flares
  49867. * in a given scene.
  49868. */
  49869. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49870. /**
  49871. * The component name helpfull to identify the component in the list of scene components.
  49872. */
  49873. readonly name: string;
  49874. /**
  49875. * The scene the component belongs to.
  49876. */
  49877. scene: Scene;
  49878. /**
  49879. * Creates a new instance of the component for the given scene
  49880. * @param scene Defines the scene to register the component in
  49881. */
  49882. constructor(scene: Scene);
  49883. /**
  49884. * Registers the component in a given scene
  49885. */
  49886. register(): void;
  49887. /**
  49888. * Rebuilds the elements related to this component in case of
  49889. * context lost for instance.
  49890. */
  49891. rebuild(): void;
  49892. /**
  49893. * Adds all the elements from the container to the scene
  49894. * @param container the container holding the elements
  49895. */
  49896. addFromContainer(container: AbstractScene): void;
  49897. /**
  49898. * Removes all the elements in the container from the scene
  49899. * @param container contains the elements to remove
  49900. * @param dispose if the removed element should be disposed (default: false)
  49901. */
  49902. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49903. /**
  49904. * Serializes the component data to the specified json object
  49905. * @param serializationObject The object to serialize to
  49906. */
  49907. serialize(serializationObject: any): void;
  49908. /**
  49909. * Disposes the component and the associated ressources.
  49910. */
  49911. dispose(): void;
  49912. private _draw;
  49913. }
  49914. }
  49915. declare module BABYLON {
  49916. /**
  49917. * Defines the shadow generator component responsible to manage any shadow generators
  49918. * in a given scene.
  49919. */
  49920. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49921. /**
  49922. * The component name helpfull to identify the component in the list of scene components.
  49923. */
  49924. readonly name: string;
  49925. /**
  49926. * The scene the component belongs to.
  49927. */
  49928. scene: Scene;
  49929. /**
  49930. * Creates a new instance of the component for the given scene
  49931. * @param scene Defines the scene to register the component in
  49932. */
  49933. constructor(scene: Scene);
  49934. /**
  49935. * Registers the component in a given scene
  49936. */
  49937. register(): void;
  49938. /**
  49939. * Rebuilds the elements related to this component in case of
  49940. * context lost for instance.
  49941. */
  49942. rebuild(): void;
  49943. /**
  49944. * Serializes the component data to the specified json object
  49945. * @param serializationObject The object to serialize to
  49946. */
  49947. serialize(serializationObject: any): void;
  49948. /**
  49949. * Adds all the elements from the container to the scene
  49950. * @param container the container holding the elements
  49951. */
  49952. addFromContainer(container: AbstractScene): void;
  49953. /**
  49954. * Removes all the elements in the container from the scene
  49955. * @param container contains the elements to remove
  49956. * @param dispose if the removed element should be disposed (default: false)
  49957. */
  49958. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49959. /**
  49960. * Rebuilds the elements related to this component in case of
  49961. * context lost for instance.
  49962. */
  49963. dispose(): void;
  49964. private _gatherRenderTargets;
  49965. }
  49966. }
  49967. declare module BABYLON {
  49968. /**
  49969. * A point light is a light defined by an unique point in world space.
  49970. * The light is emitted in every direction from this point.
  49971. * A good example of a point light is a standard light bulb.
  49972. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49973. */
  49974. export class PointLight extends ShadowLight {
  49975. private _shadowAngle;
  49976. /**
  49977. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49978. * This specifies what angle the shadow will use to be created.
  49979. *
  49980. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49981. */
  49982. /**
  49983. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49984. * This specifies what angle the shadow will use to be created.
  49985. *
  49986. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49987. */
  49988. shadowAngle: number;
  49989. /**
  49990. * Gets the direction if it has been set.
  49991. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49992. */
  49993. /**
  49994. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49995. */
  49996. direction: Vector3;
  49997. /**
  49998. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  49999. * A PointLight emits the light in every direction.
  50000. * It can cast shadows.
  50001. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50002. * ```javascript
  50003. * var pointLight = new PointLight("pl", camera.position, scene);
  50004. * ```
  50005. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50006. * @param name The light friendly name
  50007. * @param position The position of the point light in the scene
  50008. * @param scene The scene the lights belongs to
  50009. */
  50010. constructor(name: string, position: Vector3, scene: Scene);
  50011. /**
  50012. * Returns the string "PointLight"
  50013. * @returns the class name
  50014. */
  50015. getClassName(): string;
  50016. /**
  50017. * Returns the integer 0.
  50018. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50019. */
  50020. getTypeID(): number;
  50021. /**
  50022. * Specifies wether or not the shadowmap should be a cube texture.
  50023. * @returns true if the shadowmap needs to be a cube texture.
  50024. */
  50025. needCube(): boolean;
  50026. /**
  50027. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50028. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50029. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50030. */
  50031. getShadowDirection(faceIndex?: number): Vector3;
  50032. /**
  50033. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50034. * - fov = PI / 2
  50035. * - aspect ratio : 1.0
  50036. * - z-near and far equal to the active camera minZ and maxZ.
  50037. * Returns the PointLight.
  50038. */
  50039. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50040. protected _buildUniformLayout(): void;
  50041. /**
  50042. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50043. * @param effect The effect to update
  50044. * @param lightIndex The index of the light in the effect to update
  50045. * @returns The point light
  50046. */
  50047. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50048. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  50049. /**
  50050. * Prepares the list of defines specific to the light type.
  50051. * @param defines the list of defines
  50052. * @param lightIndex defines the index of the light for the effect
  50053. */
  50054. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50055. }
  50056. }
  50057. declare module BABYLON {
  50058. /**
  50059. * Header information of HDR texture files.
  50060. */
  50061. export interface HDRInfo {
  50062. /**
  50063. * The height of the texture in pixels.
  50064. */
  50065. height: number;
  50066. /**
  50067. * The width of the texture in pixels.
  50068. */
  50069. width: number;
  50070. /**
  50071. * The index of the beginning of the data in the binary file.
  50072. */
  50073. dataPosition: number;
  50074. }
  50075. /**
  50076. * This groups tools to convert HDR texture to native colors array.
  50077. */
  50078. export class HDRTools {
  50079. private static Ldexp;
  50080. private static Rgbe2float;
  50081. private static readStringLine;
  50082. /**
  50083. * Reads header information from an RGBE texture stored in a native array.
  50084. * More information on this format are available here:
  50085. * https://en.wikipedia.org/wiki/RGBE_image_format
  50086. *
  50087. * @param uint8array The binary file stored in native array.
  50088. * @return The header information.
  50089. */
  50090. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50091. /**
  50092. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50093. * This RGBE texture needs to store the information as a panorama.
  50094. *
  50095. * More information on this format are available here:
  50096. * https://en.wikipedia.org/wiki/RGBE_image_format
  50097. *
  50098. * @param buffer The binary file stored in an array buffer.
  50099. * @param size The expected size of the extracted cubemap.
  50100. * @return The Cube Map information.
  50101. */
  50102. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50103. /**
  50104. * Returns the pixels data extracted from an RGBE texture.
  50105. * This pixels will be stored left to right up to down in the R G B order in one array.
  50106. *
  50107. * More information on this format are available here:
  50108. * https://en.wikipedia.org/wiki/RGBE_image_format
  50109. *
  50110. * @param uint8array The binary file stored in an array buffer.
  50111. * @param hdrInfo The header information of the file.
  50112. * @return The pixels data in RGB right to left up to down order.
  50113. */
  50114. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50115. private static RGBE_ReadPixels_RLE;
  50116. }
  50117. }
  50118. declare module BABYLON {
  50119. /**
  50120. * This represents a texture coming from an HDR input.
  50121. *
  50122. * The only supported format is currently panorama picture stored in RGBE format.
  50123. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50124. */
  50125. export class HDRCubeTexture extends BaseTexture {
  50126. private static _facesMapping;
  50127. private _generateHarmonics;
  50128. private _noMipmap;
  50129. private _textureMatrix;
  50130. private _size;
  50131. private _onLoad;
  50132. private _onError;
  50133. /**
  50134. * The texture URL.
  50135. */
  50136. url: string;
  50137. /**
  50138. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50139. */
  50140. coordinatesMode: number;
  50141. protected _isBlocking: boolean;
  50142. /**
  50143. * Sets wether or not the texture is blocking during loading.
  50144. */
  50145. /**
  50146. * Gets wether or not the texture is blocking during loading.
  50147. */
  50148. isBlocking: boolean;
  50149. protected _rotationY: number;
  50150. /**
  50151. * Sets texture matrix rotation angle around Y axis in radians.
  50152. */
  50153. /**
  50154. * Gets texture matrix rotation angle around Y axis radians.
  50155. */
  50156. rotationY: number;
  50157. /**
  50158. * Gets or sets the center of the bounding box associated with the cube texture
  50159. * It must define where the camera used to render the texture was set
  50160. */
  50161. boundingBoxPosition: Vector3;
  50162. private _boundingBoxSize;
  50163. /**
  50164. * Gets or sets the size of the bounding box associated with the cube texture
  50165. * When defined, the cubemap will switch to local mode
  50166. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50167. * @example https://www.babylonjs-playground.com/#RNASML
  50168. */
  50169. boundingBoxSize: Vector3;
  50170. /**
  50171. * Instantiates an HDRTexture from the following parameters.
  50172. *
  50173. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50174. * @param scene The scene the texture will be used in
  50175. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50176. * @param noMipmap Forces to not generate the mipmap if true
  50177. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50178. * @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)
  50179. * @param reserved Reserved flag for internal use.
  50180. */
  50181. 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>);
  50182. /**
  50183. * Get the current class name of the texture useful for serialization or dynamic coding.
  50184. * @returns "HDRCubeTexture"
  50185. */
  50186. getClassName(): string;
  50187. /**
  50188. * Occurs when the file is raw .hdr file.
  50189. */
  50190. private loadTexture;
  50191. clone(): HDRCubeTexture;
  50192. delayLoad(): void;
  50193. /**
  50194. * Get the texture reflection matrix used to rotate/transform the reflection.
  50195. * @returns the reflection matrix
  50196. */
  50197. getReflectionTextureMatrix(): Matrix;
  50198. /**
  50199. * Set the texture reflection matrix used to rotate/transform the reflection.
  50200. * @param value Define the reflection matrix to set
  50201. */
  50202. setReflectionTextureMatrix(value: Matrix): void;
  50203. /**
  50204. * Parses a JSON representation of an HDR Texture in order to create the texture
  50205. * @param parsedTexture Define the JSON representation
  50206. * @param scene Define the scene the texture should be created in
  50207. * @param rootUrl Define the root url in case we need to load relative dependencies
  50208. * @returns the newly created texture after parsing
  50209. */
  50210. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50211. serialize(): any;
  50212. }
  50213. }
  50214. declare module BABYLON {
  50215. /**
  50216. * Class used to control physics engine
  50217. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50218. */
  50219. export class PhysicsEngine implements IPhysicsEngine {
  50220. private _physicsPlugin;
  50221. /**
  50222. * Global value used to control the smallest number supported by the simulation
  50223. */
  50224. static Epsilon: number;
  50225. private _impostors;
  50226. private _joints;
  50227. /**
  50228. * Gets the gravity vector used by the simulation
  50229. */
  50230. gravity: Vector3;
  50231. /**
  50232. * Factory used to create the default physics plugin.
  50233. * @returns The default physics plugin
  50234. */
  50235. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50236. /**
  50237. * Creates a new Physics Engine
  50238. * @param gravity defines the gravity vector used by the simulation
  50239. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50240. */
  50241. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50242. /**
  50243. * Sets the gravity vector used by the simulation
  50244. * @param gravity defines the gravity vector to use
  50245. */
  50246. setGravity(gravity: Vector3): void;
  50247. /**
  50248. * Set the time step of the physics engine.
  50249. * Default is 1/60.
  50250. * To slow it down, enter 1/600 for example.
  50251. * To speed it up, 1/30
  50252. * @param newTimeStep defines the new timestep to apply to this world.
  50253. */
  50254. setTimeStep(newTimeStep?: number): void;
  50255. /**
  50256. * Get the time step of the physics engine.
  50257. * @returns the current time step
  50258. */
  50259. getTimeStep(): number;
  50260. /**
  50261. * Release all resources
  50262. */
  50263. dispose(): void;
  50264. /**
  50265. * Gets the name of the current physics plugin
  50266. * @returns the name of the plugin
  50267. */
  50268. getPhysicsPluginName(): string;
  50269. /**
  50270. * Adding a new impostor for the impostor tracking.
  50271. * This will be done by the impostor itself.
  50272. * @param impostor the impostor to add
  50273. */
  50274. addImpostor(impostor: PhysicsImpostor): void;
  50275. /**
  50276. * Remove an impostor from the engine.
  50277. * This impostor and its mesh will not longer be updated by the physics engine.
  50278. * @param impostor the impostor to remove
  50279. */
  50280. removeImpostor(impostor: PhysicsImpostor): void;
  50281. /**
  50282. * Add a joint to the physics engine
  50283. * @param mainImpostor defines the main impostor to which the joint is added.
  50284. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50285. * @param joint defines the joint that will connect both impostors.
  50286. */
  50287. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50288. /**
  50289. * Removes a joint from the simulation
  50290. * @param mainImpostor defines the impostor used with the joint
  50291. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50292. * @param joint defines the joint to remove
  50293. */
  50294. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50295. /**
  50296. * Called by the scene. No need to call it.
  50297. * @param delta defines the timespam between frames
  50298. */ private _step(delta: number): void;
  50299. /**
  50300. * Gets the current plugin used to run the simulation
  50301. * @returns current plugin
  50302. */
  50303. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50304. /**
  50305. * Gets the list of physic impostors
  50306. * @returns an array of PhysicsImpostor
  50307. */
  50308. getImpostors(): Array<PhysicsImpostor>;
  50309. /**
  50310. * Gets the impostor for a physics enabled object
  50311. * @param object defines the object impersonated by the impostor
  50312. * @returns the PhysicsImpostor or null if not found
  50313. */
  50314. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50315. /**
  50316. * Gets the impostor for a physics body object
  50317. * @param body defines physics body used by the impostor
  50318. * @returns the PhysicsImpostor or null if not found
  50319. */
  50320. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50321. /**
  50322. * Does a raycast in the physics world
  50323. * @param from when should the ray start?
  50324. * @param to when should the ray end?
  50325. * @returns PhysicsRaycastResult
  50326. */
  50327. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50328. }
  50329. }
  50330. declare module BABYLON {
  50331. /** @hidden */
  50332. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50333. private _useDeltaForWorldStep;
  50334. world: any;
  50335. name: string;
  50336. private _physicsMaterials;
  50337. private _fixedTimeStep;
  50338. private _cannonRaycastResult;
  50339. private _raycastResult;
  50340. private _physicsBodysToRemoveAfterStep;
  50341. BJSCANNON: any;
  50342. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50343. setGravity(gravity: Vector3): void;
  50344. setTimeStep(timeStep: number): void;
  50345. getTimeStep(): number;
  50346. executeStep(delta: number): void;
  50347. private _removeMarkedPhysicsBodiesFromWorld;
  50348. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50349. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50350. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50351. private _processChildMeshes;
  50352. removePhysicsBody(impostor: PhysicsImpostor): void;
  50353. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50354. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50355. private _addMaterial;
  50356. private _checkWithEpsilon;
  50357. private _createShape;
  50358. private _createHeightmap;
  50359. private _minus90X;
  50360. private _plus90X;
  50361. private _tmpPosition;
  50362. private _tmpDeltaPosition;
  50363. private _tmpUnityRotation;
  50364. private _updatePhysicsBodyTransformation;
  50365. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50366. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50367. isSupported(): boolean;
  50368. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50369. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50370. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50371. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50372. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50373. getBodyMass(impostor: PhysicsImpostor): number;
  50374. getBodyFriction(impostor: PhysicsImpostor): number;
  50375. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50376. getBodyRestitution(impostor: PhysicsImpostor): number;
  50377. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50378. sleepBody(impostor: PhysicsImpostor): void;
  50379. wakeUpBody(impostor: PhysicsImpostor): void;
  50380. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50381. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50382. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50383. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50384. getRadius(impostor: PhysicsImpostor): number;
  50385. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50386. dispose(): void;
  50387. private _extendNamespace;
  50388. /**
  50389. * Does a raycast in the physics world
  50390. * @param from when should the ray start?
  50391. * @param to when should the ray end?
  50392. * @returns PhysicsRaycastResult
  50393. */
  50394. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50395. }
  50396. }
  50397. declare module BABYLON {
  50398. /** @hidden */
  50399. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50400. world: any;
  50401. name: string;
  50402. BJSOIMO: any;
  50403. private _raycastResult;
  50404. constructor(iterations?: number, oimoInjection?: any);
  50405. setGravity(gravity: Vector3): void;
  50406. setTimeStep(timeStep: number): void;
  50407. getTimeStep(): number;
  50408. private _tmpImpostorsArray;
  50409. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50410. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50411. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50412. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50413. private _tmpPositionVector;
  50414. removePhysicsBody(impostor: PhysicsImpostor): void;
  50415. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50416. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50417. isSupported(): boolean;
  50418. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50419. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50420. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50421. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50422. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50423. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50424. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50425. getBodyMass(impostor: PhysicsImpostor): number;
  50426. getBodyFriction(impostor: PhysicsImpostor): number;
  50427. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50428. getBodyRestitution(impostor: PhysicsImpostor): number;
  50429. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50430. sleepBody(impostor: PhysicsImpostor): void;
  50431. wakeUpBody(impostor: PhysicsImpostor): void;
  50432. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50433. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50434. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50435. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50436. getRadius(impostor: PhysicsImpostor): number;
  50437. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50438. dispose(): void;
  50439. /**
  50440. * Does a raycast in the physics world
  50441. * @param from when should the ray start?
  50442. * @param to when should the ray end?
  50443. * @returns PhysicsRaycastResult
  50444. */
  50445. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50446. }
  50447. }
  50448. declare module BABYLON {
  50449. /**
  50450. * Class containing static functions to help procedurally build meshes
  50451. */
  50452. export class RibbonBuilder {
  50453. /**
  50454. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50455. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50456. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50457. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50458. * * 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
  50459. * * 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
  50460. * * 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
  50461. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50462. * * 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
  50463. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50464. * * 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
  50465. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50466. * * 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
  50467. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50468. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50469. * @param name defines the name of the mesh
  50470. * @param options defines the options used to create the mesh
  50471. * @param scene defines the hosting scene
  50472. * @returns the ribbon mesh
  50473. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50474. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50475. */
  50476. static CreateRibbon(name: string, options: {
  50477. pathArray: Vector3[][];
  50478. closeArray?: boolean;
  50479. closePath?: boolean;
  50480. offset?: number;
  50481. updatable?: boolean;
  50482. sideOrientation?: number;
  50483. frontUVs?: Vector4;
  50484. backUVs?: Vector4;
  50485. instance?: Mesh;
  50486. invertUV?: boolean;
  50487. uvs?: Vector2[];
  50488. colors?: Color4[];
  50489. }, scene?: Nullable<Scene>): Mesh;
  50490. }
  50491. }
  50492. declare module BABYLON {
  50493. /**
  50494. * Class containing static functions to help procedurally build meshes
  50495. */
  50496. export class ShapeBuilder {
  50497. /**
  50498. * 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.
  50499. * * 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.
  50500. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50501. * * 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.
  50502. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50503. * * 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
  50504. * * 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
  50505. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50506. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50507. * * 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
  50508. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50510. * @param name defines the name of the mesh
  50511. * @param options defines the options used to create the mesh
  50512. * @param scene defines the hosting scene
  50513. * @returns the extruded shape mesh
  50514. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50515. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50516. */
  50517. static ExtrudeShape(name: string, options: {
  50518. shape: Vector3[];
  50519. path: Vector3[];
  50520. scale?: number;
  50521. rotation?: number;
  50522. cap?: number;
  50523. updatable?: boolean;
  50524. sideOrientation?: number;
  50525. frontUVs?: Vector4;
  50526. backUVs?: Vector4;
  50527. instance?: Mesh;
  50528. invertUV?: boolean;
  50529. }, scene?: Nullable<Scene>): Mesh;
  50530. /**
  50531. * Creates an custom extruded shape mesh.
  50532. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50533. * * 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.
  50534. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50535. * * 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
  50536. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50537. * * 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
  50538. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50539. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50540. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50541. * * 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
  50542. * * 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
  50543. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50544. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50545. * * 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
  50546. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50547. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50548. * @param name defines the name of the mesh
  50549. * @param options defines the options used to create the mesh
  50550. * @param scene defines the hosting scene
  50551. * @returns the custom extruded shape mesh
  50552. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50553. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50554. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50555. */
  50556. static ExtrudeShapeCustom(name: string, options: {
  50557. shape: Vector3[];
  50558. path: Vector3[];
  50559. scaleFunction?: any;
  50560. rotationFunction?: any;
  50561. ribbonCloseArray?: boolean;
  50562. ribbonClosePath?: boolean;
  50563. cap?: number;
  50564. updatable?: boolean;
  50565. sideOrientation?: number;
  50566. frontUVs?: Vector4;
  50567. backUVs?: Vector4;
  50568. instance?: Mesh;
  50569. invertUV?: boolean;
  50570. }, scene?: Nullable<Scene>): Mesh;
  50571. private static _ExtrudeShapeGeneric;
  50572. }
  50573. }
  50574. declare module BABYLON {
  50575. /**
  50576. * AmmoJS Physics plugin
  50577. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50578. * @see https://github.com/kripken/ammo.js/
  50579. */
  50580. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50581. private _useDeltaForWorldStep;
  50582. /**
  50583. * Reference to the Ammo library
  50584. */
  50585. bjsAMMO: any;
  50586. /**
  50587. * Created ammoJS world which physics bodies are added to
  50588. */
  50589. world: any;
  50590. /**
  50591. * Name of the plugin
  50592. */
  50593. name: string;
  50594. private _timeStep;
  50595. private _fixedTimeStep;
  50596. private _maxSteps;
  50597. private _tmpQuaternion;
  50598. private _tmpAmmoTransform;
  50599. private _tmpAmmoQuaternion;
  50600. private _tmpAmmoConcreteContactResultCallback;
  50601. private _collisionConfiguration;
  50602. private _dispatcher;
  50603. private _overlappingPairCache;
  50604. private _solver;
  50605. private _softBodySolver;
  50606. private _tmpAmmoVectorA;
  50607. private _tmpAmmoVectorB;
  50608. private _tmpAmmoVectorC;
  50609. private _tmpAmmoVectorD;
  50610. private _tmpContactCallbackResult;
  50611. private _tmpAmmoVectorRCA;
  50612. private _tmpAmmoVectorRCB;
  50613. private _raycastResult;
  50614. private static readonly DISABLE_COLLISION_FLAG;
  50615. private static readonly KINEMATIC_FLAG;
  50616. private static readonly DISABLE_DEACTIVATION_FLAG;
  50617. /**
  50618. * Initializes the ammoJS plugin
  50619. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50620. * @param ammoInjection can be used to inject your own ammo reference
  50621. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  50622. */
  50623. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  50624. /**
  50625. * Sets the gravity of the physics world (m/(s^2))
  50626. * @param gravity Gravity to set
  50627. */
  50628. setGravity(gravity: Vector3): void;
  50629. /**
  50630. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50631. * @param timeStep timestep to use in seconds
  50632. */
  50633. setTimeStep(timeStep: number): void;
  50634. /**
  50635. * 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)
  50636. * @param fixedTimeStep fixedTimeStep to use in seconds
  50637. */
  50638. setFixedTimeStep(fixedTimeStep: number): void;
  50639. /**
  50640. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50641. * @param maxSteps the maximum number of steps by the physics engine per frame
  50642. */
  50643. setMaxSteps(maxSteps: number): void;
  50644. /**
  50645. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50646. * @returns the current timestep in seconds
  50647. */
  50648. getTimeStep(): number;
  50649. private _isImpostorInContact;
  50650. private _isImpostorPairInContact;
  50651. private _stepSimulation;
  50652. /**
  50653. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50654. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50655. * After the step the babylon meshes are set to the position of the physics imposters
  50656. * @param delta amount of time to step forward
  50657. * @param impostors array of imposters to update before/after the step
  50658. */
  50659. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50660. /**
  50661. * Update babylon mesh to match physics world object
  50662. * @param impostor imposter to match
  50663. */
  50664. private _afterSoftStep;
  50665. /**
  50666. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50667. * @param impostor imposter to match
  50668. */
  50669. private _ropeStep;
  50670. /**
  50671. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50672. * @param impostor imposter to match
  50673. */
  50674. private _softbodyOrClothStep;
  50675. private _tmpVector;
  50676. private _tmpMatrix;
  50677. /**
  50678. * Applies an impulse on the imposter
  50679. * @param impostor imposter to apply impulse to
  50680. * @param force amount of force to be applied to the imposter
  50681. * @param contactPoint the location to apply the impulse on the imposter
  50682. */
  50683. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50684. /**
  50685. * Applies a force on the imposter
  50686. * @param impostor imposter to apply force
  50687. * @param force amount of force to be applied to the imposter
  50688. * @param contactPoint the location to apply the force on the imposter
  50689. */
  50690. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50691. /**
  50692. * Creates a physics body using the plugin
  50693. * @param impostor the imposter to create the physics body on
  50694. */
  50695. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50696. /**
  50697. * Removes the physics body from the imposter and disposes of the body's memory
  50698. * @param impostor imposter to remove the physics body from
  50699. */
  50700. removePhysicsBody(impostor: PhysicsImpostor): void;
  50701. /**
  50702. * Generates a joint
  50703. * @param impostorJoint the imposter joint to create the joint with
  50704. */
  50705. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50706. /**
  50707. * Removes a joint
  50708. * @param impostorJoint the imposter joint to remove the joint from
  50709. */
  50710. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50711. private _addMeshVerts;
  50712. /**
  50713. * Initialise the soft body vertices to match its object's (mesh) vertices
  50714. * Softbody vertices (nodes) are in world space and to match this
  50715. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50716. * @param impostor to create the softbody for
  50717. */
  50718. private _softVertexData;
  50719. /**
  50720. * Create an impostor's soft body
  50721. * @param impostor to create the softbody for
  50722. */
  50723. private _createSoftbody;
  50724. /**
  50725. * Create cloth for an impostor
  50726. * @param impostor to create the softbody for
  50727. */
  50728. private _createCloth;
  50729. /**
  50730. * Create rope for an impostor
  50731. * @param impostor to create the softbody for
  50732. */
  50733. private _createRope;
  50734. private _addHullVerts;
  50735. private _createShape;
  50736. /**
  50737. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50738. * @param impostor imposter containing the physics body and babylon object
  50739. */
  50740. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50741. /**
  50742. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50743. * @param impostor imposter containing the physics body and babylon object
  50744. * @param newPosition new position
  50745. * @param newRotation new rotation
  50746. */
  50747. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50748. /**
  50749. * If this plugin is supported
  50750. * @returns true if its supported
  50751. */
  50752. isSupported(): boolean;
  50753. /**
  50754. * Sets the linear velocity of the physics body
  50755. * @param impostor imposter to set the velocity on
  50756. * @param velocity velocity to set
  50757. */
  50758. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50759. /**
  50760. * Sets the angular velocity of the physics body
  50761. * @param impostor imposter to set the velocity on
  50762. * @param velocity velocity to set
  50763. */
  50764. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50765. /**
  50766. * gets the linear velocity
  50767. * @param impostor imposter to get linear velocity from
  50768. * @returns linear velocity
  50769. */
  50770. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50771. /**
  50772. * gets the angular velocity
  50773. * @param impostor imposter to get angular velocity from
  50774. * @returns angular velocity
  50775. */
  50776. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50777. /**
  50778. * Sets the mass of physics body
  50779. * @param impostor imposter to set the mass on
  50780. * @param mass mass to set
  50781. */
  50782. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50783. /**
  50784. * Gets the mass of the physics body
  50785. * @param impostor imposter to get the mass from
  50786. * @returns mass
  50787. */
  50788. getBodyMass(impostor: PhysicsImpostor): number;
  50789. /**
  50790. * Gets friction of the impostor
  50791. * @param impostor impostor to get friction from
  50792. * @returns friction value
  50793. */
  50794. getBodyFriction(impostor: PhysicsImpostor): number;
  50795. /**
  50796. * Sets friction of the impostor
  50797. * @param impostor impostor to set friction on
  50798. * @param friction friction value
  50799. */
  50800. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50801. /**
  50802. * Gets restitution of the impostor
  50803. * @param impostor impostor to get restitution from
  50804. * @returns restitution value
  50805. */
  50806. getBodyRestitution(impostor: PhysicsImpostor): number;
  50807. /**
  50808. * Sets resitution of the impostor
  50809. * @param impostor impostor to set resitution on
  50810. * @param restitution resitution value
  50811. */
  50812. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50813. /**
  50814. * Gets pressure inside the impostor
  50815. * @param impostor impostor to get pressure from
  50816. * @returns pressure value
  50817. */
  50818. getBodyPressure(impostor: PhysicsImpostor): number;
  50819. /**
  50820. * Sets pressure inside a soft body impostor
  50821. * Cloth and rope must remain 0 pressure
  50822. * @param impostor impostor to set pressure on
  50823. * @param pressure pressure value
  50824. */
  50825. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50826. /**
  50827. * Gets stiffness of the impostor
  50828. * @param impostor impostor to get stiffness from
  50829. * @returns pressure value
  50830. */
  50831. getBodyStiffness(impostor: PhysicsImpostor): number;
  50832. /**
  50833. * Sets stiffness of the impostor
  50834. * @param impostor impostor to set stiffness on
  50835. * @param stiffness stiffness value from 0 to 1
  50836. */
  50837. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50838. /**
  50839. * Gets velocityIterations of the impostor
  50840. * @param impostor impostor to get velocity iterations from
  50841. * @returns velocityIterations value
  50842. */
  50843. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50844. /**
  50845. * Sets velocityIterations of the impostor
  50846. * @param impostor impostor to set velocity iterations on
  50847. * @param velocityIterations velocityIterations value
  50848. */
  50849. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50850. /**
  50851. * Gets positionIterations of the impostor
  50852. * @param impostor impostor to get position iterations from
  50853. * @returns positionIterations value
  50854. */
  50855. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50856. /**
  50857. * Sets positionIterations of the impostor
  50858. * @param impostor impostor to set position on
  50859. * @param positionIterations positionIterations value
  50860. */
  50861. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50862. /**
  50863. * Append an anchor to a cloth object
  50864. * @param impostor is the cloth impostor to add anchor to
  50865. * @param otherImpostor is the rigid impostor to anchor to
  50866. * @param width ratio across width from 0 to 1
  50867. * @param height ratio up height from 0 to 1
  50868. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50869. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50870. */
  50871. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50872. /**
  50873. * Append an hook to a rope object
  50874. * @param impostor is the rope impostor to add hook to
  50875. * @param otherImpostor is the rigid impostor to hook to
  50876. * @param length ratio along the rope from 0 to 1
  50877. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50878. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50879. */
  50880. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50881. /**
  50882. * Sleeps the physics body and stops it from being active
  50883. * @param impostor impostor to sleep
  50884. */
  50885. sleepBody(impostor: PhysicsImpostor): void;
  50886. /**
  50887. * Activates the physics body
  50888. * @param impostor impostor to activate
  50889. */
  50890. wakeUpBody(impostor: PhysicsImpostor): void;
  50891. /**
  50892. * Updates the distance parameters of the joint
  50893. * @param joint joint to update
  50894. * @param maxDistance maximum distance of the joint
  50895. * @param minDistance minimum distance of the joint
  50896. */
  50897. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50898. /**
  50899. * Sets a motor on the joint
  50900. * @param joint joint to set motor on
  50901. * @param speed speed of the motor
  50902. * @param maxForce maximum force of the motor
  50903. * @param motorIndex index of the motor
  50904. */
  50905. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50906. /**
  50907. * Sets the motors limit
  50908. * @param joint joint to set limit on
  50909. * @param upperLimit upper limit
  50910. * @param lowerLimit lower limit
  50911. */
  50912. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50913. /**
  50914. * Syncs the position and rotation of a mesh with the impostor
  50915. * @param mesh mesh to sync
  50916. * @param impostor impostor to update the mesh with
  50917. */
  50918. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50919. /**
  50920. * Gets the radius of the impostor
  50921. * @param impostor impostor to get radius from
  50922. * @returns the radius
  50923. */
  50924. getRadius(impostor: PhysicsImpostor): number;
  50925. /**
  50926. * Gets the box size of the impostor
  50927. * @param impostor impostor to get box size from
  50928. * @param result the resulting box size
  50929. */
  50930. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50931. /**
  50932. * Disposes of the impostor
  50933. */
  50934. dispose(): void;
  50935. /**
  50936. * Does a raycast in the physics world
  50937. * @param from when should the ray start?
  50938. * @param to when should the ray end?
  50939. * @returns PhysicsRaycastResult
  50940. */
  50941. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50942. }
  50943. }
  50944. declare module BABYLON {
  50945. interface AbstractScene {
  50946. /**
  50947. * The list of reflection probes added to the scene
  50948. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50949. */
  50950. reflectionProbes: Array<ReflectionProbe>;
  50951. /**
  50952. * Removes the given reflection probe from this scene.
  50953. * @param toRemove The reflection probe to remove
  50954. * @returns The index of the removed reflection probe
  50955. */
  50956. removeReflectionProbe(toRemove: ReflectionProbe): number;
  50957. /**
  50958. * Adds the given reflection probe to this scene.
  50959. * @param newReflectionProbe The reflection probe to add
  50960. */
  50961. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  50962. }
  50963. /**
  50964. * Class used to generate realtime reflection / refraction cube textures
  50965. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50966. */
  50967. export class ReflectionProbe {
  50968. /** defines the name of the probe */
  50969. name: string;
  50970. private _scene;
  50971. private _renderTargetTexture;
  50972. private _projectionMatrix;
  50973. private _viewMatrix;
  50974. private _target;
  50975. private _add;
  50976. private _attachedMesh;
  50977. private _invertYAxis;
  50978. /** Gets or sets probe position (center of the cube map) */
  50979. position: Vector3;
  50980. /**
  50981. * Creates a new reflection probe
  50982. * @param name defines the name of the probe
  50983. * @param size defines the texture resolution (for each face)
  50984. * @param scene defines the hosting scene
  50985. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  50986. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  50987. */
  50988. constructor(
  50989. /** defines the name of the probe */
  50990. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  50991. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  50992. samples: number;
  50993. /** Gets or sets the refresh rate to use (on every frame by default) */
  50994. refreshRate: number;
  50995. /**
  50996. * Gets the hosting scene
  50997. * @returns a Scene
  50998. */
  50999. getScene(): Scene;
  51000. /** Gets the internal CubeTexture used to render to */
  51001. readonly cubeTexture: RenderTargetTexture;
  51002. /** Gets the list of meshes to render */
  51003. readonly renderList: Nullable<AbstractMesh[]>;
  51004. /**
  51005. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51006. * @param mesh defines the mesh to attach to
  51007. */
  51008. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51009. /**
  51010. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51011. * @param renderingGroupId The rendering group id corresponding to its index
  51012. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51013. */
  51014. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51015. /**
  51016. * Clean all associated resources
  51017. */
  51018. dispose(): void;
  51019. /**
  51020. * Converts the reflection probe information to a readable string for debug purpose.
  51021. * @param fullDetails Supports for multiple levels of logging within scene loading
  51022. * @returns the human readable reflection probe info
  51023. */
  51024. toString(fullDetails?: boolean): string;
  51025. /**
  51026. * Get the class name of the relfection probe.
  51027. * @returns "ReflectionProbe"
  51028. */
  51029. getClassName(): string;
  51030. /**
  51031. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51032. * @returns The JSON representation of the texture
  51033. */
  51034. serialize(): any;
  51035. /**
  51036. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51037. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51038. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51039. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51040. * @returns The parsed reflection probe if successful
  51041. */
  51042. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51043. }
  51044. }
  51045. declare module BABYLON {
  51046. /** @hidden */
  51047. export var _BabylonLoaderRegistered: boolean;
  51048. }
  51049. declare module BABYLON {
  51050. /**
  51051. * The Physically based simple base material of BJS.
  51052. *
  51053. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51054. * It is used as the base class for both the specGloss and metalRough conventions.
  51055. */
  51056. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51057. /**
  51058. * Number of Simultaneous lights allowed on the material.
  51059. */
  51060. maxSimultaneousLights: number;
  51061. /**
  51062. * If sets to true, disables all the lights affecting the material.
  51063. */
  51064. disableLighting: boolean;
  51065. /**
  51066. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51067. */
  51068. environmentTexture: BaseTexture;
  51069. /**
  51070. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51071. */
  51072. invertNormalMapX: boolean;
  51073. /**
  51074. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51075. */
  51076. invertNormalMapY: boolean;
  51077. /**
  51078. * Normal map used in the model.
  51079. */
  51080. normalTexture: BaseTexture;
  51081. /**
  51082. * Emissivie color used to self-illuminate the model.
  51083. */
  51084. emissiveColor: Color3;
  51085. /**
  51086. * Emissivie texture used to self-illuminate the model.
  51087. */
  51088. emissiveTexture: BaseTexture;
  51089. /**
  51090. * Occlusion Channel Strenght.
  51091. */
  51092. occlusionStrength: number;
  51093. /**
  51094. * Occlusion Texture of the material (adding extra occlusion effects).
  51095. */
  51096. occlusionTexture: BaseTexture;
  51097. /**
  51098. * Defines the alpha limits in alpha test mode.
  51099. */
  51100. alphaCutOff: number;
  51101. /**
  51102. * Gets the current double sided mode.
  51103. */
  51104. /**
  51105. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51106. */
  51107. doubleSided: boolean;
  51108. /**
  51109. * Stores the pre-calculated light information of a mesh in a texture.
  51110. */
  51111. lightmapTexture: BaseTexture;
  51112. /**
  51113. * If true, the light map contains occlusion information instead of lighting info.
  51114. */
  51115. useLightmapAsShadowmap: boolean;
  51116. /**
  51117. * Instantiates a new PBRMaterial instance.
  51118. *
  51119. * @param name The material name
  51120. * @param scene The scene the material will be use in.
  51121. */
  51122. constructor(name: string, scene: Scene);
  51123. getClassName(): string;
  51124. }
  51125. }
  51126. declare module BABYLON {
  51127. /**
  51128. * The PBR material of BJS following the metal roughness convention.
  51129. *
  51130. * This fits to the PBR convention in the GLTF definition:
  51131. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51132. */
  51133. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51134. /**
  51135. * The base color has two different interpretations depending on the value of metalness.
  51136. * When the material is a metal, the base color is the specific measured reflectance value
  51137. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51138. * of the material.
  51139. */
  51140. baseColor: Color3;
  51141. /**
  51142. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51143. * well as opacity information in the alpha channel.
  51144. */
  51145. baseTexture: BaseTexture;
  51146. /**
  51147. * Specifies the metallic scalar value of the material.
  51148. * Can also be used to scale the metalness values of the metallic texture.
  51149. */
  51150. metallic: number;
  51151. /**
  51152. * Specifies the roughness scalar value of the material.
  51153. * Can also be used to scale the roughness values of the metallic texture.
  51154. */
  51155. roughness: number;
  51156. /**
  51157. * Texture containing both the metallic value in the B channel and the
  51158. * roughness value in the G channel to keep better precision.
  51159. */
  51160. metallicRoughnessTexture: BaseTexture;
  51161. /**
  51162. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51163. *
  51164. * @param name The material name
  51165. * @param scene The scene the material will be use in.
  51166. */
  51167. constructor(name: string, scene: Scene);
  51168. /**
  51169. * Return the currrent class name of the material.
  51170. */
  51171. getClassName(): string;
  51172. /**
  51173. * Makes a duplicate of the current material.
  51174. * @param name - name to use for the new material.
  51175. */
  51176. clone(name: string): PBRMetallicRoughnessMaterial;
  51177. /**
  51178. * Serialize the material to a parsable JSON object.
  51179. */
  51180. serialize(): any;
  51181. /**
  51182. * Parses a JSON object correponding to the serialize function.
  51183. */
  51184. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51185. }
  51186. }
  51187. declare module BABYLON {
  51188. /**
  51189. * The PBR material of BJS following the specular glossiness convention.
  51190. *
  51191. * This fits to the PBR convention in the GLTF definition:
  51192. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51193. */
  51194. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51195. /**
  51196. * Specifies the diffuse color of the material.
  51197. */
  51198. diffuseColor: Color3;
  51199. /**
  51200. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51201. * channel.
  51202. */
  51203. diffuseTexture: BaseTexture;
  51204. /**
  51205. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51206. */
  51207. specularColor: Color3;
  51208. /**
  51209. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51210. */
  51211. glossiness: number;
  51212. /**
  51213. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51214. */
  51215. specularGlossinessTexture: BaseTexture;
  51216. /**
  51217. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51218. *
  51219. * @param name The material name
  51220. * @param scene The scene the material will be use in.
  51221. */
  51222. constructor(name: string, scene: Scene);
  51223. /**
  51224. * Return the currrent class name of the material.
  51225. */
  51226. getClassName(): string;
  51227. /**
  51228. * Makes a duplicate of the current material.
  51229. * @param name - name to use for the new material.
  51230. */
  51231. clone(name: string): PBRSpecularGlossinessMaterial;
  51232. /**
  51233. * Serialize the material to a parsable JSON object.
  51234. */
  51235. serialize(): any;
  51236. /**
  51237. * Parses a JSON object correponding to the serialize function.
  51238. */
  51239. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51240. }
  51241. }
  51242. declare module BABYLON {
  51243. /**
  51244. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51245. * It can help converting any input color in a desired output one. This can then be used to create effects
  51246. * from sepia, black and white to sixties or futuristic rendering...
  51247. *
  51248. * The only supported format is currently 3dl.
  51249. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51250. */
  51251. export class ColorGradingTexture extends BaseTexture {
  51252. /**
  51253. * The current texture matrix. (will always be identity in color grading texture)
  51254. */
  51255. private _textureMatrix;
  51256. /**
  51257. * The texture URL.
  51258. */
  51259. url: string;
  51260. /**
  51261. * Empty line regex stored for GC.
  51262. */
  51263. private static _noneEmptyLineRegex;
  51264. private _engine;
  51265. /**
  51266. * Instantiates a ColorGradingTexture from the following parameters.
  51267. *
  51268. * @param url The location of the color gradind data (currently only supporting 3dl)
  51269. * @param scene The scene the texture will be used in
  51270. */
  51271. constructor(url: string, scene: Scene);
  51272. /**
  51273. * Returns the texture matrix used in most of the material.
  51274. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51275. */
  51276. getTextureMatrix(): Matrix;
  51277. /**
  51278. * Occurs when the file being loaded is a .3dl LUT file.
  51279. */
  51280. private load3dlTexture;
  51281. /**
  51282. * Starts the loading process of the texture.
  51283. */
  51284. private loadTexture;
  51285. /**
  51286. * Clones the color gradind texture.
  51287. */
  51288. clone(): ColorGradingTexture;
  51289. /**
  51290. * Called during delayed load for textures.
  51291. */
  51292. delayLoad(): void;
  51293. /**
  51294. * Parses a color grading texture serialized by Babylon.
  51295. * @param parsedTexture The texture information being parsedTexture
  51296. * @param scene The scene to load the texture in
  51297. * @param rootUrl The root url of the data assets to load
  51298. * @return A color gradind texture
  51299. */
  51300. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51301. /**
  51302. * Serializes the LUT texture to json format.
  51303. */
  51304. serialize(): any;
  51305. }
  51306. }
  51307. declare module BABYLON {
  51308. /**
  51309. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51310. */
  51311. export class EquiRectangularCubeTexture extends BaseTexture {
  51312. /** The six faces of the cube. */
  51313. private static _FacesMapping;
  51314. private _noMipmap;
  51315. private _onLoad;
  51316. private _onError;
  51317. /** The size of the cubemap. */
  51318. private _size;
  51319. /** The buffer of the image. */
  51320. private _buffer;
  51321. /** The width of the input image. */
  51322. private _width;
  51323. /** The height of the input image. */
  51324. private _height;
  51325. /** The URL to the image. */
  51326. url: string;
  51327. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51328. coordinatesMode: number;
  51329. /**
  51330. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51331. * @param url The location of the image
  51332. * @param scene The scene the texture will be used in
  51333. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51334. * @param noMipmap Forces to not generate the mipmap if true
  51335. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51336. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51337. * @param onLoad — defines a callback called when texture is loaded
  51338. * @param onError — defines a callback called if there is an error
  51339. */
  51340. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51341. /**
  51342. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51343. */
  51344. private loadImage;
  51345. /**
  51346. * Convert the image buffer into a cubemap and create a CubeTexture.
  51347. */
  51348. private loadTexture;
  51349. /**
  51350. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51351. * @param buffer The ArrayBuffer that should be converted.
  51352. * @returns The buffer as Float32Array.
  51353. */
  51354. private getFloat32ArrayFromArrayBuffer;
  51355. /**
  51356. * Get the current class name of the texture useful for serialization or dynamic coding.
  51357. * @returns "EquiRectangularCubeTexture"
  51358. */
  51359. getClassName(): string;
  51360. /**
  51361. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51362. * @returns A clone of the current EquiRectangularCubeTexture.
  51363. */
  51364. clone(): EquiRectangularCubeTexture;
  51365. }
  51366. }
  51367. declare module BABYLON {
  51368. /**
  51369. * Based on jsTGALoader - Javascript loader for TGA file
  51370. * By Vincent Thibault
  51371. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51372. */
  51373. export class TGATools {
  51374. private static _TYPE_INDEXED;
  51375. private static _TYPE_RGB;
  51376. private static _TYPE_GREY;
  51377. private static _TYPE_RLE_INDEXED;
  51378. private static _TYPE_RLE_RGB;
  51379. private static _TYPE_RLE_GREY;
  51380. private static _ORIGIN_MASK;
  51381. private static _ORIGIN_SHIFT;
  51382. private static _ORIGIN_BL;
  51383. private static _ORIGIN_BR;
  51384. private static _ORIGIN_UL;
  51385. private static _ORIGIN_UR;
  51386. /**
  51387. * Gets the header of a TGA file
  51388. * @param data defines the TGA data
  51389. * @returns the header
  51390. */
  51391. static GetTGAHeader(data: Uint8Array): any;
  51392. /**
  51393. * Uploads TGA content to a Babylon Texture
  51394. * @hidden
  51395. */
  51396. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51397. /** @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;
  51398. /** @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;
  51399. /** @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;
  51400. /** @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;
  51401. /** @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;
  51402. /** @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;
  51403. }
  51404. }
  51405. declare module BABYLON {
  51406. /**
  51407. * Implementation of the TGA Texture Loader.
  51408. * @hidden
  51409. */
  51410. export class _TGATextureLoader implements IInternalTextureLoader {
  51411. /**
  51412. * Defines wether the loader supports cascade loading the different faces.
  51413. */
  51414. readonly supportCascades: boolean;
  51415. /**
  51416. * This returns if the loader support the current file information.
  51417. * @param extension defines the file extension of the file being loaded
  51418. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51419. * @param fallback defines the fallback internal texture if any
  51420. * @param isBase64 defines whether the texture is encoded as a base64
  51421. * @param isBuffer defines whether the texture data are stored as a buffer
  51422. * @returns true if the loader can load the specified file
  51423. */
  51424. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51425. /**
  51426. * Transform the url before loading if required.
  51427. * @param rootUrl the url of the texture
  51428. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51429. * @returns the transformed texture
  51430. */
  51431. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51432. /**
  51433. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51434. * @param rootUrl the url of the texture
  51435. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51436. * @returns the fallback texture
  51437. */
  51438. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51439. /**
  51440. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51441. * @param data contains the texture data
  51442. * @param texture defines the BabylonJS internal texture
  51443. * @param createPolynomials will be true if polynomials have been requested
  51444. * @param onLoad defines the callback to trigger once the texture is ready
  51445. * @param onError defines the callback to trigger in case of error
  51446. */
  51447. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51448. /**
  51449. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51450. * @param data contains the texture data
  51451. * @param texture defines the BabylonJS internal texture
  51452. * @param callback defines the method to call once ready to upload
  51453. */
  51454. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51455. }
  51456. }
  51457. declare module BABYLON {
  51458. /**
  51459. * Info about the .basis files
  51460. */
  51461. class BasisFileInfo {
  51462. /**
  51463. * If the file has alpha
  51464. */
  51465. hasAlpha: boolean;
  51466. /**
  51467. * Info about each image of the basis file
  51468. */
  51469. images: Array<{
  51470. levels: Array<{
  51471. width: number;
  51472. height: number;
  51473. transcodedPixels: ArrayBufferView;
  51474. }>;
  51475. }>;
  51476. }
  51477. /**
  51478. * Result of transcoding a basis file
  51479. */
  51480. class TranscodeResult {
  51481. /**
  51482. * Info about the .basis file
  51483. */
  51484. fileInfo: BasisFileInfo;
  51485. /**
  51486. * Format to use when loading the file
  51487. */
  51488. format: number;
  51489. }
  51490. /**
  51491. * Configuration options for the Basis transcoder
  51492. */
  51493. export class BasisTranscodeConfiguration {
  51494. /**
  51495. * Supported compression formats used to determine the supported output format of the transcoder
  51496. */
  51497. supportedCompressionFormats?: {
  51498. /**
  51499. * etc1 compression format
  51500. */
  51501. etc1?: boolean;
  51502. /**
  51503. * s3tc compression format
  51504. */
  51505. s3tc?: boolean;
  51506. /**
  51507. * pvrtc compression format
  51508. */
  51509. pvrtc?: boolean;
  51510. /**
  51511. * etc2 compression format
  51512. */
  51513. etc2?: boolean;
  51514. };
  51515. /**
  51516. * If mipmap levels should be loaded for transcoded images (Default: true)
  51517. */
  51518. loadMipmapLevels?: boolean;
  51519. /**
  51520. * Index of a single image to load (Default: all images)
  51521. */
  51522. loadSingleImage?: number;
  51523. }
  51524. /**
  51525. * Used to load .Basis files
  51526. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  51527. */
  51528. export class BasisTools {
  51529. private static _IgnoreSupportedFormats;
  51530. /**
  51531. * URL to use when loading the basis transcoder
  51532. */
  51533. static JSModuleURL: string;
  51534. /**
  51535. * URL to use when loading the wasm module for the transcoder
  51536. */
  51537. static WasmModuleURL: string;
  51538. /**
  51539. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  51540. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  51541. * @returns internal format corresponding to the Basis format
  51542. */
  51543. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  51544. private static _WorkerPromise;
  51545. private static _Worker;
  51546. private static _actionId;
  51547. private static _CreateWorkerAsync;
  51548. /**
  51549. * Transcodes a loaded image file to compressed pixel data
  51550. * @param imageData image data to transcode
  51551. * @param config configuration options for the transcoding
  51552. * @returns a promise resulting in the transcoded image
  51553. */
  51554. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  51555. /**
  51556. * Loads a texture from the transcode result
  51557. * @param texture texture load to
  51558. * @param transcodeResult the result of transcoding the basis file to load from
  51559. */
  51560. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  51561. }
  51562. }
  51563. declare module BABYLON {
  51564. /**
  51565. * Loader for .basis file format
  51566. */
  51567. export class _BasisTextureLoader implements IInternalTextureLoader {
  51568. /**
  51569. * Defines whether the loader supports cascade loading the different faces.
  51570. */
  51571. readonly supportCascades: boolean;
  51572. /**
  51573. * This returns if the loader support the current file information.
  51574. * @param extension defines the file extension of the file being loaded
  51575. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51576. * @param fallback defines the fallback internal texture if any
  51577. * @param isBase64 defines whether the texture is encoded as a base64
  51578. * @param isBuffer defines whether the texture data are stored as a buffer
  51579. * @returns true if the loader can load the specified file
  51580. */
  51581. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51582. /**
  51583. * Transform the url before loading if required.
  51584. * @param rootUrl the url of the texture
  51585. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51586. * @returns the transformed texture
  51587. */
  51588. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51589. /**
  51590. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51591. * @param rootUrl the url of the texture
  51592. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51593. * @returns the fallback texture
  51594. */
  51595. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51596. /**
  51597. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  51598. * @param data contains the texture data
  51599. * @param texture defines the BabylonJS internal texture
  51600. * @param createPolynomials will be true if polynomials have been requested
  51601. * @param onLoad defines the callback to trigger once the texture is ready
  51602. * @param onError defines the callback to trigger in case of error
  51603. */
  51604. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51605. /**
  51606. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51607. * @param data contains the texture data
  51608. * @param texture defines the BabylonJS internal texture
  51609. * @param callback defines the method to call once ready to upload
  51610. */
  51611. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51612. }
  51613. }
  51614. declare module BABYLON {
  51615. /**
  51616. * 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.
  51617. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51618. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51619. */
  51620. export class CustomProceduralTexture extends ProceduralTexture {
  51621. private _animate;
  51622. private _time;
  51623. private _config;
  51624. private _texturePath;
  51625. /**
  51626. * Instantiates a new Custom Procedural Texture.
  51627. * 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.
  51628. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51629. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51630. * @param name Define the name of the texture
  51631. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51632. * @param size Define the size of the texture to create
  51633. * @param scene Define the scene the texture belongs to
  51634. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51635. * @param generateMipMaps Define if the texture should creates mip maps or not
  51636. */
  51637. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51638. private _loadJson;
  51639. /**
  51640. * Is the texture ready to be used ? (rendered at least once)
  51641. * @returns true if ready, otherwise, false.
  51642. */
  51643. isReady(): boolean;
  51644. /**
  51645. * Render the texture to its associated render target.
  51646. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51647. */
  51648. render(useCameraPostProcess?: boolean): void;
  51649. /**
  51650. * Update the list of dependant textures samplers in the shader.
  51651. */
  51652. updateTextures(): void;
  51653. /**
  51654. * Update the uniform values of the procedural texture in the shader.
  51655. */
  51656. updateShaderUniforms(): void;
  51657. /**
  51658. * Define if the texture animates or not.
  51659. */
  51660. animate: boolean;
  51661. }
  51662. }
  51663. declare module BABYLON {
  51664. /** @hidden */
  51665. export var noisePixelShader: {
  51666. name: string;
  51667. shader: string;
  51668. };
  51669. }
  51670. declare module BABYLON {
  51671. /**
  51672. * Class used to generate noise procedural textures
  51673. */
  51674. export class NoiseProceduralTexture extends ProceduralTexture {
  51675. private _time;
  51676. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51677. brightness: number;
  51678. /** Defines the number of octaves to process */
  51679. octaves: number;
  51680. /** Defines the level of persistence (0.8 by default) */
  51681. persistence: number;
  51682. /** Gets or sets animation speed factor (default is 1) */
  51683. animationSpeedFactor: number;
  51684. /**
  51685. * Creates a new NoiseProceduralTexture
  51686. * @param name defines the name fo the texture
  51687. * @param size defines the size of the texture (default is 256)
  51688. * @param scene defines the hosting scene
  51689. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51690. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51691. */
  51692. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51693. private _updateShaderUniforms;
  51694. protected _getDefines(): string;
  51695. /** Generate the current state of the procedural texture */
  51696. render(useCameraPostProcess?: boolean): void;
  51697. /**
  51698. * Serializes this noise procedural texture
  51699. * @returns a serialized noise procedural texture object
  51700. */
  51701. serialize(): any;
  51702. /**
  51703. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51704. * @param parsedTexture defines parsed texture data
  51705. * @param scene defines the current scene
  51706. * @param rootUrl defines the root URL containing noise procedural texture information
  51707. * @returns a parsed NoiseProceduralTexture
  51708. */
  51709. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51710. }
  51711. }
  51712. declare module BABYLON {
  51713. /**
  51714. * Raw cube texture where the raw buffers are passed in
  51715. */
  51716. export class RawCubeTexture extends CubeTexture {
  51717. /**
  51718. * Creates a cube texture where the raw buffers are passed in.
  51719. * @param scene defines the scene the texture is attached to
  51720. * @param data defines the array of data to use to create each face
  51721. * @param size defines the size of the textures
  51722. * @param format defines the format of the data
  51723. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51724. * @param generateMipMaps defines if the engine should generate the mip levels
  51725. * @param invertY defines if data must be stored with Y axis inverted
  51726. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51727. * @param compression defines the compression used (null by default)
  51728. */
  51729. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51730. /**
  51731. * Updates the raw cube texture.
  51732. * @param data defines the data to store
  51733. * @param format defines the data format
  51734. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51735. * @param invertY defines if data must be stored with Y axis inverted
  51736. * @param compression defines the compression used (null by default)
  51737. * @param level defines which level of the texture to update
  51738. */
  51739. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51740. /**
  51741. * Updates a raw cube texture with RGBD encoded data.
  51742. * @param data defines the array of data [mipmap][face] to use to create each face
  51743. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51744. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51745. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51746. * @returns a promsie that resolves when the operation is complete
  51747. */
  51748. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51749. /**
  51750. * Clones the raw cube texture.
  51751. * @return a new cube texture
  51752. */
  51753. clone(): CubeTexture;
  51754. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51755. }
  51756. }
  51757. declare module BABYLON {
  51758. /**
  51759. * Class used to store 3D textures containing user data
  51760. */
  51761. export class RawTexture3D extends Texture {
  51762. /** Gets or sets the texture format to use */
  51763. format: number;
  51764. private _engine;
  51765. /**
  51766. * Create a new RawTexture3D
  51767. * @param data defines the data of the texture
  51768. * @param width defines the width of the texture
  51769. * @param height defines the height of the texture
  51770. * @param depth defines the depth of the texture
  51771. * @param format defines the texture format to use
  51772. * @param scene defines the hosting scene
  51773. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51774. * @param invertY defines if texture must be stored with Y axis inverted
  51775. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51776. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51777. */
  51778. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51779. /** Gets or sets the texture format to use */
  51780. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51781. /**
  51782. * Update the texture with new data
  51783. * @param data defines the data to store in the texture
  51784. */
  51785. update(data: ArrayBufferView): void;
  51786. }
  51787. }
  51788. declare module BABYLON {
  51789. /**
  51790. * Creates a refraction texture used by refraction channel of the standard material.
  51791. * It is like a mirror but to see through a material.
  51792. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51793. */
  51794. export class RefractionTexture extends RenderTargetTexture {
  51795. /**
  51796. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51797. * 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.
  51798. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51799. */
  51800. refractionPlane: Plane;
  51801. /**
  51802. * Define how deep under the surface we should see.
  51803. */
  51804. depth: number;
  51805. /**
  51806. * Creates a refraction texture used by refraction channel of the standard material.
  51807. * It is like a mirror but to see through a material.
  51808. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51809. * @param name Define the texture name
  51810. * @param size Define the size of the underlying texture
  51811. * @param scene Define the scene the refraction belongs to
  51812. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51813. */
  51814. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51815. /**
  51816. * Clone the refraction texture.
  51817. * @returns the cloned texture
  51818. */
  51819. clone(): RefractionTexture;
  51820. /**
  51821. * Serialize the texture to a JSON representation you could use in Parse later on
  51822. * @returns the serialized JSON representation
  51823. */
  51824. serialize(): any;
  51825. }
  51826. }
  51827. declare module BABYLON {
  51828. /**
  51829. * Defines the options related to the creation of an HtmlElementTexture
  51830. */
  51831. export interface IHtmlElementTextureOptions {
  51832. /**
  51833. * Defines wether mip maps should be created or not.
  51834. */
  51835. generateMipMaps?: boolean;
  51836. /**
  51837. * Defines the sampling mode of the texture.
  51838. */
  51839. samplingMode?: number;
  51840. /**
  51841. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  51842. */
  51843. engine: Nullable<ThinEngine>;
  51844. /**
  51845. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  51846. */
  51847. scene: Nullable<Scene>;
  51848. }
  51849. /**
  51850. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  51851. * To be as efficient as possible depending on your constraints nothing aside the first upload
  51852. * is automatically managed.
  51853. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  51854. * in your application.
  51855. *
  51856. * As the update is not automatic, you need to call them manually.
  51857. */
  51858. export class HtmlElementTexture extends BaseTexture {
  51859. /**
  51860. * The texture URL.
  51861. */
  51862. element: HTMLVideoElement | HTMLCanvasElement;
  51863. private static readonly DefaultOptions;
  51864. private _textureMatrix;
  51865. private _engine;
  51866. private _isVideo;
  51867. private _generateMipMaps;
  51868. private _samplingMode;
  51869. /**
  51870. * Instantiates a HtmlElementTexture from the following parameters.
  51871. *
  51872. * @param name Defines the name of the texture
  51873. * @param element Defines the video or canvas the texture is filled with
  51874. * @param options Defines the other none mandatory texture creation options
  51875. */
  51876. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  51877. private _createInternalTexture;
  51878. /**
  51879. * Returns the texture matrix used in most of the material.
  51880. */
  51881. getTextureMatrix(): Matrix;
  51882. /**
  51883. * Updates the content of the texture.
  51884. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  51885. */
  51886. update(invertY?: Nullable<boolean>): void;
  51887. }
  51888. }
  51889. declare module BABYLON {
  51890. /**
  51891. * Enum used to define the target of a block
  51892. */
  51893. export enum NodeMaterialBlockTargets {
  51894. /** Vertex shader */
  51895. Vertex = 1,
  51896. /** Fragment shader */
  51897. Fragment = 2,
  51898. /** Neutral */
  51899. Neutral = 4,
  51900. /** Vertex and Fragment */
  51901. VertexAndFragment = 3
  51902. }
  51903. }
  51904. declare module BABYLON {
  51905. /**
  51906. * Defines the kind of connection point for node based material
  51907. */
  51908. export enum NodeMaterialBlockConnectionPointTypes {
  51909. /** Float */
  51910. Float = 1,
  51911. /** Int */
  51912. Int = 2,
  51913. /** Vector2 */
  51914. Vector2 = 4,
  51915. /** Vector3 */
  51916. Vector3 = 8,
  51917. /** Vector4 */
  51918. Vector4 = 16,
  51919. /** Color3 */
  51920. Color3 = 32,
  51921. /** Color4 */
  51922. Color4 = 64,
  51923. /** Matrix */
  51924. Matrix = 128,
  51925. /** Detect type based on connection */
  51926. AutoDetect = 1024,
  51927. /** Output type that will be defined by input type */
  51928. BasedOnInput = 2048
  51929. }
  51930. }
  51931. declare module BABYLON {
  51932. /**
  51933. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  51934. */
  51935. export enum NodeMaterialBlockConnectionPointMode {
  51936. /** Value is an uniform */
  51937. Uniform = 0,
  51938. /** Value is a mesh attribute */
  51939. Attribute = 1,
  51940. /** Value is a varying between vertex and fragment shaders */
  51941. Varying = 2,
  51942. /** Mode is undefined */
  51943. Undefined = 3
  51944. }
  51945. }
  51946. declare module BABYLON {
  51947. /**
  51948. * Enum used to define system values e.g. values automatically provided by the system
  51949. */
  51950. export enum NodeMaterialSystemValues {
  51951. /** World */
  51952. World = 1,
  51953. /** View */
  51954. View = 2,
  51955. /** Projection */
  51956. Projection = 3,
  51957. /** ViewProjection */
  51958. ViewProjection = 4,
  51959. /** WorldView */
  51960. WorldView = 5,
  51961. /** WorldViewProjection */
  51962. WorldViewProjection = 6,
  51963. /** CameraPosition */
  51964. CameraPosition = 7,
  51965. /** Fog Color */
  51966. FogColor = 8,
  51967. /** Delta time */
  51968. DeltaTime = 9
  51969. }
  51970. }
  51971. declare module BABYLON {
  51972. /**
  51973. * Root class for all node material optimizers
  51974. */
  51975. export class NodeMaterialOptimizer {
  51976. /**
  51977. * Function used to optimize a NodeMaterial graph
  51978. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  51979. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  51980. */
  51981. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  51982. }
  51983. }
  51984. declare module BABYLON {
  51985. /**
  51986. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  51987. */
  51988. export class TransformBlock extends NodeMaterialBlock {
  51989. /**
  51990. * Defines the value to use to complement W value to transform it to a Vector4
  51991. */
  51992. complementW: number;
  51993. /**
  51994. * Defines the value to use to complement z value to transform it to a Vector4
  51995. */
  51996. complementZ: number;
  51997. /**
  51998. * Creates a new TransformBlock
  51999. * @param name defines the block name
  52000. */
  52001. constructor(name: string);
  52002. /**
  52003. * Gets the current class name
  52004. * @returns the class name
  52005. */
  52006. getClassName(): string;
  52007. /**
  52008. * Gets the vector input
  52009. */
  52010. readonly vector: NodeMaterialConnectionPoint;
  52011. /**
  52012. * Gets the output component
  52013. */
  52014. readonly output: NodeMaterialConnectionPoint;
  52015. /**
  52016. * Gets the matrix transform input
  52017. */
  52018. readonly transform: NodeMaterialConnectionPoint;
  52019. protected _buildBlock(state: NodeMaterialBuildState): this;
  52020. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52021. protected _dumpPropertiesCode(): string;
  52022. }
  52023. }
  52024. declare module BABYLON {
  52025. /**
  52026. * Block used to output the vertex position
  52027. */
  52028. export class VertexOutputBlock extends NodeMaterialBlock {
  52029. /**
  52030. * Creates a new VertexOutputBlock
  52031. * @param name defines the block name
  52032. */
  52033. constructor(name: string);
  52034. /**
  52035. * Gets the current class name
  52036. * @returns the class name
  52037. */
  52038. getClassName(): string;
  52039. /**
  52040. * Gets the vector input component
  52041. */
  52042. readonly vector: NodeMaterialConnectionPoint;
  52043. protected _buildBlock(state: NodeMaterialBuildState): this;
  52044. }
  52045. }
  52046. declare module BABYLON {
  52047. /**
  52048. * Block used to output the final color
  52049. */
  52050. export class FragmentOutputBlock extends NodeMaterialBlock {
  52051. /**
  52052. * Create a new FragmentOutputBlock
  52053. * @param name defines the block name
  52054. */
  52055. constructor(name: string);
  52056. /**
  52057. * Gets the current class name
  52058. * @returns the class name
  52059. */
  52060. getClassName(): string;
  52061. /**
  52062. * Gets the rgba input component
  52063. */
  52064. readonly rgba: NodeMaterialConnectionPoint;
  52065. /**
  52066. * Gets the rgb input component
  52067. */
  52068. readonly rgb: NodeMaterialConnectionPoint;
  52069. /**
  52070. * Gets the a input component
  52071. */
  52072. readonly a: NodeMaterialConnectionPoint;
  52073. protected _buildBlock(state: NodeMaterialBuildState): this;
  52074. }
  52075. }
  52076. declare module BABYLON {
  52077. /**
  52078. * Block used to read a reflection texture from a sampler
  52079. */
  52080. export class ReflectionTextureBlock extends NodeMaterialBlock {
  52081. private _define3DName;
  52082. private _defineCubicName;
  52083. private _defineExplicitName;
  52084. private _defineProjectionName;
  52085. private _defineLocalCubicName;
  52086. private _defineSphericalName;
  52087. private _definePlanarName;
  52088. private _defineEquirectangularName;
  52089. private _defineMirroredEquirectangularFixedName;
  52090. private _defineEquirectangularFixedName;
  52091. private _defineSkyboxName;
  52092. private _cubeSamplerName;
  52093. private _2DSamplerName;
  52094. private _positionUVWName;
  52095. private _directionWName;
  52096. private _reflectionCoordsName;
  52097. private _reflection2DCoordsName;
  52098. private _reflectionColorName;
  52099. private _reflectionMatrixName;
  52100. /**
  52101. * Gets or sets the texture associated with the node
  52102. */
  52103. texture: Nullable<BaseTexture>;
  52104. /**
  52105. * Create a new TextureBlock
  52106. * @param name defines the block name
  52107. */
  52108. constructor(name: string);
  52109. /**
  52110. * Gets the current class name
  52111. * @returns the class name
  52112. */
  52113. getClassName(): string;
  52114. /**
  52115. * Gets the world position input component
  52116. */
  52117. readonly position: NodeMaterialConnectionPoint;
  52118. /**
  52119. * Gets the world position input component
  52120. */
  52121. readonly worldPosition: NodeMaterialConnectionPoint;
  52122. /**
  52123. * Gets the world normal input component
  52124. */
  52125. readonly worldNormal: NodeMaterialConnectionPoint;
  52126. /**
  52127. * Gets the world input component
  52128. */
  52129. readonly world: NodeMaterialConnectionPoint;
  52130. /**
  52131. * Gets the camera (or eye) position component
  52132. */
  52133. readonly cameraPosition: NodeMaterialConnectionPoint;
  52134. /**
  52135. * Gets the view input component
  52136. */
  52137. readonly view: NodeMaterialConnectionPoint;
  52138. /**
  52139. * Gets the rgb output component
  52140. */
  52141. readonly rgb: NodeMaterialConnectionPoint;
  52142. /**
  52143. * Gets the r output component
  52144. */
  52145. readonly r: NodeMaterialConnectionPoint;
  52146. /**
  52147. * Gets the g output component
  52148. */
  52149. readonly g: NodeMaterialConnectionPoint;
  52150. /**
  52151. * Gets the b output component
  52152. */
  52153. readonly b: NodeMaterialConnectionPoint;
  52154. autoConfigure(material: NodeMaterial): void;
  52155. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52156. isReady(): boolean;
  52157. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52158. private _injectVertexCode;
  52159. private _writeOutput;
  52160. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52161. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52162. }
  52163. }
  52164. declare module BABYLON {
  52165. /**
  52166. * Interface used to configure the node material editor
  52167. */
  52168. export interface INodeMaterialEditorOptions {
  52169. /** Define the URl to load node editor script */
  52170. editorURL?: string;
  52171. }
  52172. /** @hidden */
  52173. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  52174. /** BONES */
  52175. NUM_BONE_INFLUENCERS: number;
  52176. BonesPerMesh: number;
  52177. BONETEXTURE: boolean;
  52178. /** MORPH TARGETS */
  52179. MORPHTARGETS: boolean;
  52180. MORPHTARGETS_NORMAL: boolean;
  52181. MORPHTARGETS_TANGENT: boolean;
  52182. MORPHTARGETS_UV: boolean;
  52183. NUM_MORPH_INFLUENCERS: number;
  52184. /** IMAGE PROCESSING */
  52185. IMAGEPROCESSING: boolean;
  52186. VIGNETTE: boolean;
  52187. VIGNETTEBLENDMODEMULTIPLY: boolean;
  52188. VIGNETTEBLENDMODEOPAQUE: boolean;
  52189. TONEMAPPING: boolean;
  52190. TONEMAPPING_ACES: boolean;
  52191. CONTRAST: boolean;
  52192. EXPOSURE: boolean;
  52193. COLORCURVES: boolean;
  52194. COLORGRADING: boolean;
  52195. COLORGRADING3D: boolean;
  52196. SAMPLER3DGREENDEPTH: boolean;
  52197. SAMPLER3DBGRMAP: boolean;
  52198. IMAGEPROCESSINGPOSTPROCESS: boolean;
  52199. /** MISC. */
  52200. BUMPDIRECTUV: number;
  52201. constructor();
  52202. setValue(name: string, value: boolean): void;
  52203. }
  52204. /**
  52205. * Class used to configure NodeMaterial
  52206. */
  52207. export interface INodeMaterialOptions {
  52208. /**
  52209. * Defines if blocks should emit comments
  52210. */
  52211. emitComments: boolean;
  52212. }
  52213. /**
  52214. * Class used to create a node based material built by assembling shader blocks
  52215. */
  52216. export class NodeMaterial extends PushMaterial {
  52217. private static _BuildIdGenerator;
  52218. private _options;
  52219. private _vertexCompilationState;
  52220. private _fragmentCompilationState;
  52221. private _sharedData;
  52222. private _buildId;
  52223. private _buildWasSuccessful;
  52224. private _cachedWorldViewMatrix;
  52225. private _cachedWorldViewProjectionMatrix;
  52226. private _optimizers;
  52227. private _animationFrame;
  52228. /** Define the URl to load node editor script */
  52229. static EditorURL: string;
  52230. private BJSNODEMATERIALEDITOR;
  52231. /** Get the inspector from bundle or global */
  52232. private _getGlobalNodeMaterialEditor;
  52233. /**
  52234. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  52235. */
  52236. ignoreAlpha: boolean;
  52237. /**
  52238. * Defines the maximum number of lights that can be used in the material
  52239. */
  52240. maxSimultaneousLights: number;
  52241. /**
  52242. * Observable raised when the material is built
  52243. */
  52244. onBuildObservable: Observable<NodeMaterial>;
  52245. /**
  52246. * Gets or sets the root nodes of the material vertex shader
  52247. */ private _vertexOutputNodes: NodeMaterialBlock[];
  52248. /**
  52249. * Gets or sets the root nodes of the material fragment (pixel) shader
  52250. */ private _fragmentOutputNodes: NodeMaterialBlock[];
  52251. /** Gets or sets options to control the node material overall behavior */
  52252. options: INodeMaterialOptions;
  52253. /**
  52254. * Default configuration related to image processing available in the standard Material.
  52255. */
  52256. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52257. /**
  52258. * Gets the image processing configuration used either in this material.
  52259. */
  52260. /**
  52261. * Sets the Default image processing configuration used either in the this material.
  52262. *
  52263. * If sets to null, the scene one is in use.
  52264. */
  52265. imageProcessingConfiguration: ImageProcessingConfiguration;
  52266. /**
  52267. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  52268. */
  52269. attachedBlocks: NodeMaterialBlock[];
  52270. /**
  52271. * Create a new node based material
  52272. * @param name defines the material name
  52273. * @param scene defines the hosting scene
  52274. * @param options defines creation option
  52275. */
  52276. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  52277. /**
  52278. * Gets the current class name of the material e.g. "NodeMaterial"
  52279. * @returns the class name
  52280. */
  52281. getClassName(): string;
  52282. /**
  52283. * Keep track of the image processing observer to allow dispose and replace.
  52284. */
  52285. private _imageProcessingObserver;
  52286. /**
  52287. * Attaches a new image processing configuration to the Standard Material.
  52288. * @param configuration
  52289. */
  52290. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52291. /**
  52292. * Get a block by its name
  52293. * @param name defines the name of the block to retrieve
  52294. * @returns the required block or null if not found
  52295. */
  52296. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  52297. /**
  52298. * Get a block by its name
  52299. * @param predicate defines the predicate used to find the good candidate
  52300. * @returns the required block or null if not found
  52301. */
  52302. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  52303. /**
  52304. * Get an input block by its name
  52305. * @param predicate defines the predicate used to find the good candidate
  52306. * @returns the required input block or null if not found
  52307. */
  52308. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  52309. /**
  52310. * Gets the list of input blocks attached to this material
  52311. * @returns an array of InputBlocks
  52312. */
  52313. getInputBlocks(): InputBlock[];
  52314. /**
  52315. * Adds a new optimizer to the list of optimizers
  52316. * @param optimizer defines the optimizers to add
  52317. * @returns the current material
  52318. */
  52319. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52320. /**
  52321. * Remove an optimizer from the list of optimizers
  52322. * @param optimizer defines the optimizers to remove
  52323. * @returns the current material
  52324. */
  52325. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52326. /**
  52327. * Add a new block to the list of output nodes
  52328. * @param node defines the node to add
  52329. * @returns the current material
  52330. */
  52331. addOutputNode(node: NodeMaterialBlock): this;
  52332. /**
  52333. * Remove a block from the list of root nodes
  52334. * @param node defines the node to remove
  52335. * @returns the current material
  52336. */
  52337. removeOutputNode(node: NodeMaterialBlock): this;
  52338. private _addVertexOutputNode;
  52339. private _removeVertexOutputNode;
  52340. private _addFragmentOutputNode;
  52341. private _removeFragmentOutputNode;
  52342. /**
  52343. * Specifies if the material will require alpha blending
  52344. * @returns a boolean specifying if alpha blending is needed
  52345. */
  52346. needAlphaBlending(): boolean;
  52347. /**
  52348. * Specifies if this material should be rendered in alpha test mode
  52349. * @returns a boolean specifying if an alpha test is needed.
  52350. */
  52351. needAlphaTesting(): boolean;
  52352. private _initializeBlock;
  52353. private _resetDualBlocks;
  52354. /**
  52355. * Build the material and generates the inner effect
  52356. * @param verbose defines if the build should log activity
  52357. */
  52358. build(verbose?: boolean): void;
  52359. /**
  52360. * Runs an otpimization phase to try to improve the shader code
  52361. */
  52362. optimize(): void;
  52363. private _prepareDefinesForAttributes;
  52364. /**
  52365. * Get if the submesh is ready to be used and all its information available.
  52366. * Child classes can use it to update shaders
  52367. * @param mesh defines the mesh to check
  52368. * @param subMesh defines which submesh to check
  52369. * @param useInstances specifies that instances should be used
  52370. * @returns a boolean indicating that the submesh is ready or not
  52371. */
  52372. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52373. /**
  52374. * Get a string representing the shaders built by the current node graph
  52375. */
  52376. readonly compiledShaders: string;
  52377. /**
  52378. * Binds the world matrix to the material
  52379. * @param world defines the world transformation matrix
  52380. */
  52381. bindOnlyWorldMatrix(world: Matrix): void;
  52382. /**
  52383. * Binds the submesh to this material by preparing the effect and shader to draw
  52384. * @param world defines the world transformation matrix
  52385. * @param mesh defines the mesh containing the submesh
  52386. * @param subMesh defines the submesh to bind the material to
  52387. */
  52388. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52389. /**
  52390. * Gets the active textures from the material
  52391. * @returns an array of textures
  52392. */
  52393. getActiveTextures(): BaseTexture[];
  52394. /**
  52395. * Gets the list of texture blocks
  52396. * @returns an array of texture blocks
  52397. */
  52398. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  52399. /**
  52400. * Specifies if the material uses a texture
  52401. * @param texture defines the texture to check against the material
  52402. * @returns a boolean specifying if the material uses the texture
  52403. */
  52404. hasTexture(texture: BaseTexture): boolean;
  52405. /**
  52406. * Disposes the material
  52407. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  52408. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  52409. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  52410. */
  52411. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  52412. /** Creates the node editor window. */
  52413. private _createNodeEditor;
  52414. /**
  52415. * Launch the node material editor
  52416. * @param config Define the configuration of the editor
  52417. * @return a promise fulfilled when the node editor is visible
  52418. */
  52419. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  52420. /**
  52421. * Clear the current material
  52422. */
  52423. clear(): void;
  52424. /**
  52425. * Clear the current material and set it to a default state
  52426. */
  52427. setToDefault(): void;
  52428. /**
  52429. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  52430. * @param url defines the url to load from
  52431. * @returns a promise that will fullfil when the material is fully loaded
  52432. */
  52433. loadAsync(url: string): Promise<void>;
  52434. private _gatherBlocks;
  52435. /**
  52436. * Generate a string containing the code declaration required to create an equivalent of this material
  52437. * @returns a string
  52438. */
  52439. generateCode(): string;
  52440. /**
  52441. * Serializes this material in a JSON representation
  52442. * @returns the serialized material object
  52443. */
  52444. serialize(): any;
  52445. private _restoreConnections;
  52446. /**
  52447. * Clear the current graph and load a new one from a serialization object
  52448. * @param source defines the JSON representation of the material
  52449. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52450. */
  52451. loadFromSerialization(source: any, rootUrl?: string): void;
  52452. /**
  52453. * Creates a node material from parsed material data
  52454. * @param source defines the JSON representation of the material
  52455. * @param scene defines the hosting scene
  52456. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52457. * @returns a new node material
  52458. */
  52459. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  52460. /**
  52461. * Creates a new node material set to default basic configuration
  52462. * @param name defines the name of the material
  52463. * @param scene defines the hosting scene
  52464. * @returns a new NodeMaterial
  52465. */
  52466. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  52467. }
  52468. }
  52469. declare module BABYLON {
  52470. /**
  52471. * Block used to read a texture from a sampler
  52472. */
  52473. export class TextureBlock extends NodeMaterialBlock {
  52474. private _defineName;
  52475. private _linearDefineName;
  52476. private _samplerName;
  52477. private _transformedUVName;
  52478. private _textureTransformName;
  52479. private _textureInfoName;
  52480. private _mainUVName;
  52481. private _mainUVDefineName;
  52482. /**
  52483. * Gets or sets the texture associated with the node
  52484. */
  52485. texture: Nullable<Texture>;
  52486. /**
  52487. * Create a new TextureBlock
  52488. * @param name defines the block name
  52489. */
  52490. constructor(name: string);
  52491. /**
  52492. * Gets the current class name
  52493. * @returns the class name
  52494. */
  52495. getClassName(): string;
  52496. /**
  52497. * Gets the uv input component
  52498. */
  52499. readonly uv: NodeMaterialConnectionPoint;
  52500. /**
  52501. * Gets the rgba output component
  52502. */
  52503. readonly rgba: NodeMaterialConnectionPoint;
  52504. /**
  52505. * Gets the rgb output component
  52506. */
  52507. readonly rgb: NodeMaterialConnectionPoint;
  52508. /**
  52509. * Gets the r output component
  52510. */
  52511. readonly r: NodeMaterialConnectionPoint;
  52512. /**
  52513. * Gets the g output component
  52514. */
  52515. readonly g: NodeMaterialConnectionPoint;
  52516. /**
  52517. * Gets the b output component
  52518. */
  52519. readonly b: NodeMaterialConnectionPoint;
  52520. /**
  52521. * Gets the a output component
  52522. */
  52523. readonly a: NodeMaterialConnectionPoint;
  52524. readonly target: NodeMaterialBlockTargets;
  52525. autoConfigure(material: NodeMaterial): void;
  52526. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52527. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52528. isReady(): boolean;
  52529. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52530. private readonly _isMixed;
  52531. private _injectVertexCode;
  52532. private _writeOutput;
  52533. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52534. protected _dumpPropertiesCode(): string;
  52535. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52536. }
  52537. }
  52538. declare module BABYLON {
  52539. /**
  52540. * Class used to store shared data between 2 NodeMaterialBuildState
  52541. */
  52542. export class NodeMaterialBuildStateSharedData {
  52543. /**
  52544. * Gets the list of emitted varyings
  52545. */
  52546. temps: string[];
  52547. /**
  52548. * Gets the list of emitted varyings
  52549. */
  52550. varyings: string[];
  52551. /**
  52552. * Gets the varying declaration string
  52553. */
  52554. varyingDeclaration: string;
  52555. /**
  52556. * Input blocks
  52557. */
  52558. inputBlocks: InputBlock[];
  52559. /**
  52560. * Input blocks
  52561. */
  52562. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  52563. /**
  52564. * Bindable blocks (Blocks that need to set data to the effect)
  52565. */
  52566. bindableBlocks: NodeMaterialBlock[];
  52567. /**
  52568. * List of blocks that can provide a compilation fallback
  52569. */
  52570. blocksWithFallbacks: NodeMaterialBlock[];
  52571. /**
  52572. * List of blocks that can provide a define update
  52573. */
  52574. blocksWithDefines: NodeMaterialBlock[];
  52575. /**
  52576. * List of blocks that can provide a repeatable content
  52577. */
  52578. repeatableContentBlocks: NodeMaterialBlock[];
  52579. /**
  52580. * List of blocks that can provide a dynamic list of uniforms
  52581. */
  52582. dynamicUniformBlocks: NodeMaterialBlock[];
  52583. /**
  52584. * List of blocks that can block the isReady function for the material
  52585. */
  52586. blockingBlocks: NodeMaterialBlock[];
  52587. /**
  52588. * Gets the list of animated inputs
  52589. */
  52590. animatedInputs: InputBlock[];
  52591. /**
  52592. * Build Id used to avoid multiple recompilations
  52593. */
  52594. buildId: number;
  52595. /** List of emitted variables */
  52596. variableNames: {
  52597. [key: string]: number;
  52598. };
  52599. /** List of emitted defines */
  52600. defineNames: {
  52601. [key: string]: number;
  52602. };
  52603. /** Should emit comments? */
  52604. emitComments: boolean;
  52605. /** Emit build activity */
  52606. verbose: boolean;
  52607. /** Gets or sets the hosting scene */
  52608. scene: Scene;
  52609. /**
  52610. * Gets the compilation hints emitted at compilation time
  52611. */
  52612. hints: {
  52613. needWorldViewMatrix: boolean;
  52614. needWorldViewProjectionMatrix: boolean;
  52615. needAlphaBlending: boolean;
  52616. needAlphaTesting: boolean;
  52617. };
  52618. /**
  52619. * List of compilation checks
  52620. */
  52621. checks: {
  52622. emitVertex: boolean;
  52623. emitFragment: boolean;
  52624. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  52625. };
  52626. /** Creates a new shared data */
  52627. constructor();
  52628. /**
  52629. * Emits console errors and exceptions if there is a failing check
  52630. */
  52631. emitErrors(): void;
  52632. }
  52633. }
  52634. declare module BABYLON {
  52635. /**
  52636. * Class used to store node based material build state
  52637. */
  52638. export class NodeMaterialBuildState {
  52639. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  52640. supportUniformBuffers: boolean;
  52641. /**
  52642. * Gets the list of emitted attributes
  52643. */
  52644. attributes: string[];
  52645. /**
  52646. * Gets the list of emitted uniforms
  52647. */
  52648. uniforms: string[];
  52649. /**
  52650. * Gets the list of emitted constants
  52651. */
  52652. constants: string[];
  52653. /**
  52654. * Gets the list of emitted samplers
  52655. */
  52656. samplers: string[];
  52657. /**
  52658. * Gets the list of emitted functions
  52659. */
  52660. functions: {
  52661. [key: string]: string;
  52662. };
  52663. /**
  52664. * Gets the list of emitted extensions
  52665. */
  52666. extensions: {
  52667. [key: string]: string;
  52668. };
  52669. /**
  52670. * Gets the target of the compilation state
  52671. */
  52672. target: NodeMaterialBlockTargets;
  52673. /**
  52674. * Gets the list of emitted counters
  52675. */
  52676. counters: {
  52677. [key: string]: number;
  52678. };
  52679. /**
  52680. * Shared data between multiple NodeMaterialBuildState instances
  52681. */
  52682. sharedData: NodeMaterialBuildStateSharedData;
  52683. /** @hidden */ private _vertexState: NodeMaterialBuildState;
  52684. /** @hidden */ private _attributeDeclaration: string;
  52685. /** @hidden */ private _uniformDeclaration: string;
  52686. /** @hidden */ private _constantDeclaration: string;
  52687. /** @hidden */ private _samplerDeclaration: string;
  52688. /** @hidden */ private _varyingTransfer: string;
  52689. private _repeatableContentAnchorIndex;
  52690. /** @hidden */ private _builtCompilationString: string;
  52691. /**
  52692. * Gets the emitted compilation strings
  52693. */
  52694. compilationString: string;
  52695. /**
  52696. * Finalize the compilation strings
  52697. * @param state defines the current compilation state
  52698. */
  52699. finalize(state: NodeMaterialBuildState): void;
  52700. /** @hidden */ protected readonly _repeatableContentAnchor: string;
  52701. /** @hidden */ private _getFreeVariableName(prefix: string): string;
  52702. /** @hidden */ private _getFreeDefineName(prefix: string): string;
  52703. /** @hidden */ private _excludeVariableName(name: string): void;
  52704. /** @hidden */ private _emit2DSampler(name: string): void;
  52705. /** @hidden */ private _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  52706. /** @hidden */ private _emitExtension(name: string, extension: string): void;
  52707. /** @hidden */ private _emitFunction(name: string, code: string, comments: string): void;
  52708. /** @hidden */ private _emitCodeFromInclude(includeName: string, comments: string, options?: {
  52709. replaceStrings?: {
  52710. search: RegExp;
  52711. replace: string;
  52712. }[];
  52713. repeatKey?: string;
  52714. }): string;
  52715. /** @hidden */ private _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  52716. repeatKey?: string;
  52717. removeAttributes?: boolean;
  52718. removeUniforms?: boolean;
  52719. removeVaryings?: boolean;
  52720. removeIfDef?: boolean;
  52721. replaceStrings?: {
  52722. search: RegExp;
  52723. replace: string;
  52724. }[];
  52725. }, storeKey?: string): void;
  52726. /** @hidden */ private _registerTempVariable(name: string): boolean;
  52727. /** @hidden */ private _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  52728. /** @hidden */ private _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  52729. /** @hidden */ private _emitFloat(value: number): string;
  52730. }
  52731. }
  52732. declare module BABYLON {
  52733. /**
  52734. * Defines a block that can be used inside a node based material
  52735. */
  52736. export class NodeMaterialBlock {
  52737. private _buildId;
  52738. private _buildTarget;
  52739. private _target;
  52740. private _isFinalMerger;
  52741. private _isInput;
  52742. /** @hidden */ private _codeVariableName: string;
  52743. /** @hidden */ private _inputs: NodeMaterialConnectionPoint[];
  52744. /** @hidden */ private _outputs: NodeMaterialConnectionPoint[];
  52745. /** @hidden */ private _preparationId: number;
  52746. /**
  52747. * Gets or sets the name of the block
  52748. */
  52749. name: string;
  52750. /**
  52751. * Gets or sets the unique id of the node
  52752. */
  52753. uniqueId: number;
  52754. /**
  52755. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  52756. */
  52757. readonly isFinalMerger: boolean;
  52758. /**
  52759. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  52760. */
  52761. readonly isInput: boolean;
  52762. /**
  52763. * Gets or sets the build Id
  52764. */
  52765. buildId: number;
  52766. /**
  52767. * Gets or sets the target of the block
  52768. */
  52769. target: NodeMaterialBlockTargets;
  52770. /**
  52771. * Gets the list of input points
  52772. */
  52773. readonly inputs: NodeMaterialConnectionPoint[];
  52774. /** Gets the list of output points */
  52775. readonly outputs: NodeMaterialConnectionPoint[];
  52776. /**
  52777. * Find an input by its name
  52778. * @param name defines the name of the input to look for
  52779. * @returns the input or null if not found
  52780. */
  52781. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52782. /**
  52783. * Find an output by its name
  52784. * @param name defines the name of the outputto look for
  52785. * @returns the output or null if not found
  52786. */
  52787. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52788. /**
  52789. * Creates a new NodeMaterialBlock
  52790. * @param name defines the block name
  52791. * @param target defines the target of that block (Vertex by default)
  52792. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  52793. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  52794. */
  52795. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  52796. /**
  52797. * Initialize the block and prepare the context for build
  52798. * @param state defines the state that will be used for the build
  52799. */
  52800. initialize(state: NodeMaterialBuildState): void;
  52801. /**
  52802. * Bind data to effect. Will only be called for blocks with isBindable === true
  52803. * @param effect defines the effect to bind data to
  52804. * @param nodeMaterial defines the hosting NodeMaterial
  52805. * @param mesh defines the mesh that will be rendered
  52806. */
  52807. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52808. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  52809. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  52810. protected _writeFloat(value: number): string;
  52811. /**
  52812. * Gets the current class name e.g. "NodeMaterialBlock"
  52813. * @returns the class name
  52814. */
  52815. getClassName(): string;
  52816. /**
  52817. * Register a new input. Must be called inside a block constructor
  52818. * @param name defines the connection point name
  52819. * @param type defines the connection point type
  52820. * @param isOptional defines a boolean indicating that this input can be omitted
  52821. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  52822. * @returns the current block
  52823. */
  52824. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  52825. /**
  52826. * Register a new output. Must be called inside a block constructor
  52827. * @param name defines the connection point name
  52828. * @param type defines the connection point type
  52829. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  52830. * @returns the current block
  52831. */
  52832. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  52833. /**
  52834. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  52835. * @param forOutput defines an optional connection point to check compatibility with
  52836. * @returns the first available input or null
  52837. */
  52838. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  52839. /**
  52840. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  52841. * @param forBlock defines an optional block to check compatibility with
  52842. * @returns the first available input or null
  52843. */
  52844. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  52845. /**
  52846. * Gets the sibling of the given output
  52847. * @param current defines the current output
  52848. * @returns the next output in the list or null
  52849. */
  52850. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  52851. /**
  52852. * Connect current block with another block
  52853. * @param other defines the block to connect with
  52854. * @param options define the various options to help pick the right connections
  52855. * @returns the current block
  52856. */
  52857. connectTo(other: NodeMaterialBlock, options?: {
  52858. input?: string;
  52859. output?: string;
  52860. outputSwizzle?: string;
  52861. }): this | undefined;
  52862. protected _buildBlock(state: NodeMaterialBuildState): void;
  52863. /**
  52864. * Add uniforms, samplers and uniform buffers at compilation time
  52865. * @param state defines the state to update
  52866. * @param nodeMaterial defines the node material requesting the update
  52867. * @param defines defines the material defines to update
  52868. * @param uniformBuffers defines the list of uniform buffer names
  52869. */
  52870. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  52871. /**
  52872. * Add potential fallbacks if shader compilation fails
  52873. * @param mesh defines the mesh to be rendered
  52874. * @param fallbacks defines the current prioritized list of fallbacks
  52875. */
  52876. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  52877. /**
  52878. * Initialize defines for shader compilation
  52879. * @param mesh defines the mesh to be rendered
  52880. * @param nodeMaterial defines the node material requesting the update
  52881. * @param defines defines the material defines to update
  52882. * @param useInstances specifies that instances should be used
  52883. */
  52884. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52885. /**
  52886. * Update defines for shader compilation
  52887. * @param mesh defines the mesh to be rendered
  52888. * @param nodeMaterial defines the node material requesting the update
  52889. * @param defines defines the material defines to update
  52890. * @param useInstances specifies that instances should be used
  52891. */
  52892. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52893. /**
  52894. * Lets the block try to connect some inputs automatically
  52895. * @param material defines the hosting NodeMaterial
  52896. */
  52897. autoConfigure(material: NodeMaterial): void;
  52898. /**
  52899. * Function called when a block is declared as repeatable content generator
  52900. * @param vertexShaderState defines the current compilation state for the vertex shader
  52901. * @param fragmentShaderState defines the current compilation state for the fragment shader
  52902. * @param mesh defines the mesh to be rendered
  52903. * @param defines defines the material defines to update
  52904. */
  52905. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  52906. /**
  52907. * Checks if the block is ready
  52908. * @param mesh defines the mesh to be rendered
  52909. * @param nodeMaterial defines the node material requesting the update
  52910. * @param defines defines the material defines to update
  52911. * @param useInstances specifies that instances should be used
  52912. * @returns true if the block is ready
  52913. */
  52914. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  52915. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  52916. private _processBuild;
  52917. /**
  52918. * Compile the current node and generate the shader code
  52919. * @param state defines the current compilation state (uniforms, samplers, current string)
  52920. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  52921. * @returns true if already built
  52922. */
  52923. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  52924. protected _inputRename(name: string): string;
  52925. protected _outputRename(name: string): string;
  52926. protected _dumpPropertiesCode(): string;
  52927. /** @hidden */ private _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  52928. /**
  52929. * Clone the current block to a new identical block
  52930. * @param scene defines the hosting scene
  52931. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52932. * @returns a copy of the current block
  52933. */
  52934. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  52935. /**
  52936. * Serializes this block in a JSON representation
  52937. * @returns the serialized block object
  52938. */
  52939. serialize(): any;
  52940. /** @hidden */ private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52941. }
  52942. }
  52943. declare module BABYLON {
  52944. /**
  52945. * Enum defining the type of animations supported by InputBlock
  52946. */
  52947. export enum AnimatedInputBlockTypes {
  52948. /** No animation */
  52949. None = 0,
  52950. /** Time based animation. Will only work for floats */
  52951. Time = 1
  52952. }
  52953. }
  52954. declare module BABYLON {
  52955. /**
  52956. * Block used to expose an input value
  52957. */
  52958. export class InputBlock extends NodeMaterialBlock {
  52959. private _mode;
  52960. private _associatedVariableName;
  52961. private _storedValue;
  52962. private _valueCallback;
  52963. private _type;
  52964. private _animationType;
  52965. /** Gets or set a value used to limit the range of float values */
  52966. min: number;
  52967. /** Gets or set a value used to limit the range of float values */
  52968. max: number;
  52969. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  52970. matrixMode: number;
  52971. /** @hidden */ private _systemValue: Nullable<NodeMaterialSystemValues>;
  52972. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  52973. visibleInInspector: boolean;
  52974. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  52975. isConstant: boolean;
  52976. /**
  52977. * Gets or sets the connection point type (default is float)
  52978. */
  52979. readonly type: NodeMaterialBlockConnectionPointTypes;
  52980. /**
  52981. * Creates a new InputBlock
  52982. * @param name defines the block name
  52983. * @param target defines the target of that block (Vertex by default)
  52984. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  52985. */
  52986. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  52987. /**
  52988. * Gets the output component
  52989. */
  52990. readonly output: NodeMaterialConnectionPoint;
  52991. /**
  52992. * Set the source of this connection point to a vertex attribute
  52993. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  52994. * @returns the current connection point
  52995. */
  52996. setAsAttribute(attributeName?: string): InputBlock;
  52997. /**
  52998. * Set the source of this connection point to a system value
  52999. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  53000. * @returns the current connection point
  53001. */
  53002. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  53003. /**
  53004. * Gets or sets the value of that point.
  53005. * Please note that this value will be ignored if valueCallback is defined
  53006. */
  53007. value: any;
  53008. /**
  53009. * Gets or sets a callback used to get the value of that point.
  53010. * Please note that setting this value will force the connection point to ignore the value property
  53011. */
  53012. valueCallback: () => any;
  53013. /**
  53014. * Gets or sets the associated variable name in the shader
  53015. */
  53016. associatedVariableName: string;
  53017. /** Gets or sets the type of animation applied to the input */
  53018. animationType: AnimatedInputBlockTypes;
  53019. /**
  53020. * Gets a boolean indicating that this connection point not defined yet
  53021. */
  53022. readonly isUndefined: boolean;
  53023. /**
  53024. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  53025. * In this case the connection point name must be the name of the uniform to use.
  53026. * Can only be set on inputs
  53027. */
  53028. isUniform: boolean;
  53029. /**
  53030. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  53031. * In this case the connection point name must be the name of the attribute to use
  53032. * Can only be set on inputs
  53033. */
  53034. isAttribute: boolean;
  53035. /**
  53036. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  53037. * Can only be set on exit points
  53038. */
  53039. isVarying: boolean;
  53040. /**
  53041. * Gets a boolean indicating that the current connection point is a system value
  53042. */
  53043. readonly isSystemValue: boolean;
  53044. /**
  53045. * Gets or sets the current well known value or null if not defined as a system value
  53046. */
  53047. systemValue: Nullable<NodeMaterialSystemValues>;
  53048. /**
  53049. * Gets the current class name
  53050. * @returns the class name
  53051. */
  53052. getClassName(): string;
  53053. /**
  53054. * Animate the input if animationType !== None
  53055. * @param scene defines the rendering scene
  53056. */
  53057. animate(scene: Scene): void;
  53058. private _emitDefine;
  53059. initialize(state: NodeMaterialBuildState): void;
  53060. /**
  53061. * Set the input block to its default value (based on its type)
  53062. */
  53063. setDefaultValue(): void;
  53064. private _emitConstant;
  53065. private _emit;
  53066. /** @hidden */ private _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  53067. /** @hidden */ private _transmit(effect: Effect, scene: Scene): void;
  53068. protected _buildBlock(state: NodeMaterialBuildState): void;
  53069. protected _dumpPropertiesCode(): string;
  53070. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53071. }
  53072. }
  53073. declare module BABYLON {
  53074. /**
  53075. * Defines a connection point for a block
  53076. */
  53077. export class NodeMaterialConnectionPoint {
  53078. /** @hidden */ private _ownerBlock: NodeMaterialBlock;
  53079. /** @hidden */ private _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53080. private _endpoints;
  53081. private _associatedVariableName;
  53082. /** @hidden */ private _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53083. /** @hidden */ private _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53084. private _type;
  53085. /** @hidden */ private _enforceAssociatedVariableName: boolean;
  53086. /**
  53087. * Gets or sets the additional types supported by this connection point
  53088. */
  53089. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53090. /**
  53091. * Gets or sets the additional types excluded by this connection point
  53092. */
  53093. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53094. /**
  53095. * Gets or sets the associated variable name in the shader
  53096. */
  53097. associatedVariableName: string;
  53098. /**
  53099. * Gets or sets the connection point type (default is float)
  53100. */
  53101. type: NodeMaterialBlockConnectionPointTypes;
  53102. /**
  53103. * Gets or sets the connection point name
  53104. */
  53105. name: string;
  53106. /**
  53107. * Gets or sets a boolean indicating that this connection point can be omitted
  53108. */
  53109. isOptional: boolean;
  53110. /**
  53111. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  53112. */
  53113. define: string;
  53114. /** @hidden */ private _prioritizeVertex: boolean;
  53115. private _target;
  53116. /** Gets or sets the target of that connection point */
  53117. target: NodeMaterialBlockTargets;
  53118. /**
  53119. * Gets a boolean indicating that the current point is connected
  53120. */
  53121. readonly isConnected: boolean;
  53122. /**
  53123. * Gets a boolean indicating that the current point is connected to an input block
  53124. */
  53125. readonly isConnectedToInputBlock: boolean;
  53126. /**
  53127. * Gets a the connected input block (if any)
  53128. */
  53129. readonly connectInputBlock: Nullable<InputBlock>;
  53130. /** Get the other side of the connection (if any) */
  53131. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53132. /** Get the block that owns this connection point */
  53133. readonly ownerBlock: NodeMaterialBlock;
  53134. /** Get the block connected on the other side of this connection (if any) */
  53135. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  53136. /** Get the block connected on the endpoints of this connection (if any) */
  53137. readonly connectedBlocks: Array<NodeMaterialBlock>;
  53138. /** Gets the list of connected endpoints */
  53139. readonly endpoints: NodeMaterialConnectionPoint[];
  53140. /** Gets a boolean indicating if that output point is connected to at least one input */
  53141. readonly hasEndpoints: boolean;
  53142. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  53143. readonly isConnectedInVertexShader: boolean;
  53144. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  53145. readonly isConnectedInFragmentShader: boolean;
  53146. /**
  53147. * Creates a new connection point
  53148. * @param name defines the connection point name
  53149. * @param ownerBlock defines the block hosting this connection point
  53150. */
  53151. constructor(name: string, ownerBlock: NodeMaterialBlock);
  53152. /**
  53153. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  53154. * @returns the class name
  53155. */
  53156. getClassName(): string;
  53157. /**
  53158. * Gets an boolean indicating if the current point can be connected to another point
  53159. * @param connectionPoint defines the other connection point
  53160. * @returns true if the connection is possible
  53161. */
  53162. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  53163. /**
  53164. * Connect this point to another connection point
  53165. * @param connectionPoint defines the other connection point
  53166. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  53167. * @returns the current connection point
  53168. */
  53169. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  53170. /**
  53171. * Disconnect this point from one of his endpoint
  53172. * @param endpoint defines the other connection point
  53173. * @returns the current connection point
  53174. */
  53175. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53176. /**
  53177. * Serializes this point in a JSON representation
  53178. * @returns the serialized point object
  53179. */
  53180. serialize(): any;
  53181. }
  53182. }
  53183. declare module BABYLON {
  53184. /**
  53185. * Block used to add support for vertex skinning (bones)
  53186. */
  53187. export class BonesBlock extends NodeMaterialBlock {
  53188. /**
  53189. * Creates a new BonesBlock
  53190. * @param name defines the block name
  53191. */
  53192. constructor(name: string);
  53193. /**
  53194. * Initialize the block and prepare the context for build
  53195. * @param state defines the state that will be used for the build
  53196. */
  53197. initialize(state: NodeMaterialBuildState): void;
  53198. /**
  53199. * Gets the current class name
  53200. * @returns the class name
  53201. */
  53202. getClassName(): string;
  53203. /**
  53204. * Gets the matrix indices input component
  53205. */
  53206. readonly matricesIndices: NodeMaterialConnectionPoint;
  53207. /**
  53208. * Gets the matrix weights input component
  53209. */
  53210. readonly matricesWeights: NodeMaterialConnectionPoint;
  53211. /**
  53212. * Gets the extra matrix indices input component
  53213. */
  53214. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  53215. /**
  53216. * Gets the extra matrix weights input component
  53217. */
  53218. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  53219. /**
  53220. * Gets the world input component
  53221. */
  53222. readonly world: NodeMaterialConnectionPoint;
  53223. /**
  53224. * Gets the output component
  53225. */
  53226. readonly output: NodeMaterialConnectionPoint;
  53227. autoConfigure(material: NodeMaterial): void;
  53228. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53229. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53230. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53231. protected _buildBlock(state: NodeMaterialBuildState): this;
  53232. }
  53233. }
  53234. declare module BABYLON {
  53235. /**
  53236. * Block used to add support for instances
  53237. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  53238. */
  53239. export class InstancesBlock extends NodeMaterialBlock {
  53240. /**
  53241. * Creates a new InstancesBlock
  53242. * @param name defines the block name
  53243. */
  53244. constructor(name: string);
  53245. /**
  53246. * Gets the current class name
  53247. * @returns the class name
  53248. */
  53249. getClassName(): string;
  53250. /**
  53251. * Gets the first world row input component
  53252. */
  53253. readonly world0: NodeMaterialConnectionPoint;
  53254. /**
  53255. * Gets the second world row input component
  53256. */
  53257. readonly world1: NodeMaterialConnectionPoint;
  53258. /**
  53259. * Gets the third world row input component
  53260. */
  53261. readonly world2: NodeMaterialConnectionPoint;
  53262. /**
  53263. * Gets the forth world row input component
  53264. */
  53265. readonly world3: NodeMaterialConnectionPoint;
  53266. /**
  53267. * Gets the world input component
  53268. */
  53269. readonly world: NodeMaterialConnectionPoint;
  53270. /**
  53271. * Gets the output component
  53272. */
  53273. readonly output: NodeMaterialConnectionPoint;
  53274. autoConfigure(material: NodeMaterial): void;
  53275. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53276. protected _buildBlock(state: NodeMaterialBuildState): this;
  53277. }
  53278. }
  53279. declare module BABYLON {
  53280. /**
  53281. * Block used to add morph targets support to vertex shader
  53282. */
  53283. export class MorphTargetsBlock extends NodeMaterialBlock {
  53284. private _repeatableContentAnchor;
  53285. private _repeatebleContentGenerated;
  53286. /**
  53287. * Create a new MorphTargetsBlock
  53288. * @param name defines the block name
  53289. */
  53290. constructor(name: string);
  53291. /**
  53292. * Gets the current class name
  53293. * @returns the class name
  53294. */
  53295. getClassName(): string;
  53296. /**
  53297. * Gets the position input component
  53298. */
  53299. readonly position: NodeMaterialConnectionPoint;
  53300. /**
  53301. * Gets the normal input component
  53302. */
  53303. readonly normal: NodeMaterialConnectionPoint;
  53304. /**
  53305. * Gets the tangent input component
  53306. */
  53307. readonly tangent: NodeMaterialConnectionPoint;
  53308. /**
  53309. * Gets the tangent input component
  53310. */
  53311. readonly uv: NodeMaterialConnectionPoint;
  53312. /**
  53313. * Gets the position output component
  53314. */
  53315. readonly positionOutput: NodeMaterialConnectionPoint;
  53316. /**
  53317. * Gets the normal output component
  53318. */
  53319. readonly normalOutput: NodeMaterialConnectionPoint;
  53320. /**
  53321. * Gets the tangent output component
  53322. */
  53323. readonly tangentOutput: NodeMaterialConnectionPoint;
  53324. /**
  53325. * Gets the tangent output component
  53326. */
  53327. readonly uvOutput: NodeMaterialConnectionPoint;
  53328. initialize(state: NodeMaterialBuildState): void;
  53329. autoConfigure(material: NodeMaterial): void;
  53330. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53331. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53332. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53333. protected _buildBlock(state: NodeMaterialBuildState): this;
  53334. }
  53335. }
  53336. declare module BABYLON {
  53337. /**
  53338. * Block used to get data information from a light
  53339. */
  53340. export class LightInformationBlock extends NodeMaterialBlock {
  53341. private _lightDataUniformName;
  53342. private _lightColorUniformName;
  53343. private _lightTypeDefineName;
  53344. /**
  53345. * Gets or sets the light associated with this block
  53346. */
  53347. light: Nullable<Light>;
  53348. /**
  53349. * Creates a new LightInformationBlock
  53350. * @param name defines the block name
  53351. */
  53352. constructor(name: string);
  53353. /**
  53354. * Gets the current class name
  53355. * @returns the class name
  53356. */
  53357. getClassName(): string;
  53358. /**
  53359. * Gets the world position input component
  53360. */
  53361. readonly worldPosition: NodeMaterialConnectionPoint;
  53362. /**
  53363. * Gets the direction output component
  53364. */
  53365. readonly direction: NodeMaterialConnectionPoint;
  53366. /**
  53367. * Gets the direction output component
  53368. */
  53369. readonly color: NodeMaterialConnectionPoint;
  53370. /**
  53371. * Gets the direction output component
  53372. */
  53373. readonly intensity: NodeMaterialConnectionPoint;
  53374. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53375. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53376. protected _buildBlock(state: NodeMaterialBuildState): this;
  53377. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53378. }
  53379. }
  53380. declare module BABYLON {
  53381. /**
  53382. * Block used to add image processing support to fragment shader
  53383. */
  53384. export class ImageProcessingBlock extends NodeMaterialBlock {
  53385. /**
  53386. * Create a new ImageProcessingBlock
  53387. * @param name defines the block name
  53388. */
  53389. constructor(name: string);
  53390. /**
  53391. * Gets the current class name
  53392. * @returns the class name
  53393. */
  53394. getClassName(): string;
  53395. /**
  53396. * Gets the color input component
  53397. */
  53398. readonly color: NodeMaterialConnectionPoint;
  53399. /**
  53400. * Gets the output component
  53401. */
  53402. readonly output: NodeMaterialConnectionPoint;
  53403. /**
  53404. * Initialize the block and prepare the context for build
  53405. * @param state defines the state that will be used for the build
  53406. */
  53407. initialize(state: NodeMaterialBuildState): void;
  53408. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  53409. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53410. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53411. protected _buildBlock(state: NodeMaterialBuildState): this;
  53412. }
  53413. }
  53414. declare module BABYLON {
  53415. /**
  53416. * Block used to pertub normals based on a normal map
  53417. */
  53418. export class PerturbNormalBlock extends NodeMaterialBlock {
  53419. private _tangentSpaceParameterName;
  53420. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  53421. invertX: boolean;
  53422. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  53423. invertY: boolean;
  53424. /**
  53425. * Create a new PerturbNormalBlock
  53426. * @param name defines the block name
  53427. */
  53428. constructor(name: string);
  53429. /**
  53430. * Gets the current class name
  53431. * @returns the class name
  53432. */
  53433. getClassName(): string;
  53434. /**
  53435. * Gets the world position input component
  53436. */
  53437. readonly worldPosition: NodeMaterialConnectionPoint;
  53438. /**
  53439. * Gets the world normal input component
  53440. */
  53441. readonly worldNormal: NodeMaterialConnectionPoint;
  53442. /**
  53443. * Gets the uv input component
  53444. */
  53445. readonly uv: NodeMaterialConnectionPoint;
  53446. /**
  53447. * Gets the normal map color input component
  53448. */
  53449. readonly normalMapColor: NodeMaterialConnectionPoint;
  53450. /**
  53451. * Gets the strength input component
  53452. */
  53453. readonly strength: NodeMaterialConnectionPoint;
  53454. /**
  53455. * Gets the output component
  53456. */
  53457. readonly output: NodeMaterialConnectionPoint;
  53458. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53459. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53460. autoConfigure(material: NodeMaterial): void;
  53461. protected _buildBlock(state: NodeMaterialBuildState): this;
  53462. protected _dumpPropertiesCode(): string;
  53463. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53464. }
  53465. }
  53466. declare module BABYLON {
  53467. /**
  53468. * Block used to discard a pixel if a value is smaller than a cutoff
  53469. */
  53470. export class DiscardBlock extends NodeMaterialBlock {
  53471. /**
  53472. * Create a new DiscardBlock
  53473. * @param name defines the block name
  53474. */
  53475. constructor(name: string);
  53476. /**
  53477. * Gets the current class name
  53478. * @returns the class name
  53479. */
  53480. getClassName(): string;
  53481. /**
  53482. * Gets the color input component
  53483. */
  53484. readonly value: NodeMaterialConnectionPoint;
  53485. /**
  53486. * Gets the cutoff input component
  53487. */
  53488. readonly cutoff: NodeMaterialConnectionPoint;
  53489. protected _buildBlock(state: NodeMaterialBuildState): this;
  53490. }
  53491. }
  53492. declare module BABYLON {
  53493. /**
  53494. * Block used to add support for scene fog
  53495. */
  53496. export class FogBlock extends NodeMaterialBlock {
  53497. private _fogDistanceName;
  53498. private _fogParameters;
  53499. /**
  53500. * Create a new FogBlock
  53501. * @param name defines the block name
  53502. */
  53503. constructor(name: string);
  53504. /**
  53505. * Gets the current class name
  53506. * @returns the class name
  53507. */
  53508. getClassName(): string;
  53509. /**
  53510. * Gets the world position input component
  53511. */
  53512. readonly worldPosition: NodeMaterialConnectionPoint;
  53513. /**
  53514. * Gets the view input component
  53515. */
  53516. readonly view: NodeMaterialConnectionPoint;
  53517. /**
  53518. * Gets the color input component
  53519. */
  53520. readonly input: NodeMaterialConnectionPoint;
  53521. /**
  53522. * Gets the fog color input component
  53523. */
  53524. readonly fogColor: NodeMaterialConnectionPoint;
  53525. /**
  53526. * Gets the output component
  53527. */
  53528. readonly output: NodeMaterialConnectionPoint;
  53529. autoConfigure(material: NodeMaterial): void;
  53530. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53531. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53532. protected _buildBlock(state: NodeMaterialBuildState): this;
  53533. }
  53534. }
  53535. declare module BABYLON {
  53536. /**
  53537. * Block used to add light in the fragment shader
  53538. */
  53539. export class LightBlock extends NodeMaterialBlock {
  53540. private _lightId;
  53541. /**
  53542. * Gets or sets the light associated with this block
  53543. */
  53544. light: Nullable<Light>;
  53545. /**
  53546. * Create a new LightBlock
  53547. * @param name defines the block name
  53548. */
  53549. constructor(name: string);
  53550. /**
  53551. * Gets the current class name
  53552. * @returns the class name
  53553. */
  53554. getClassName(): string;
  53555. /**
  53556. * Gets the world position input component
  53557. */
  53558. readonly worldPosition: NodeMaterialConnectionPoint;
  53559. /**
  53560. * Gets the world normal input component
  53561. */
  53562. readonly worldNormal: NodeMaterialConnectionPoint;
  53563. /**
  53564. * Gets the camera (or eye) position component
  53565. */
  53566. readonly cameraPosition: NodeMaterialConnectionPoint;
  53567. /**
  53568. * Gets the glossiness component
  53569. */
  53570. readonly glossiness: NodeMaterialConnectionPoint;
  53571. /**
  53572. * Gets the glossinness power component
  53573. */
  53574. readonly glossPower: NodeMaterialConnectionPoint;
  53575. /**
  53576. * Gets the diffuse color component
  53577. */
  53578. readonly diffuseColor: NodeMaterialConnectionPoint;
  53579. /**
  53580. * Gets the specular color component
  53581. */
  53582. readonly specularColor: NodeMaterialConnectionPoint;
  53583. /**
  53584. * Gets the diffuse output component
  53585. */
  53586. readonly diffuseOutput: NodeMaterialConnectionPoint;
  53587. /**
  53588. * Gets the specular output component
  53589. */
  53590. readonly specularOutput: NodeMaterialConnectionPoint;
  53591. autoConfigure(material: NodeMaterial): void;
  53592. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53593. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  53594. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53595. private _injectVertexCode;
  53596. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53597. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53598. }
  53599. }
  53600. declare module BABYLON {
  53601. /**
  53602. * Block used to multiply 2 values
  53603. */
  53604. export class MultiplyBlock extends NodeMaterialBlock {
  53605. /**
  53606. * Creates a new MultiplyBlock
  53607. * @param name defines the block name
  53608. */
  53609. constructor(name: string);
  53610. /**
  53611. * Gets the current class name
  53612. * @returns the class name
  53613. */
  53614. getClassName(): string;
  53615. /**
  53616. * Gets the left operand input component
  53617. */
  53618. readonly left: NodeMaterialConnectionPoint;
  53619. /**
  53620. * Gets the right operand input component
  53621. */
  53622. readonly right: NodeMaterialConnectionPoint;
  53623. /**
  53624. * Gets the output component
  53625. */
  53626. readonly output: NodeMaterialConnectionPoint;
  53627. protected _buildBlock(state: NodeMaterialBuildState): this;
  53628. }
  53629. }
  53630. declare module BABYLON {
  53631. /**
  53632. * Block used to add 2 vectors
  53633. */
  53634. export class AddBlock extends NodeMaterialBlock {
  53635. /**
  53636. * Creates a new AddBlock
  53637. * @param name defines the block name
  53638. */
  53639. constructor(name: string);
  53640. /**
  53641. * Gets the current class name
  53642. * @returns the class name
  53643. */
  53644. getClassName(): string;
  53645. /**
  53646. * Gets the left operand input component
  53647. */
  53648. readonly left: NodeMaterialConnectionPoint;
  53649. /**
  53650. * Gets the right operand input component
  53651. */
  53652. readonly right: NodeMaterialConnectionPoint;
  53653. /**
  53654. * Gets the output component
  53655. */
  53656. readonly output: NodeMaterialConnectionPoint;
  53657. protected _buildBlock(state: NodeMaterialBuildState): this;
  53658. }
  53659. }
  53660. declare module BABYLON {
  53661. /**
  53662. * Block used to scale a vector by a float
  53663. */
  53664. export class ScaleBlock extends NodeMaterialBlock {
  53665. /**
  53666. * Creates a new ScaleBlock
  53667. * @param name defines the block name
  53668. */
  53669. constructor(name: string);
  53670. /**
  53671. * Gets the current class name
  53672. * @returns the class name
  53673. */
  53674. getClassName(): string;
  53675. /**
  53676. * Gets the input component
  53677. */
  53678. readonly input: NodeMaterialConnectionPoint;
  53679. /**
  53680. * Gets the factor input component
  53681. */
  53682. readonly factor: NodeMaterialConnectionPoint;
  53683. /**
  53684. * Gets the output component
  53685. */
  53686. readonly output: NodeMaterialConnectionPoint;
  53687. protected _buildBlock(state: NodeMaterialBuildState): this;
  53688. }
  53689. }
  53690. declare module BABYLON {
  53691. /**
  53692. * Block used to clamp a float
  53693. */
  53694. export class ClampBlock extends NodeMaterialBlock {
  53695. /** Gets or sets the minimum range */
  53696. minimum: number;
  53697. /** Gets or sets the maximum range */
  53698. maximum: number;
  53699. /**
  53700. * Creates a new ClampBlock
  53701. * @param name defines the block name
  53702. */
  53703. constructor(name: string);
  53704. /**
  53705. * Gets the current class name
  53706. * @returns the class name
  53707. */
  53708. getClassName(): string;
  53709. /**
  53710. * Gets the value input component
  53711. */
  53712. readonly value: NodeMaterialConnectionPoint;
  53713. /**
  53714. * Gets the output component
  53715. */
  53716. readonly output: NodeMaterialConnectionPoint;
  53717. protected _buildBlock(state: NodeMaterialBuildState): this;
  53718. protected _dumpPropertiesCode(): string;
  53719. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53720. }
  53721. }
  53722. declare module BABYLON {
  53723. /**
  53724. * Block used to apply a cross product between 2 vectors
  53725. */
  53726. export class CrossBlock extends NodeMaterialBlock {
  53727. /**
  53728. * Creates a new CrossBlock
  53729. * @param name defines the block name
  53730. */
  53731. constructor(name: string);
  53732. /**
  53733. * Gets the current class name
  53734. * @returns the class name
  53735. */
  53736. getClassName(): string;
  53737. /**
  53738. * Gets the left operand input component
  53739. */
  53740. readonly left: NodeMaterialConnectionPoint;
  53741. /**
  53742. * Gets the right operand input component
  53743. */
  53744. readonly right: NodeMaterialConnectionPoint;
  53745. /**
  53746. * Gets the output component
  53747. */
  53748. readonly output: NodeMaterialConnectionPoint;
  53749. protected _buildBlock(state: NodeMaterialBuildState): this;
  53750. }
  53751. }
  53752. declare module BABYLON {
  53753. /**
  53754. * Block used to apply a dot product between 2 vectors
  53755. */
  53756. export class DotBlock extends NodeMaterialBlock {
  53757. /**
  53758. * Creates a new DotBlock
  53759. * @param name defines the block name
  53760. */
  53761. constructor(name: string);
  53762. /**
  53763. * Gets the current class name
  53764. * @returns the class name
  53765. */
  53766. getClassName(): string;
  53767. /**
  53768. * Gets the left operand input component
  53769. */
  53770. readonly left: NodeMaterialConnectionPoint;
  53771. /**
  53772. * Gets the right operand input component
  53773. */
  53774. readonly right: NodeMaterialConnectionPoint;
  53775. /**
  53776. * Gets the output component
  53777. */
  53778. readonly output: NodeMaterialConnectionPoint;
  53779. protected _buildBlock(state: NodeMaterialBuildState): this;
  53780. }
  53781. }
  53782. declare module BABYLON {
  53783. /**
  53784. * Block used to remap a float from a range to a new one
  53785. */
  53786. export class RemapBlock extends NodeMaterialBlock {
  53787. /**
  53788. * Gets or sets the source range
  53789. */
  53790. sourceRange: Vector2;
  53791. /**
  53792. * Gets or sets the target range
  53793. */
  53794. targetRange: Vector2;
  53795. /**
  53796. * Creates a new RemapBlock
  53797. * @param name defines the block name
  53798. */
  53799. constructor(name: string);
  53800. /**
  53801. * Gets the current class name
  53802. * @returns the class name
  53803. */
  53804. getClassName(): string;
  53805. /**
  53806. * Gets the input component
  53807. */
  53808. readonly input: NodeMaterialConnectionPoint;
  53809. /**
  53810. * Gets the source min input component
  53811. */
  53812. readonly sourceMin: NodeMaterialConnectionPoint;
  53813. /**
  53814. * Gets the source max input component
  53815. */
  53816. readonly sourceMax: NodeMaterialConnectionPoint;
  53817. /**
  53818. * Gets the target min input component
  53819. */
  53820. readonly targetMin: NodeMaterialConnectionPoint;
  53821. /**
  53822. * Gets the target max input component
  53823. */
  53824. readonly targetMax: NodeMaterialConnectionPoint;
  53825. /**
  53826. * Gets the output component
  53827. */
  53828. readonly output: NodeMaterialConnectionPoint;
  53829. protected _buildBlock(state: NodeMaterialBuildState): this;
  53830. protected _dumpPropertiesCode(): string;
  53831. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53832. }
  53833. }
  53834. declare module BABYLON {
  53835. /**
  53836. * Block used to normalize a vector
  53837. */
  53838. export class NormalizeBlock extends NodeMaterialBlock {
  53839. /**
  53840. * Creates a new NormalizeBlock
  53841. * @param name defines the block name
  53842. */
  53843. constructor(name: string);
  53844. /**
  53845. * Gets the current class name
  53846. * @returns the class name
  53847. */
  53848. getClassName(): string;
  53849. /**
  53850. * Gets the input component
  53851. */
  53852. readonly input: NodeMaterialConnectionPoint;
  53853. /**
  53854. * Gets the output component
  53855. */
  53856. readonly output: NodeMaterialConnectionPoint;
  53857. protected _buildBlock(state: NodeMaterialBuildState): this;
  53858. }
  53859. }
  53860. declare module BABYLON {
  53861. /**
  53862. * Operations supported by the Trigonometry block
  53863. */
  53864. export enum TrigonometryBlockOperations {
  53865. /** Cos */
  53866. Cos = 0,
  53867. /** Sin */
  53868. Sin = 1,
  53869. /** Abs */
  53870. Abs = 2,
  53871. /** Exp */
  53872. Exp = 3,
  53873. /** Exp2 */
  53874. Exp2 = 4,
  53875. /** Round */
  53876. Round = 5,
  53877. /** Floor */
  53878. Floor = 6,
  53879. /** Ceiling */
  53880. Ceiling = 7,
  53881. /** Square root */
  53882. Sqrt = 8,
  53883. /** Log */
  53884. Log = 9,
  53885. /** Tangent */
  53886. Tan = 10,
  53887. /** Arc tangent */
  53888. ArcTan = 11,
  53889. /** Arc cosinus */
  53890. ArcCos = 12,
  53891. /** Arc sinus */
  53892. ArcSin = 13,
  53893. /** Fraction */
  53894. Fract = 14,
  53895. /** Sign */
  53896. Sign = 15,
  53897. /** To radians (from degrees) */
  53898. Radians = 16,
  53899. /** To degrees (from radians) */
  53900. Degrees = 17
  53901. }
  53902. /**
  53903. * Block used to apply trigonometry operation to floats
  53904. */
  53905. export class TrigonometryBlock extends NodeMaterialBlock {
  53906. /**
  53907. * Gets or sets the operation applied by the block
  53908. */
  53909. operation: TrigonometryBlockOperations;
  53910. /**
  53911. * Creates a new TrigonometryBlock
  53912. * @param name defines the block name
  53913. */
  53914. constructor(name: string);
  53915. /**
  53916. * Gets the current class name
  53917. * @returns the class name
  53918. */
  53919. getClassName(): string;
  53920. /**
  53921. * Gets the input component
  53922. */
  53923. readonly input: NodeMaterialConnectionPoint;
  53924. /**
  53925. * Gets the output component
  53926. */
  53927. readonly output: NodeMaterialConnectionPoint;
  53928. protected _buildBlock(state: NodeMaterialBuildState): this;
  53929. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53930. }
  53931. }
  53932. declare module BABYLON {
  53933. /**
  53934. * Block used to create a Color3/4 out of individual inputs (one for each component)
  53935. */
  53936. export class ColorMergerBlock extends NodeMaterialBlock {
  53937. /**
  53938. * Create a new ColorMergerBlock
  53939. * @param name defines the block name
  53940. */
  53941. constructor(name: string);
  53942. /**
  53943. * Gets the current class name
  53944. * @returns the class name
  53945. */
  53946. getClassName(): string;
  53947. /**
  53948. * Gets the r component (input)
  53949. */
  53950. readonly r: NodeMaterialConnectionPoint;
  53951. /**
  53952. * Gets the g component (input)
  53953. */
  53954. readonly g: NodeMaterialConnectionPoint;
  53955. /**
  53956. * Gets the b component (input)
  53957. */
  53958. readonly b: NodeMaterialConnectionPoint;
  53959. /**
  53960. * Gets the a component (input)
  53961. */
  53962. readonly a: NodeMaterialConnectionPoint;
  53963. /**
  53964. * Gets the rgba component (output)
  53965. */
  53966. readonly rgba: NodeMaterialConnectionPoint;
  53967. /**
  53968. * Gets the rgb component (output)
  53969. */
  53970. readonly rgb: NodeMaterialConnectionPoint;
  53971. protected _buildBlock(state: NodeMaterialBuildState): this;
  53972. }
  53973. }
  53974. declare module BABYLON {
  53975. /**
  53976. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  53977. */
  53978. export class VectorMergerBlock extends NodeMaterialBlock {
  53979. /**
  53980. * Create a new VectorMergerBlock
  53981. * @param name defines the block name
  53982. */
  53983. constructor(name: string);
  53984. /**
  53985. * Gets the current class name
  53986. * @returns the class name
  53987. */
  53988. getClassName(): string;
  53989. /**
  53990. * Gets the x component (input)
  53991. */
  53992. readonly x: NodeMaterialConnectionPoint;
  53993. /**
  53994. * Gets the y component (input)
  53995. */
  53996. readonly y: NodeMaterialConnectionPoint;
  53997. /**
  53998. * Gets the z component (input)
  53999. */
  54000. readonly z: NodeMaterialConnectionPoint;
  54001. /**
  54002. * Gets the w component (input)
  54003. */
  54004. readonly w: NodeMaterialConnectionPoint;
  54005. /**
  54006. * Gets the xyzw component (output)
  54007. */
  54008. readonly xyzw: NodeMaterialConnectionPoint;
  54009. /**
  54010. * Gets the xyz component (output)
  54011. */
  54012. readonly xyz: NodeMaterialConnectionPoint;
  54013. /**
  54014. * Gets the xy component (output)
  54015. */
  54016. readonly xy: NodeMaterialConnectionPoint;
  54017. protected _buildBlock(state: NodeMaterialBuildState): this;
  54018. }
  54019. }
  54020. declare module BABYLON {
  54021. /**
  54022. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  54023. */
  54024. export class ColorSplitterBlock extends NodeMaterialBlock {
  54025. /**
  54026. * Create a new ColorSplitterBlock
  54027. * @param name defines the block name
  54028. */
  54029. constructor(name: string);
  54030. /**
  54031. * Gets the current class name
  54032. * @returns the class name
  54033. */
  54034. getClassName(): string;
  54035. /**
  54036. * Gets the rgba component (input)
  54037. */
  54038. readonly rgba: NodeMaterialConnectionPoint;
  54039. /**
  54040. * Gets the rgb component (input)
  54041. */
  54042. readonly rgbIn: NodeMaterialConnectionPoint;
  54043. /**
  54044. * Gets the rgb component (output)
  54045. */
  54046. readonly rgbOut: NodeMaterialConnectionPoint;
  54047. /**
  54048. * Gets the r component (output)
  54049. */
  54050. readonly r: NodeMaterialConnectionPoint;
  54051. /**
  54052. * Gets the g component (output)
  54053. */
  54054. readonly g: NodeMaterialConnectionPoint;
  54055. /**
  54056. * Gets the b component (output)
  54057. */
  54058. readonly b: NodeMaterialConnectionPoint;
  54059. /**
  54060. * Gets the a component (output)
  54061. */
  54062. readonly a: NodeMaterialConnectionPoint;
  54063. protected _inputRename(name: string): string;
  54064. protected _outputRename(name: string): string;
  54065. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54066. }
  54067. }
  54068. declare module BABYLON {
  54069. /**
  54070. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  54071. */
  54072. export class VectorSplitterBlock extends NodeMaterialBlock {
  54073. /**
  54074. * Create a new VectorSplitterBlock
  54075. * @param name defines the block name
  54076. */
  54077. constructor(name: string);
  54078. /**
  54079. * Gets the current class name
  54080. * @returns the class name
  54081. */
  54082. getClassName(): string;
  54083. /**
  54084. * Gets the xyzw component (input)
  54085. */
  54086. readonly xyzw: NodeMaterialConnectionPoint;
  54087. /**
  54088. * Gets the xyz component (input)
  54089. */
  54090. readonly xyzIn: NodeMaterialConnectionPoint;
  54091. /**
  54092. * Gets the xy component (input)
  54093. */
  54094. readonly xyIn: NodeMaterialConnectionPoint;
  54095. /**
  54096. * Gets the xyz component (output)
  54097. */
  54098. readonly xyzOut: NodeMaterialConnectionPoint;
  54099. /**
  54100. * Gets the xy component (output)
  54101. */
  54102. readonly xyOut: NodeMaterialConnectionPoint;
  54103. /**
  54104. * Gets the x component (output)
  54105. */
  54106. readonly x: NodeMaterialConnectionPoint;
  54107. /**
  54108. * Gets the y component (output)
  54109. */
  54110. readonly y: NodeMaterialConnectionPoint;
  54111. /**
  54112. * Gets the z component (output)
  54113. */
  54114. readonly z: NodeMaterialConnectionPoint;
  54115. /**
  54116. * Gets the w component (output)
  54117. */
  54118. readonly w: NodeMaterialConnectionPoint;
  54119. protected _inputRename(name: string): string;
  54120. protected _outputRename(name: string): string;
  54121. protected _buildBlock(state: NodeMaterialBuildState): this;
  54122. }
  54123. }
  54124. declare module BABYLON {
  54125. /**
  54126. * Block used to lerp between 2 values
  54127. */
  54128. export class LerpBlock extends NodeMaterialBlock {
  54129. /**
  54130. * Creates a new LerpBlock
  54131. * @param name defines the block name
  54132. */
  54133. constructor(name: string);
  54134. /**
  54135. * Gets the current class name
  54136. * @returns the class name
  54137. */
  54138. getClassName(): string;
  54139. /**
  54140. * Gets the left operand input component
  54141. */
  54142. readonly left: NodeMaterialConnectionPoint;
  54143. /**
  54144. * Gets the right operand input component
  54145. */
  54146. readonly right: NodeMaterialConnectionPoint;
  54147. /**
  54148. * Gets the gradient operand input component
  54149. */
  54150. readonly gradient: NodeMaterialConnectionPoint;
  54151. /**
  54152. * Gets the output component
  54153. */
  54154. readonly output: NodeMaterialConnectionPoint;
  54155. protected _buildBlock(state: NodeMaterialBuildState): this;
  54156. }
  54157. }
  54158. declare module BABYLON {
  54159. /**
  54160. * Block used to divide 2 vectors
  54161. */
  54162. export class DivideBlock extends NodeMaterialBlock {
  54163. /**
  54164. * Creates a new DivideBlock
  54165. * @param name defines the block name
  54166. */
  54167. constructor(name: string);
  54168. /**
  54169. * Gets the current class name
  54170. * @returns the class name
  54171. */
  54172. getClassName(): string;
  54173. /**
  54174. * Gets the left operand input component
  54175. */
  54176. readonly left: NodeMaterialConnectionPoint;
  54177. /**
  54178. * Gets the right operand input component
  54179. */
  54180. readonly right: NodeMaterialConnectionPoint;
  54181. /**
  54182. * Gets the output component
  54183. */
  54184. readonly output: NodeMaterialConnectionPoint;
  54185. protected _buildBlock(state: NodeMaterialBuildState): this;
  54186. }
  54187. }
  54188. declare module BABYLON {
  54189. /**
  54190. * Block used to subtract 2 vectors
  54191. */
  54192. export class SubtractBlock extends NodeMaterialBlock {
  54193. /**
  54194. * Creates a new SubtractBlock
  54195. * @param name defines the block name
  54196. */
  54197. constructor(name: string);
  54198. /**
  54199. * Gets the current class name
  54200. * @returns the class name
  54201. */
  54202. getClassName(): string;
  54203. /**
  54204. * Gets the left operand input component
  54205. */
  54206. readonly left: NodeMaterialConnectionPoint;
  54207. /**
  54208. * Gets the right operand input component
  54209. */
  54210. readonly right: NodeMaterialConnectionPoint;
  54211. /**
  54212. * Gets the output component
  54213. */
  54214. readonly output: NodeMaterialConnectionPoint;
  54215. protected _buildBlock(state: NodeMaterialBuildState): this;
  54216. }
  54217. }
  54218. declare module BABYLON {
  54219. /**
  54220. * Block used to step a value
  54221. */
  54222. export class StepBlock extends NodeMaterialBlock {
  54223. /**
  54224. * Creates a new StepBlock
  54225. * @param name defines the block name
  54226. */
  54227. constructor(name: string);
  54228. /**
  54229. * Gets the current class name
  54230. * @returns the class name
  54231. */
  54232. getClassName(): string;
  54233. /**
  54234. * Gets the value operand input component
  54235. */
  54236. readonly value: NodeMaterialConnectionPoint;
  54237. /**
  54238. * Gets the edge operand input component
  54239. */
  54240. readonly edge: NodeMaterialConnectionPoint;
  54241. /**
  54242. * Gets the output component
  54243. */
  54244. readonly output: NodeMaterialConnectionPoint;
  54245. protected _buildBlock(state: NodeMaterialBuildState): this;
  54246. }
  54247. }
  54248. declare module BABYLON {
  54249. /**
  54250. * Block used to get the opposite (1 - x) of a value
  54251. */
  54252. export class OneMinusBlock extends NodeMaterialBlock {
  54253. /**
  54254. * Creates a new OneMinusBlock
  54255. * @param name defines the block name
  54256. */
  54257. constructor(name: string);
  54258. /**
  54259. * Gets the current class name
  54260. * @returns the class name
  54261. */
  54262. getClassName(): string;
  54263. /**
  54264. * Gets the input component
  54265. */
  54266. readonly input: NodeMaterialConnectionPoint;
  54267. /**
  54268. * Gets the output component
  54269. */
  54270. readonly output: NodeMaterialConnectionPoint;
  54271. protected _buildBlock(state: NodeMaterialBuildState): this;
  54272. }
  54273. }
  54274. declare module BABYLON {
  54275. /**
  54276. * Block used to get the view direction
  54277. */
  54278. export class ViewDirectionBlock extends NodeMaterialBlock {
  54279. /**
  54280. * Creates a new ViewDirectionBlock
  54281. * @param name defines the block name
  54282. */
  54283. constructor(name: string);
  54284. /**
  54285. * Gets the current class name
  54286. * @returns the class name
  54287. */
  54288. getClassName(): string;
  54289. /**
  54290. * Gets the world position component
  54291. */
  54292. readonly worldPosition: NodeMaterialConnectionPoint;
  54293. /**
  54294. * Gets the camera position component
  54295. */
  54296. readonly cameraPosition: NodeMaterialConnectionPoint;
  54297. /**
  54298. * Gets the output component
  54299. */
  54300. readonly output: NodeMaterialConnectionPoint;
  54301. autoConfigure(material: NodeMaterial): void;
  54302. protected _buildBlock(state: NodeMaterialBuildState): this;
  54303. }
  54304. }
  54305. declare module BABYLON {
  54306. /**
  54307. * Block used to compute fresnel value
  54308. */
  54309. export class FresnelBlock extends NodeMaterialBlock {
  54310. /**
  54311. * Create a new FresnelBlock
  54312. * @param name defines the block name
  54313. */
  54314. constructor(name: string);
  54315. /**
  54316. * Gets the current class name
  54317. * @returns the class name
  54318. */
  54319. getClassName(): string;
  54320. /**
  54321. * Gets the world normal input component
  54322. */
  54323. readonly worldNormal: NodeMaterialConnectionPoint;
  54324. /**
  54325. * Gets the view direction input component
  54326. */
  54327. readonly viewDirection: NodeMaterialConnectionPoint;
  54328. /**
  54329. * Gets the bias input component
  54330. */
  54331. readonly bias: NodeMaterialConnectionPoint;
  54332. /**
  54333. * Gets the camera (or eye) position component
  54334. */
  54335. readonly power: NodeMaterialConnectionPoint;
  54336. /**
  54337. * Gets the fresnel output component
  54338. */
  54339. readonly fresnel: NodeMaterialConnectionPoint;
  54340. autoConfigure(material: NodeMaterial): void;
  54341. protected _buildBlock(state: NodeMaterialBuildState): this;
  54342. }
  54343. }
  54344. declare module BABYLON {
  54345. /**
  54346. * Block used to get the max of 2 values
  54347. */
  54348. export class MaxBlock extends NodeMaterialBlock {
  54349. /**
  54350. * Creates a new MaxBlock
  54351. * @param name defines the block name
  54352. */
  54353. constructor(name: string);
  54354. /**
  54355. * Gets the current class name
  54356. * @returns the class name
  54357. */
  54358. getClassName(): string;
  54359. /**
  54360. * Gets the left operand input component
  54361. */
  54362. readonly left: NodeMaterialConnectionPoint;
  54363. /**
  54364. * Gets the right operand input component
  54365. */
  54366. readonly right: NodeMaterialConnectionPoint;
  54367. /**
  54368. * Gets the output component
  54369. */
  54370. readonly output: NodeMaterialConnectionPoint;
  54371. protected _buildBlock(state: NodeMaterialBuildState): this;
  54372. }
  54373. }
  54374. declare module BABYLON {
  54375. /**
  54376. * Block used to get the min of 2 values
  54377. */
  54378. export class MinBlock extends NodeMaterialBlock {
  54379. /**
  54380. * Creates a new MinBlock
  54381. * @param name defines the block name
  54382. */
  54383. constructor(name: string);
  54384. /**
  54385. * Gets the current class name
  54386. * @returns the class name
  54387. */
  54388. getClassName(): string;
  54389. /**
  54390. * Gets the left operand input component
  54391. */
  54392. readonly left: NodeMaterialConnectionPoint;
  54393. /**
  54394. * Gets the right operand input component
  54395. */
  54396. readonly right: NodeMaterialConnectionPoint;
  54397. /**
  54398. * Gets the output component
  54399. */
  54400. readonly output: NodeMaterialConnectionPoint;
  54401. protected _buildBlock(state: NodeMaterialBuildState): this;
  54402. }
  54403. }
  54404. declare module BABYLON {
  54405. /**
  54406. * Block used to get the distance between 2 values
  54407. */
  54408. export class DistanceBlock extends NodeMaterialBlock {
  54409. /**
  54410. * Creates a new DistanceBlock
  54411. * @param name defines the block name
  54412. */
  54413. constructor(name: string);
  54414. /**
  54415. * Gets the current class name
  54416. * @returns the class name
  54417. */
  54418. getClassName(): string;
  54419. /**
  54420. * Gets the left operand input component
  54421. */
  54422. readonly left: NodeMaterialConnectionPoint;
  54423. /**
  54424. * Gets the right operand input component
  54425. */
  54426. readonly right: NodeMaterialConnectionPoint;
  54427. /**
  54428. * Gets the output component
  54429. */
  54430. readonly output: NodeMaterialConnectionPoint;
  54431. protected _buildBlock(state: NodeMaterialBuildState): this;
  54432. }
  54433. }
  54434. declare module BABYLON {
  54435. /**
  54436. * Block used to get the length of a vector
  54437. */
  54438. export class LengthBlock extends NodeMaterialBlock {
  54439. /**
  54440. * Creates a new LengthBlock
  54441. * @param name defines the block name
  54442. */
  54443. constructor(name: string);
  54444. /**
  54445. * Gets the current class name
  54446. * @returns the class name
  54447. */
  54448. getClassName(): string;
  54449. /**
  54450. * Gets the value input component
  54451. */
  54452. readonly value: NodeMaterialConnectionPoint;
  54453. /**
  54454. * Gets the output component
  54455. */
  54456. readonly output: NodeMaterialConnectionPoint;
  54457. protected _buildBlock(state: NodeMaterialBuildState): this;
  54458. }
  54459. }
  54460. declare module BABYLON {
  54461. /**
  54462. * Block used to get negative version of a value (i.e. x * -1)
  54463. */
  54464. export class NegateBlock extends NodeMaterialBlock {
  54465. /**
  54466. * Creates a new NegateBlock
  54467. * @param name defines the block name
  54468. */
  54469. constructor(name: string);
  54470. /**
  54471. * Gets the current class name
  54472. * @returns the class name
  54473. */
  54474. getClassName(): string;
  54475. /**
  54476. * Gets the value input component
  54477. */
  54478. readonly value: NodeMaterialConnectionPoint;
  54479. /**
  54480. * Gets the output component
  54481. */
  54482. readonly output: NodeMaterialConnectionPoint;
  54483. protected _buildBlock(state: NodeMaterialBuildState): this;
  54484. }
  54485. }
  54486. declare module BABYLON {
  54487. /**
  54488. * Block used to get the value of the first parameter raised to the power of the second
  54489. */
  54490. export class PowBlock extends NodeMaterialBlock {
  54491. /**
  54492. * Creates a new PowBlock
  54493. * @param name defines the block name
  54494. */
  54495. constructor(name: string);
  54496. /**
  54497. * Gets the current class name
  54498. * @returns the class name
  54499. */
  54500. getClassName(): string;
  54501. /**
  54502. * Gets the value operand input component
  54503. */
  54504. readonly value: NodeMaterialConnectionPoint;
  54505. /**
  54506. * Gets the power operand input component
  54507. */
  54508. readonly power: NodeMaterialConnectionPoint;
  54509. /**
  54510. * Gets the output component
  54511. */
  54512. readonly output: NodeMaterialConnectionPoint;
  54513. protected _buildBlock(state: NodeMaterialBuildState): this;
  54514. }
  54515. }
  54516. declare module BABYLON {
  54517. /**
  54518. * Block used to get a random number
  54519. */
  54520. export class RandomNumberBlock extends NodeMaterialBlock {
  54521. /**
  54522. * Creates a new RandomNumberBlock
  54523. * @param name defines the block name
  54524. */
  54525. constructor(name: string);
  54526. /**
  54527. * Gets the current class name
  54528. * @returns the class name
  54529. */
  54530. getClassName(): string;
  54531. /**
  54532. * Gets the seed input component
  54533. */
  54534. readonly seed: NodeMaterialConnectionPoint;
  54535. /**
  54536. * Gets the output component
  54537. */
  54538. readonly output: NodeMaterialConnectionPoint;
  54539. protected _buildBlock(state: NodeMaterialBuildState): this;
  54540. }
  54541. }
  54542. declare module BABYLON {
  54543. /**
  54544. * Block used to compute arc tangent of 2 values
  54545. */
  54546. export class ArcTan2Block extends NodeMaterialBlock {
  54547. /**
  54548. * Creates a new ArcTan2Block
  54549. * @param name defines the block name
  54550. */
  54551. constructor(name: string);
  54552. /**
  54553. * Gets the current class name
  54554. * @returns the class name
  54555. */
  54556. getClassName(): string;
  54557. /**
  54558. * Gets the x operand input component
  54559. */
  54560. readonly x: NodeMaterialConnectionPoint;
  54561. /**
  54562. * Gets the y operand input component
  54563. */
  54564. readonly y: NodeMaterialConnectionPoint;
  54565. /**
  54566. * Gets the output component
  54567. */
  54568. readonly output: NodeMaterialConnectionPoint;
  54569. protected _buildBlock(state: NodeMaterialBuildState): this;
  54570. }
  54571. }
  54572. declare module BABYLON {
  54573. /**
  54574. * Block used to smooth step a value
  54575. */
  54576. export class SmoothStepBlock extends NodeMaterialBlock {
  54577. /**
  54578. * Creates a new SmoothStepBlock
  54579. * @param name defines the block name
  54580. */
  54581. constructor(name: string);
  54582. /**
  54583. * Gets the current class name
  54584. * @returns the class name
  54585. */
  54586. getClassName(): string;
  54587. /**
  54588. * Gets the value operand input component
  54589. */
  54590. readonly value: NodeMaterialConnectionPoint;
  54591. /**
  54592. * Gets the first edge operand input component
  54593. */
  54594. readonly edge0: NodeMaterialConnectionPoint;
  54595. /**
  54596. * Gets the second edge operand input component
  54597. */
  54598. readonly edge1: NodeMaterialConnectionPoint;
  54599. /**
  54600. * Gets the output component
  54601. */
  54602. readonly output: NodeMaterialConnectionPoint;
  54603. protected _buildBlock(state: NodeMaterialBuildState): this;
  54604. }
  54605. }
  54606. declare module BABYLON {
  54607. /**
  54608. * Block used to get the reciprocal (1 / x) of a value
  54609. */
  54610. export class ReciprocalBlock extends NodeMaterialBlock {
  54611. /**
  54612. * Creates a new ReciprocalBlock
  54613. * @param name defines the block name
  54614. */
  54615. constructor(name: string);
  54616. /**
  54617. * Gets the current class name
  54618. * @returns the class name
  54619. */
  54620. getClassName(): string;
  54621. /**
  54622. * Gets the input component
  54623. */
  54624. readonly input: NodeMaterialConnectionPoint;
  54625. /**
  54626. * Gets the output component
  54627. */
  54628. readonly output: NodeMaterialConnectionPoint;
  54629. protected _buildBlock(state: NodeMaterialBuildState): this;
  54630. }
  54631. }
  54632. declare module BABYLON {
  54633. /**
  54634. * Block used to replace a color by another one
  54635. */
  54636. export class ReplaceColorBlock extends NodeMaterialBlock {
  54637. /**
  54638. * Creates a new ReplaceColorBlock
  54639. * @param name defines the block name
  54640. */
  54641. constructor(name: string);
  54642. /**
  54643. * Gets the current class name
  54644. * @returns the class name
  54645. */
  54646. getClassName(): string;
  54647. /**
  54648. * Gets the value input component
  54649. */
  54650. readonly value: NodeMaterialConnectionPoint;
  54651. /**
  54652. * Gets the reference input component
  54653. */
  54654. readonly reference: NodeMaterialConnectionPoint;
  54655. /**
  54656. * Gets the distance input component
  54657. */
  54658. readonly distance: NodeMaterialConnectionPoint;
  54659. /**
  54660. * Gets the replacement input component
  54661. */
  54662. readonly replacement: NodeMaterialConnectionPoint;
  54663. /**
  54664. * Gets the output component
  54665. */
  54666. readonly output: NodeMaterialConnectionPoint;
  54667. protected _buildBlock(state: NodeMaterialBuildState): this;
  54668. }
  54669. }
  54670. declare module BABYLON {
  54671. /**
  54672. * Block used to posterize a value
  54673. * @see https://en.wikipedia.org/wiki/Posterization
  54674. */
  54675. export class PosterizeBlock extends NodeMaterialBlock {
  54676. /**
  54677. * Creates a new PosterizeBlock
  54678. * @param name defines the block name
  54679. */
  54680. constructor(name: string);
  54681. /**
  54682. * Gets the current class name
  54683. * @returns the class name
  54684. */
  54685. getClassName(): string;
  54686. /**
  54687. * Gets the value input component
  54688. */
  54689. readonly value: NodeMaterialConnectionPoint;
  54690. /**
  54691. * Gets the steps input component
  54692. */
  54693. readonly steps: NodeMaterialConnectionPoint;
  54694. /**
  54695. * Gets the output component
  54696. */
  54697. readonly output: NodeMaterialConnectionPoint;
  54698. protected _buildBlock(state: NodeMaterialBuildState): this;
  54699. }
  54700. }
  54701. declare module BABYLON {
  54702. /**
  54703. * Operations supported by the Wave block
  54704. */
  54705. export enum WaveBlockKind {
  54706. /** SawTooth */
  54707. SawTooth = 0,
  54708. /** Square */
  54709. Square = 1,
  54710. /** Triangle */
  54711. Triangle = 2
  54712. }
  54713. /**
  54714. * Block used to apply wave operation to floats
  54715. */
  54716. export class WaveBlock extends NodeMaterialBlock {
  54717. /**
  54718. * Gets or sets the kibnd of wave to be applied by the block
  54719. */
  54720. kind: WaveBlockKind;
  54721. /**
  54722. * Creates a new WaveBlock
  54723. * @param name defines the block name
  54724. */
  54725. constructor(name: string);
  54726. /**
  54727. * Gets the current class name
  54728. * @returns the class name
  54729. */
  54730. getClassName(): string;
  54731. /**
  54732. * Gets the input component
  54733. */
  54734. readonly input: NodeMaterialConnectionPoint;
  54735. /**
  54736. * Gets the output component
  54737. */
  54738. readonly output: NodeMaterialConnectionPoint;
  54739. protected _buildBlock(state: NodeMaterialBuildState): this;
  54740. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54741. }
  54742. }
  54743. declare module BABYLON {
  54744. /**
  54745. * Class used to store a color step for the GradientBlock
  54746. */
  54747. export class GradientBlockColorStep {
  54748. /**
  54749. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  54750. */
  54751. step: number;
  54752. /**
  54753. * Gets or sets the color associated with this step
  54754. */
  54755. color: Color3;
  54756. /**
  54757. * Creates a new GradientBlockColorStep
  54758. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  54759. * @param color defines the color associated with this step
  54760. */
  54761. constructor(
  54762. /**
  54763. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  54764. */
  54765. step: number,
  54766. /**
  54767. * Gets or sets the color associated with this step
  54768. */
  54769. color: Color3);
  54770. }
  54771. /**
  54772. * Block used to return a color from a gradient based on an input value between 0 and 1
  54773. */
  54774. export class GradientBlock extends NodeMaterialBlock {
  54775. /**
  54776. * Gets or sets the list of color steps
  54777. */
  54778. colorSteps: GradientBlockColorStep[];
  54779. /**
  54780. * Creates a new GradientBlock
  54781. * @param name defines the block name
  54782. */
  54783. constructor(name: string);
  54784. /**
  54785. * Gets the current class name
  54786. * @returns the class name
  54787. */
  54788. getClassName(): string;
  54789. /**
  54790. * Gets the gradient input component
  54791. */
  54792. readonly gradient: NodeMaterialConnectionPoint;
  54793. /**
  54794. * Gets the output component
  54795. */
  54796. readonly output: NodeMaterialConnectionPoint;
  54797. private _writeColorConstant;
  54798. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54799. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54800. protected _dumpPropertiesCode(): string;
  54801. }
  54802. }
  54803. declare module BABYLON {
  54804. /**
  54805. * Block used to normalize lerp between 2 values
  54806. */
  54807. export class NLerpBlock extends NodeMaterialBlock {
  54808. /**
  54809. * Creates a new NLerpBlock
  54810. * @param name defines the block name
  54811. */
  54812. constructor(name: string);
  54813. /**
  54814. * Gets the current class name
  54815. * @returns the class name
  54816. */
  54817. getClassName(): string;
  54818. /**
  54819. * Gets the left operand input component
  54820. */
  54821. readonly left: NodeMaterialConnectionPoint;
  54822. /**
  54823. * Gets the right operand input component
  54824. */
  54825. readonly right: NodeMaterialConnectionPoint;
  54826. /**
  54827. * Gets the gradient operand input component
  54828. */
  54829. readonly gradient: NodeMaterialConnectionPoint;
  54830. /**
  54831. * Gets the output component
  54832. */
  54833. readonly output: NodeMaterialConnectionPoint;
  54834. protected _buildBlock(state: NodeMaterialBuildState): this;
  54835. }
  54836. }
  54837. declare module BABYLON {
  54838. /**
  54839. * Effect Render Options
  54840. */
  54841. export interface IEffectRendererOptions {
  54842. /**
  54843. * Defines the vertices positions.
  54844. */
  54845. positions?: number[];
  54846. /**
  54847. * Defines the indices.
  54848. */
  54849. indices?: number[];
  54850. }
  54851. /**
  54852. * Helper class to render one or more effects
  54853. */
  54854. export class EffectRenderer {
  54855. private engine;
  54856. private static _DefaultOptions;
  54857. private _vertexBuffers;
  54858. private _indexBuffer;
  54859. private _ringBufferIndex;
  54860. private _ringScreenBuffer;
  54861. private _fullscreenViewport;
  54862. private _getNextFrameBuffer;
  54863. /**
  54864. * Creates an effect renderer
  54865. * @param engine the engine to use for rendering
  54866. * @param options defines the options of the effect renderer
  54867. */
  54868. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  54869. /**
  54870. * Sets the current viewport in normalized coordinates 0-1
  54871. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  54872. */
  54873. setViewport(viewport?: Viewport): void;
  54874. /**
  54875. * Binds the embedded attributes buffer to the effect.
  54876. * @param effect Defines the effect to bind the attributes for
  54877. */
  54878. bindBuffers(effect: Effect): void;
  54879. /**
  54880. * Sets the current effect wrapper to use during draw.
  54881. * The effect needs to be ready before calling this api.
  54882. * This also sets the default full screen position attribute.
  54883. * @param effectWrapper Defines the effect to draw with
  54884. */
  54885. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  54886. /**
  54887. * Draws a full screen quad.
  54888. */
  54889. draw(): void;
  54890. /**
  54891. * renders one or more effects to a specified texture
  54892. * @param effectWrappers list of effects to renderer
  54893. * @param outputTexture texture to draw to, if null it will render to the screen
  54894. */
  54895. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  54896. /**
  54897. * Disposes of the effect renderer
  54898. */
  54899. dispose(): void;
  54900. }
  54901. /**
  54902. * Options to create an EffectWrapper
  54903. */
  54904. interface EffectWrapperCreationOptions {
  54905. /**
  54906. * Engine to use to create the effect
  54907. */
  54908. engine: ThinEngine;
  54909. /**
  54910. * Fragment shader for the effect
  54911. */
  54912. fragmentShader: string;
  54913. /**
  54914. * Vertex shader for the effect
  54915. */
  54916. vertexShader?: string;
  54917. /**
  54918. * Attributes to use in the shader
  54919. */
  54920. attributeNames?: Array<string>;
  54921. /**
  54922. * Uniforms to use in the shader
  54923. */
  54924. uniformNames?: Array<string>;
  54925. /**
  54926. * Texture sampler names to use in the shader
  54927. */
  54928. samplerNames?: Array<string>;
  54929. /**
  54930. * The friendly name of the effect displayed in Spector.
  54931. */
  54932. name?: string;
  54933. }
  54934. /**
  54935. * Wraps an effect to be used for rendering
  54936. */
  54937. export class EffectWrapper {
  54938. /**
  54939. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  54940. */
  54941. onApplyObservable: Observable<{}>;
  54942. /**
  54943. * The underlying effect
  54944. */
  54945. effect: Effect;
  54946. /**
  54947. * Creates an effect to be renderer
  54948. * @param creationOptions options to create the effect
  54949. */
  54950. constructor(creationOptions: EffectWrapperCreationOptions);
  54951. /**
  54952. * Disposes of the effect wrapper
  54953. */
  54954. dispose(): void;
  54955. }
  54956. }
  54957. declare module BABYLON {
  54958. /**
  54959. * Helper class to push actions to a pool of workers.
  54960. */
  54961. export class WorkerPool implements IDisposable {
  54962. private _workerInfos;
  54963. private _pendingActions;
  54964. /**
  54965. * Constructor
  54966. * @param workers Array of workers to use for actions
  54967. */
  54968. constructor(workers: Array<Worker>);
  54969. /**
  54970. * Terminates all workers and clears any pending actions.
  54971. */
  54972. dispose(): void;
  54973. /**
  54974. * Pushes an action to the worker pool. If all the workers are active, the action will be
  54975. * pended until a worker has completed its action.
  54976. * @param action The action to perform. Call onComplete when the action is complete.
  54977. */
  54978. push(action: (worker: Worker, onComplete: () => void) => void): void;
  54979. private _execute;
  54980. }
  54981. }
  54982. declare module BABYLON {
  54983. /**
  54984. * Configuration for Draco compression
  54985. */
  54986. export interface IDracoCompressionConfiguration {
  54987. /**
  54988. * Configuration for the decoder.
  54989. */
  54990. decoder: {
  54991. /**
  54992. * The url to the WebAssembly module.
  54993. */
  54994. wasmUrl?: string;
  54995. /**
  54996. * The url to the WebAssembly binary.
  54997. */
  54998. wasmBinaryUrl?: string;
  54999. /**
  55000. * The url to the fallback JavaScript module.
  55001. */
  55002. fallbackUrl?: string;
  55003. };
  55004. }
  55005. /**
  55006. * Draco compression (https://google.github.io/draco/)
  55007. *
  55008. * This class wraps the Draco module.
  55009. *
  55010. * **Encoder**
  55011. *
  55012. * The encoder is not currently implemented.
  55013. *
  55014. * **Decoder**
  55015. *
  55016. * 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.
  55017. *
  55018. * To update the configuration, use the following code:
  55019. * ```javascript
  55020. * DracoCompression.Configuration = {
  55021. * decoder: {
  55022. * wasmUrl: "<url to the WebAssembly library>",
  55023. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  55024. * fallbackUrl: "<url to the fallback JavaScript library>",
  55025. * }
  55026. * };
  55027. * ```
  55028. *
  55029. * 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.
  55030. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  55031. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  55032. *
  55033. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  55034. * ```javascript
  55035. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  55036. * ```
  55037. *
  55038. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  55039. */
  55040. export class DracoCompression implements IDisposable {
  55041. private _workerPoolPromise?;
  55042. private _decoderModulePromise?;
  55043. /**
  55044. * The configuration. Defaults to the following urls:
  55045. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  55046. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  55047. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  55048. */
  55049. static Configuration: IDracoCompressionConfiguration;
  55050. /**
  55051. * Returns true if the decoder configuration is available.
  55052. */
  55053. static readonly DecoderAvailable: boolean;
  55054. /**
  55055. * Default number of workers to create when creating the draco compression object.
  55056. */
  55057. static DefaultNumWorkers: number;
  55058. private static GetDefaultNumWorkers;
  55059. private static _Default;
  55060. /**
  55061. * Default instance for the draco compression object.
  55062. */
  55063. static readonly Default: DracoCompression;
  55064. /**
  55065. * Constructor
  55066. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  55067. */
  55068. constructor(numWorkers?: number);
  55069. /**
  55070. * Stop all async operations and release resources.
  55071. */
  55072. dispose(): void;
  55073. /**
  55074. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  55075. * @returns a promise that resolves when ready
  55076. */
  55077. whenReadyAsync(): Promise<void>;
  55078. /**
  55079. * Decode Draco compressed mesh data to vertex data.
  55080. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  55081. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  55082. * @returns A promise that resolves with the decoded vertex data
  55083. */
  55084. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  55085. [kind: string]: number;
  55086. }): Promise<VertexData>;
  55087. }
  55088. }
  55089. declare module BABYLON {
  55090. /**
  55091. * Class for building Constructive Solid Geometry
  55092. */
  55093. export class CSG {
  55094. private polygons;
  55095. /**
  55096. * The world matrix
  55097. */
  55098. matrix: Matrix;
  55099. /**
  55100. * Stores the position
  55101. */
  55102. position: Vector3;
  55103. /**
  55104. * Stores the rotation
  55105. */
  55106. rotation: Vector3;
  55107. /**
  55108. * Stores the rotation quaternion
  55109. */
  55110. rotationQuaternion: Nullable<Quaternion>;
  55111. /**
  55112. * Stores the scaling vector
  55113. */
  55114. scaling: Vector3;
  55115. /**
  55116. * Convert the Mesh to CSG
  55117. * @param mesh The Mesh to convert to CSG
  55118. * @returns A new CSG from the Mesh
  55119. */
  55120. static FromMesh(mesh: Mesh): CSG;
  55121. /**
  55122. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  55123. * @param polygons Polygons used to construct a CSG solid
  55124. */
  55125. private static FromPolygons;
  55126. /**
  55127. * Clones, or makes a deep copy, of the CSG
  55128. * @returns A new CSG
  55129. */
  55130. clone(): CSG;
  55131. /**
  55132. * Unions this CSG with another CSG
  55133. * @param csg The CSG to union against this CSG
  55134. * @returns The unioned CSG
  55135. */
  55136. union(csg: CSG): CSG;
  55137. /**
  55138. * Unions this CSG with another CSG in place
  55139. * @param csg The CSG to union against this CSG
  55140. */
  55141. unionInPlace(csg: CSG): void;
  55142. /**
  55143. * Subtracts this CSG with another CSG
  55144. * @param csg The CSG to subtract against this CSG
  55145. * @returns A new CSG
  55146. */
  55147. subtract(csg: CSG): CSG;
  55148. /**
  55149. * Subtracts this CSG with another CSG in place
  55150. * @param csg The CSG to subtact against this CSG
  55151. */
  55152. subtractInPlace(csg: CSG): void;
  55153. /**
  55154. * Intersect this CSG with another CSG
  55155. * @param csg The CSG to intersect against this CSG
  55156. * @returns A new CSG
  55157. */
  55158. intersect(csg: CSG): CSG;
  55159. /**
  55160. * Intersects this CSG with another CSG in place
  55161. * @param csg The CSG to intersect against this CSG
  55162. */
  55163. intersectInPlace(csg: CSG): void;
  55164. /**
  55165. * Return a new CSG solid with solid and empty space switched. This solid is
  55166. * not modified.
  55167. * @returns A new CSG solid with solid and empty space switched
  55168. */
  55169. inverse(): CSG;
  55170. /**
  55171. * Inverses the CSG in place
  55172. */
  55173. inverseInPlace(): void;
  55174. /**
  55175. * This is used to keep meshes transformations so they can be restored
  55176. * when we build back a Babylon Mesh
  55177. * NB : All CSG operations are performed in world coordinates
  55178. * @param csg The CSG to copy the transform attributes from
  55179. * @returns This CSG
  55180. */
  55181. copyTransformAttributes(csg: CSG): CSG;
  55182. /**
  55183. * Build Raw mesh from CSG
  55184. * Coordinates here are in world space
  55185. * @param name The name of the mesh geometry
  55186. * @param scene The Scene
  55187. * @param keepSubMeshes Specifies if the submeshes should be kept
  55188. * @returns A new Mesh
  55189. */
  55190. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  55191. /**
  55192. * Build Mesh from CSG taking material and transforms into account
  55193. * @param name The name of the Mesh
  55194. * @param material The material of the Mesh
  55195. * @param scene The Scene
  55196. * @param keepSubMeshes Specifies if submeshes should be kept
  55197. * @returns The new Mesh
  55198. */
  55199. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  55200. }
  55201. }
  55202. declare module BABYLON {
  55203. /**
  55204. * Class used to create a trail following a mesh
  55205. */
  55206. export class TrailMesh extends Mesh {
  55207. private _generator;
  55208. private _autoStart;
  55209. private _running;
  55210. private _diameter;
  55211. private _length;
  55212. private _sectionPolygonPointsCount;
  55213. private _sectionVectors;
  55214. private _sectionNormalVectors;
  55215. private _beforeRenderObserver;
  55216. /**
  55217. * @constructor
  55218. * @param name The value used by scene.getMeshByName() to do a lookup.
  55219. * @param generator The mesh to generate a trail.
  55220. * @param scene The scene to add this mesh to.
  55221. * @param diameter Diameter of trailing mesh. Default is 1.
  55222. * @param length Length of trailing mesh. Default is 60.
  55223. * @param autoStart Automatically start trailing mesh. Default true.
  55224. */
  55225. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  55226. /**
  55227. * "TrailMesh"
  55228. * @returns "TrailMesh"
  55229. */
  55230. getClassName(): string;
  55231. private _createMesh;
  55232. /**
  55233. * Start trailing mesh.
  55234. */
  55235. start(): void;
  55236. /**
  55237. * Stop trailing mesh.
  55238. */
  55239. stop(): void;
  55240. /**
  55241. * Update trailing mesh geometry.
  55242. */
  55243. update(): void;
  55244. /**
  55245. * Returns a new TrailMesh object.
  55246. * @param name is a string, the name given to the new mesh
  55247. * @param newGenerator use new generator object for cloned trail mesh
  55248. * @returns a new mesh
  55249. */
  55250. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  55251. /**
  55252. * Serializes this trail mesh
  55253. * @param serializationObject object to write serialization to
  55254. */
  55255. serialize(serializationObject: any): void;
  55256. /**
  55257. * Parses a serialized trail mesh
  55258. * @param parsedMesh the serialized mesh
  55259. * @param scene the scene to create the trail mesh in
  55260. * @returns the created trail mesh
  55261. */
  55262. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  55263. }
  55264. }
  55265. declare module BABYLON {
  55266. /**
  55267. * Class containing static functions to help procedurally build meshes
  55268. */
  55269. export class TiledBoxBuilder {
  55270. /**
  55271. * Creates a box mesh
  55272. * faceTiles sets the pattern, tile size and number of tiles for a face * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of 6 Color3 elements) and `faceUV` (an array of 6 Vector4 elements)
  55273. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55274. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55275. * * 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
  55276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55277. * @param name defines the name of the mesh
  55278. * @param options defines the options used to create the mesh
  55279. * @param scene defines the hosting scene
  55280. * @returns the box mesh
  55281. */
  55282. static CreateTiledBox(name: string, options: {
  55283. pattern?: number;
  55284. width?: number;
  55285. height?: number;
  55286. depth?: number;
  55287. tileSize?: number;
  55288. tileWidth?: number;
  55289. tileHeight?: number;
  55290. alignHorizontal?: number;
  55291. alignVertical?: number;
  55292. faceUV?: Vector4[];
  55293. faceColors?: Color4[];
  55294. sideOrientation?: number;
  55295. updatable?: boolean;
  55296. }, scene?: Nullable<Scene>): Mesh;
  55297. }
  55298. }
  55299. declare module BABYLON {
  55300. /**
  55301. * Class containing static functions to help procedurally build meshes
  55302. */
  55303. export class TorusKnotBuilder {
  55304. /**
  55305. * Creates a torus knot mesh
  55306. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55307. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55308. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55309. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55310. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55311. * * 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
  55312. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55313. * @param name defines the name of the mesh
  55314. * @param options defines the options used to create the mesh
  55315. * @param scene defines the hosting scene
  55316. * @returns the torus knot mesh
  55317. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55318. */
  55319. static CreateTorusKnot(name: string, options: {
  55320. radius?: number;
  55321. tube?: number;
  55322. radialSegments?: number;
  55323. tubularSegments?: number;
  55324. p?: number;
  55325. q?: number;
  55326. updatable?: boolean;
  55327. sideOrientation?: number;
  55328. frontUVs?: Vector4;
  55329. backUVs?: Vector4;
  55330. }, scene: any): Mesh;
  55331. }
  55332. }
  55333. declare module BABYLON {
  55334. /**
  55335. * Polygon
  55336. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  55337. */
  55338. export class Polygon {
  55339. /**
  55340. * Creates a rectangle
  55341. * @param xmin bottom X coord
  55342. * @param ymin bottom Y coord
  55343. * @param xmax top X coord
  55344. * @param ymax top Y coord
  55345. * @returns points that make the resulting rectation
  55346. */
  55347. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  55348. /**
  55349. * Creates a circle
  55350. * @param radius radius of circle
  55351. * @param cx scale in x
  55352. * @param cy scale in y
  55353. * @param numberOfSides number of sides that make up the circle
  55354. * @returns points that make the resulting circle
  55355. */
  55356. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  55357. /**
  55358. * Creates a polygon from input string
  55359. * @param input Input polygon data
  55360. * @returns the parsed points
  55361. */
  55362. static Parse(input: string): Vector2[];
  55363. /**
  55364. * Starts building a polygon from x and y coordinates
  55365. * @param x x coordinate
  55366. * @param y y coordinate
  55367. * @returns the started path2
  55368. */
  55369. static StartingAt(x: number, y: number): Path2;
  55370. }
  55371. /**
  55372. * Builds a polygon
  55373. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  55374. */
  55375. export class PolygonMeshBuilder {
  55376. private _points;
  55377. private _outlinepoints;
  55378. private _holes;
  55379. private _name;
  55380. private _scene;
  55381. private _epoints;
  55382. private _eholes;
  55383. private _addToepoint;
  55384. /**
  55385. * Babylon reference to the earcut plugin.
  55386. */
  55387. bjsEarcut: any;
  55388. /**
  55389. * Creates a PolygonMeshBuilder
  55390. * @param name name of the builder
  55391. * @param contours Path of the polygon
  55392. * @param scene scene to add to when creating the mesh
  55393. * @param earcutInjection can be used to inject your own earcut reference
  55394. */
  55395. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  55396. /**
  55397. * Adds a whole within the polygon
  55398. * @param hole Array of points defining the hole
  55399. * @returns this
  55400. */
  55401. addHole(hole: Vector2[]): PolygonMeshBuilder;
  55402. /**
  55403. * Creates the polygon
  55404. * @param updatable If the mesh should be updatable
  55405. * @param depth The depth of the mesh created
  55406. * @returns the created mesh
  55407. */
  55408. build(updatable?: boolean, depth?: number): Mesh;
  55409. /**
  55410. * Creates the polygon
  55411. * @param depth The depth of the mesh created
  55412. * @returns the created VertexData
  55413. */
  55414. buildVertexData(depth?: number): VertexData;
  55415. /**
  55416. * Adds a side to the polygon
  55417. * @param positions points that make the polygon
  55418. * @param normals normals of the polygon
  55419. * @param uvs uvs of the polygon
  55420. * @param indices indices of the polygon
  55421. * @param bounds bounds of the polygon
  55422. * @param points points of the polygon
  55423. * @param depth depth of the polygon
  55424. * @param flip flip of the polygon
  55425. */
  55426. private addSide;
  55427. }
  55428. }
  55429. declare module BABYLON {
  55430. /**
  55431. * Class containing static functions to help procedurally build meshes
  55432. */
  55433. export class PolygonBuilder {
  55434. /**
  55435. * Creates a polygon mesh
  55436. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55437. * * 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
  55438. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55439. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55440. * * 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)
  55441. * * Remember you can only change the shape positions, not their number when updating a polygon
  55442. * @param name defines the name of the mesh
  55443. * @param options defines the options used to create the mesh
  55444. * @param scene defines the hosting scene
  55445. * @param earcutInjection can be used to inject your own earcut reference
  55446. * @returns the polygon mesh
  55447. */
  55448. static CreatePolygon(name: string, options: {
  55449. shape: Vector3[];
  55450. holes?: Vector3[][];
  55451. depth?: number;
  55452. faceUV?: Vector4[];
  55453. faceColors?: Color4[];
  55454. updatable?: boolean;
  55455. sideOrientation?: number;
  55456. frontUVs?: Vector4;
  55457. backUVs?: Vector4;
  55458. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55459. /**
  55460. * Creates an extruded polygon mesh, with depth in the Y direction.
  55461. * * 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)
  55462. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55463. * @param name defines the name of the mesh
  55464. * @param options defines the options used to create the mesh
  55465. * @param scene defines the hosting scene
  55466. * @param earcutInjection can be used to inject your own earcut reference
  55467. * @returns the polygon mesh
  55468. */
  55469. static ExtrudePolygon(name: string, options: {
  55470. shape: Vector3[];
  55471. holes?: Vector3[][];
  55472. depth?: number;
  55473. faceUV?: Vector4[];
  55474. faceColors?: Color4[];
  55475. updatable?: boolean;
  55476. sideOrientation?: number;
  55477. frontUVs?: Vector4;
  55478. backUVs?: Vector4;
  55479. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55480. }
  55481. }
  55482. declare module BABYLON {
  55483. /**
  55484. * Class containing static functions to help procedurally build meshes
  55485. */
  55486. export class LatheBuilder {
  55487. /**
  55488. * Creates lathe mesh.
  55489. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55490. * * 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
  55491. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55492. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55493. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55494. * * 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
  55495. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55496. * * 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
  55497. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55498. * * 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
  55499. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55501. * @param name defines the name of the mesh
  55502. * @param options defines the options used to create the mesh
  55503. * @param scene defines the hosting scene
  55504. * @returns the lathe mesh
  55505. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55506. */
  55507. static CreateLathe(name: string, options: {
  55508. shape: Vector3[];
  55509. radius?: number;
  55510. tessellation?: number;
  55511. clip?: number;
  55512. arc?: number;
  55513. closed?: boolean;
  55514. updatable?: boolean;
  55515. sideOrientation?: number;
  55516. frontUVs?: Vector4;
  55517. backUVs?: Vector4;
  55518. cap?: number;
  55519. invertUV?: boolean;
  55520. }, scene?: Nullable<Scene>): Mesh;
  55521. }
  55522. }
  55523. declare module BABYLON {
  55524. /**
  55525. * Class containing static functions to help procedurally build meshes
  55526. */
  55527. export class TiledPlaneBuilder {
  55528. /**
  55529. * Creates a tiled plane mesh
  55530. * * The parameter `pattern` will, depending on value, do nothing or
  55531. * * * flip (reflect about central vertical) alternate tiles across and up
  55532. * * * flip every tile on alternate rows
  55533. * * * rotate (180 degs) alternate tiles across and up
  55534. * * * rotate every tile on alternate rows
  55535. * * * flip and rotate alternate tiles across and up
  55536. * * * flip and rotate every tile on alternate rows
  55537. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  55538. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  55539. * * 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
  55540. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55541. * * 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)
  55542. * * 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)
  55543. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55544. * @param name defines the name of the mesh
  55545. * @param options defines the options used to create the mesh
  55546. * @param scene defines the hosting scene
  55547. * @returns the box mesh
  55548. */
  55549. static CreateTiledPlane(name: string, options: {
  55550. pattern?: number;
  55551. tileSize?: number;
  55552. tileWidth?: number;
  55553. tileHeight?: number;
  55554. size?: number;
  55555. width?: number;
  55556. height?: number;
  55557. alignHorizontal?: number;
  55558. alignVertical?: number;
  55559. sideOrientation?: number;
  55560. frontUVs?: Vector4;
  55561. backUVs?: Vector4;
  55562. updatable?: boolean;
  55563. }, scene?: Nullable<Scene>): Mesh;
  55564. }
  55565. }
  55566. declare module BABYLON {
  55567. /**
  55568. * Class containing static functions to help procedurally build meshes
  55569. */
  55570. export class TubeBuilder {
  55571. /**
  55572. * Creates a tube mesh.
  55573. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55574. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55575. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55576. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55577. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55578. * * 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)
  55579. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55580. * * 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
  55581. * * 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
  55582. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55583. * * 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
  55584. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55585. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55586. * @param name defines the name of the mesh
  55587. * @param options defines the options used to create the mesh
  55588. * @param scene defines the hosting scene
  55589. * @returns the tube mesh
  55590. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55591. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55592. */
  55593. static CreateTube(name: string, options: {
  55594. path: Vector3[];
  55595. radius?: number;
  55596. tessellation?: number;
  55597. radiusFunction?: {
  55598. (i: number, distance: number): number;
  55599. };
  55600. cap?: number;
  55601. arc?: number;
  55602. updatable?: boolean;
  55603. sideOrientation?: number;
  55604. frontUVs?: Vector4;
  55605. backUVs?: Vector4;
  55606. instance?: Mesh;
  55607. invertUV?: boolean;
  55608. }, scene?: Nullable<Scene>): Mesh;
  55609. }
  55610. }
  55611. declare module BABYLON {
  55612. /**
  55613. * Class containing static functions to help procedurally build meshes
  55614. */
  55615. export class IcoSphereBuilder {
  55616. /**
  55617. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55618. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55619. * * 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`)
  55620. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55621. * * 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
  55622. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55623. * * 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
  55624. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55625. * @param name defines the name of the mesh
  55626. * @param options defines the options used to create the mesh
  55627. * @param scene defines the hosting scene
  55628. * @returns the icosahedron mesh
  55629. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55630. */
  55631. static CreateIcoSphere(name: string, options: {
  55632. radius?: number;
  55633. radiusX?: number;
  55634. radiusY?: number;
  55635. radiusZ?: number;
  55636. flat?: boolean;
  55637. subdivisions?: number;
  55638. sideOrientation?: number;
  55639. frontUVs?: Vector4;
  55640. backUVs?: Vector4;
  55641. updatable?: boolean;
  55642. }, scene?: Nullable<Scene>): Mesh;
  55643. }
  55644. }
  55645. declare module BABYLON {
  55646. /**
  55647. * Class containing static functions to help procedurally build meshes
  55648. */
  55649. export class DecalBuilder {
  55650. /**
  55651. * Creates a decal mesh.
  55652. * 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
  55653. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55654. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55655. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55656. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55657. * @param name defines the name of the mesh
  55658. * @param sourceMesh defines the mesh where the decal must be applied
  55659. * @param options defines the options used to create the mesh
  55660. * @param scene defines the hosting scene
  55661. * @returns the decal mesh
  55662. * @see https://doc.babylonjs.com/how_to/decals
  55663. */
  55664. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55665. position?: Vector3;
  55666. normal?: Vector3;
  55667. size?: Vector3;
  55668. angle?: number;
  55669. }): Mesh;
  55670. }
  55671. }
  55672. declare module BABYLON {
  55673. /**
  55674. * Class containing static functions to help procedurally build meshes
  55675. */
  55676. export class MeshBuilder {
  55677. /**
  55678. * Creates a box mesh
  55679. * * The parameter `size` sets the size (float) of each box side (default 1)
  55680. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  55681. * * 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)
  55682. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55683. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55684. * * 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
  55685. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55686. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55687. * @param name defines the name of the mesh
  55688. * @param options defines the options used to create the mesh
  55689. * @param scene defines the hosting scene
  55690. * @returns the box mesh
  55691. */
  55692. static CreateBox(name: string, options: {
  55693. size?: number;
  55694. width?: number;
  55695. height?: number;
  55696. depth?: number;
  55697. faceUV?: Vector4[];
  55698. faceColors?: Color4[];
  55699. sideOrientation?: number;
  55700. frontUVs?: Vector4;
  55701. backUVs?: Vector4;
  55702. updatable?: boolean;
  55703. }, scene?: Nullable<Scene>): Mesh;
  55704. /**
  55705. * Creates a tiled box mesh
  55706. * * faceTiles sets the pattern, tile size and number of tiles for a face
  55707. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55708. * @param name defines the name of the mesh
  55709. * @param options defines the options used to create the mesh
  55710. * @param scene defines the hosting scene
  55711. * @returns the tiled box mesh
  55712. */
  55713. static CreateTiledBox(name: string, options: {
  55714. pattern?: number;
  55715. size?: number;
  55716. width?: number;
  55717. height?: number;
  55718. depth: number;
  55719. tileSize?: number;
  55720. tileWidth?: number;
  55721. tileHeight?: number;
  55722. faceUV?: Vector4[];
  55723. faceColors?: Color4[];
  55724. alignHorizontal?: number;
  55725. alignVertical?: number;
  55726. sideOrientation?: number;
  55727. updatable?: boolean;
  55728. }, scene?: Nullable<Scene>): Mesh;
  55729. /**
  55730. * Creates a sphere mesh
  55731. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  55732. * * 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`)
  55733. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  55734. * * 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
  55735. * * 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)
  55736. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55737. * * 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
  55738. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55739. * @param name defines the name of the mesh
  55740. * @param options defines the options used to create the mesh
  55741. * @param scene defines the hosting scene
  55742. * @returns the sphere mesh
  55743. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  55744. */
  55745. static CreateSphere(name: string, options: {
  55746. segments?: number;
  55747. diameter?: number;
  55748. diameterX?: number;
  55749. diameterY?: number;
  55750. diameterZ?: number;
  55751. arc?: number;
  55752. slice?: number;
  55753. sideOrientation?: number;
  55754. frontUVs?: Vector4;
  55755. backUVs?: Vector4;
  55756. updatable?: boolean;
  55757. }, scene?: Nullable<Scene>): Mesh;
  55758. /**
  55759. * Creates a plane polygonal mesh. By default, this is a disc
  55760. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  55761. * * 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
  55762. * * 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
  55763. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55764. * * 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
  55765. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55766. * @param name defines the name of the mesh
  55767. * @param options defines the options used to create the mesh
  55768. * @param scene defines the hosting scene
  55769. * @returns the plane polygonal mesh
  55770. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  55771. */
  55772. static CreateDisc(name: string, options: {
  55773. radius?: number;
  55774. tessellation?: number;
  55775. arc?: number;
  55776. updatable?: boolean;
  55777. sideOrientation?: number;
  55778. frontUVs?: Vector4;
  55779. backUVs?: Vector4;
  55780. }, scene?: Nullable<Scene>): Mesh;
  55781. /**
  55782. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55783. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55784. * * 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`)
  55785. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55786. * * 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
  55787. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55788. * * 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
  55789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55790. * @param name defines the name of the mesh
  55791. * @param options defines the options used to create the mesh
  55792. * @param scene defines the hosting scene
  55793. * @returns the icosahedron mesh
  55794. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55795. */
  55796. static CreateIcoSphere(name: string, options: {
  55797. radius?: number;
  55798. radiusX?: number;
  55799. radiusY?: number;
  55800. radiusZ?: number;
  55801. flat?: boolean;
  55802. subdivisions?: number;
  55803. sideOrientation?: number;
  55804. frontUVs?: Vector4;
  55805. backUVs?: Vector4;
  55806. updatable?: boolean;
  55807. }, scene?: Nullable<Scene>): Mesh;
  55808. /**
  55809. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55810. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55811. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55812. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55813. * * 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
  55814. * * 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
  55815. * * 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
  55816. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55817. * * 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
  55818. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55819. * * 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
  55820. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55821. * * 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
  55822. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55823. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55824. * @param name defines the name of the mesh
  55825. * @param options defines the options used to create the mesh
  55826. * @param scene defines the hosting scene
  55827. * @returns the ribbon mesh
  55828. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55829. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55830. */
  55831. static CreateRibbon(name: string, options: {
  55832. pathArray: Vector3[][];
  55833. closeArray?: boolean;
  55834. closePath?: boolean;
  55835. offset?: number;
  55836. updatable?: boolean;
  55837. sideOrientation?: number;
  55838. frontUVs?: Vector4;
  55839. backUVs?: Vector4;
  55840. instance?: Mesh;
  55841. invertUV?: boolean;
  55842. uvs?: Vector2[];
  55843. colors?: Color4[];
  55844. }, scene?: Nullable<Scene>): Mesh;
  55845. /**
  55846. * Creates a cylinder or a cone mesh
  55847. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  55848. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  55849. * * 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.
  55850. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  55851. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  55852. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  55853. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  55854. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  55855. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  55856. * * 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).
  55857. * * 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
  55858. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  55859. * * 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
  55860. * * 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.
  55861. * * If `enclose` is false, a ring surface is one element.
  55862. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  55863. * * 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
  55864. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55865. * * 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
  55866. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55867. * @param name defines the name of the mesh
  55868. * @param options defines the options used to create the mesh
  55869. * @param scene defines the hosting scene
  55870. * @returns the cylinder mesh
  55871. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  55872. */
  55873. static CreateCylinder(name: string, options: {
  55874. height?: number;
  55875. diameterTop?: number;
  55876. diameterBottom?: number;
  55877. diameter?: number;
  55878. tessellation?: number;
  55879. subdivisions?: number;
  55880. arc?: number;
  55881. faceColors?: Color4[];
  55882. faceUV?: Vector4[];
  55883. updatable?: boolean;
  55884. hasRings?: boolean;
  55885. enclose?: boolean;
  55886. cap?: number;
  55887. sideOrientation?: number;
  55888. frontUVs?: Vector4;
  55889. backUVs?: Vector4;
  55890. }, scene?: Nullable<Scene>): Mesh;
  55891. /**
  55892. * Creates a torus mesh
  55893. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  55894. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  55895. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  55896. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55897. * * 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
  55898. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55899. * @param name defines the name of the mesh
  55900. * @param options defines the options used to create the mesh
  55901. * @param scene defines the hosting scene
  55902. * @returns the torus mesh
  55903. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  55904. */
  55905. static CreateTorus(name: string, options: {
  55906. diameter?: number;
  55907. thickness?: number;
  55908. tessellation?: number;
  55909. updatable?: boolean;
  55910. sideOrientation?: number;
  55911. frontUVs?: Vector4;
  55912. backUVs?: Vector4;
  55913. }, scene?: Nullable<Scene>): Mesh;
  55914. /**
  55915. * Creates a torus knot mesh
  55916. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55917. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55918. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55919. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55920. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55921. * * 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
  55922. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55923. * @param name defines the name of the mesh
  55924. * @param options defines the options used to create the mesh
  55925. * @param scene defines the hosting scene
  55926. * @returns the torus knot mesh
  55927. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55928. */
  55929. static CreateTorusKnot(name: string, options: {
  55930. radius?: number;
  55931. tube?: number;
  55932. radialSegments?: number;
  55933. tubularSegments?: number;
  55934. p?: number;
  55935. q?: number;
  55936. updatable?: boolean;
  55937. sideOrientation?: number;
  55938. frontUVs?: Vector4;
  55939. backUVs?: Vector4;
  55940. }, scene?: Nullable<Scene>): Mesh;
  55941. /**
  55942. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  55943. * * 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
  55944. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  55945. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  55946. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  55947. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  55948. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55949. * * 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
  55950. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  55951. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55952. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  55953. * @param name defines the name of the new line system
  55954. * @param options defines the options used to create the line system
  55955. * @param scene defines the hosting scene
  55956. * @returns a new line system mesh
  55957. */
  55958. static CreateLineSystem(name: string, options: {
  55959. lines: Vector3[][];
  55960. updatable?: boolean;
  55961. instance?: Nullable<LinesMesh>;
  55962. colors?: Nullable<Color4[][]>;
  55963. useVertexAlpha?: boolean;
  55964. }, scene: Nullable<Scene>): LinesMesh;
  55965. /**
  55966. * Creates a line mesh
  55967. * 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
  55968. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55969. * * The parameter `points` is an array successive Vector3
  55970. * * 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
  55971. * * The optional parameter `colors` is an array of successive Color4, one per line point
  55972. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  55973. * * When updating an instance, remember that only point positions can change, not the number of points
  55974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55975. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  55976. * @param name defines the name of the new line system
  55977. * @param options defines the options used to create the line system
  55978. * @param scene defines the hosting scene
  55979. * @returns a new line mesh
  55980. */
  55981. static CreateLines(name: string, options: {
  55982. points: Vector3[];
  55983. updatable?: boolean;
  55984. instance?: Nullable<LinesMesh>;
  55985. colors?: Color4[];
  55986. useVertexAlpha?: boolean;
  55987. }, scene?: Nullable<Scene>): LinesMesh;
  55988. /**
  55989. * Creates a dashed line mesh
  55990. * * 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
  55991. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55992. * * The parameter `points` is an array successive Vector3
  55993. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55994. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55995. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55996. * * 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
  55997. * * When updating an instance, remember that only point positions can change, not the number of points
  55998. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55999. * @param name defines the name of the mesh
  56000. * @param options defines the options used to create the mesh
  56001. * @param scene defines the hosting scene
  56002. * @returns the dashed line mesh
  56003. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  56004. */
  56005. static CreateDashedLines(name: string, options: {
  56006. points: Vector3[];
  56007. dashSize?: number;
  56008. gapSize?: number;
  56009. dashNb?: number;
  56010. updatable?: boolean;
  56011. instance?: LinesMesh;
  56012. }, scene?: Nullable<Scene>): LinesMesh;
  56013. /**
  56014. * 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.
  56015. * * 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.
  56016. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56017. * * 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.
  56018. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56019. * * 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
  56020. * * 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
  56021. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56022. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56023. * * 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
  56024. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56025. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56026. * @param name defines the name of the mesh
  56027. * @param options defines the options used to create the mesh
  56028. * @param scene defines the hosting scene
  56029. * @returns the extruded shape mesh
  56030. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56031. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56032. */
  56033. static ExtrudeShape(name: string, options: {
  56034. shape: Vector3[];
  56035. path: Vector3[];
  56036. scale?: number;
  56037. rotation?: number;
  56038. cap?: number;
  56039. updatable?: boolean;
  56040. sideOrientation?: number;
  56041. frontUVs?: Vector4;
  56042. backUVs?: Vector4;
  56043. instance?: Mesh;
  56044. invertUV?: boolean;
  56045. }, scene?: Nullable<Scene>): Mesh;
  56046. /**
  56047. * Creates an custom extruded shape mesh.
  56048. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56049. * * 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.
  56050. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56051. * * 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
  56052. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56053. * * 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
  56054. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56055. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56056. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56057. * * 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
  56058. * * 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
  56059. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56060. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56061. * * 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
  56062. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56063. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56064. * @param name defines the name of the mesh
  56065. * @param options defines the options used to create the mesh
  56066. * @param scene defines the hosting scene
  56067. * @returns the custom extruded shape mesh
  56068. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56069. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56070. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56071. */
  56072. static ExtrudeShapeCustom(name: string, options: {
  56073. shape: Vector3[];
  56074. path: Vector3[];
  56075. scaleFunction?: any;
  56076. rotationFunction?: any;
  56077. ribbonCloseArray?: boolean;
  56078. ribbonClosePath?: boolean;
  56079. cap?: number;
  56080. updatable?: boolean;
  56081. sideOrientation?: number;
  56082. frontUVs?: Vector4;
  56083. backUVs?: Vector4;
  56084. instance?: Mesh;
  56085. invertUV?: boolean;
  56086. }, scene?: Nullable<Scene>): Mesh;
  56087. /**
  56088. * Creates lathe mesh.
  56089. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56090. * * 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
  56091. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56092. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56093. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56094. * * 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
  56095. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56096. * * 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
  56097. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56098. * * 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
  56099. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56101. * @param name defines the name of the mesh
  56102. * @param options defines the options used to create the mesh
  56103. * @param scene defines the hosting scene
  56104. * @returns the lathe mesh
  56105. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56106. */
  56107. static CreateLathe(name: string, options: {
  56108. shape: Vector3[];
  56109. radius?: number;
  56110. tessellation?: number;
  56111. clip?: number;
  56112. arc?: number;
  56113. closed?: boolean;
  56114. updatable?: boolean;
  56115. sideOrientation?: number;
  56116. frontUVs?: Vector4;
  56117. backUVs?: Vector4;
  56118. cap?: number;
  56119. invertUV?: boolean;
  56120. }, scene?: Nullable<Scene>): Mesh;
  56121. /**
  56122. * Creates a tiled plane mesh
  56123. * * You can set a limited pattern arrangement with the tiles
  56124. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56125. * * 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
  56126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56127. * @param name defines the name of the mesh
  56128. * @param options defines the options used to create the mesh
  56129. * @param scene defines the hosting scene
  56130. * @returns the plane mesh
  56131. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56132. */
  56133. static CreateTiledPlane(name: string, options: {
  56134. pattern?: number;
  56135. tileSize?: number;
  56136. tileWidth?: number;
  56137. tileHeight?: number;
  56138. size?: number;
  56139. width?: number;
  56140. height?: number;
  56141. alignHorizontal?: number;
  56142. alignVertical?: number;
  56143. sideOrientation?: number;
  56144. frontUVs?: Vector4;
  56145. backUVs?: Vector4;
  56146. updatable?: boolean;
  56147. }, scene?: Nullable<Scene>): Mesh;
  56148. /**
  56149. * Creates a plane mesh
  56150. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  56151. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  56152. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  56153. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56154. * * 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
  56155. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56156. * @param name defines the name of the mesh
  56157. * @param options defines the options used to create the mesh
  56158. * @param scene defines the hosting scene
  56159. * @returns the plane mesh
  56160. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56161. */
  56162. static CreatePlane(name: string, options: {
  56163. size?: number;
  56164. width?: number;
  56165. height?: number;
  56166. sideOrientation?: number;
  56167. frontUVs?: Vector4;
  56168. backUVs?: Vector4;
  56169. updatable?: boolean;
  56170. sourcePlane?: Plane;
  56171. }, scene?: Nullable<Scene>): Mesh;
  56172. /**
  56173. * Creates a ground mesh
  56174. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  56175. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  56176. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56177. * @param name defines the name of the mesh
  56178. * @param options defines the options used to create the mesh
  56179. * @param scene defines the hosting scene
  56180. * @returns the ground mesh
  56181. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  56182. */
  56183. static CreateGround(name: string, options: {
  56184. width?: number;
  56185. height?: number;
  56186. subdivisions?: number;
  56187. subdivisionsX?: number;
  56188. subdivisionsY?: number;
  56189. updatable?: boolean;
  56190. }, scene?: Nullable<Scene>): Mesh;
  56191. /**
  56192. * Creates a tiled ground mesh
  56193. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  56194. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  56195. * * 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
  56196. * * 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
  56197. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56198. * @param name defines the name of the mesh
  56199. * @param options defines the options used to create the mesh
  56200. * @param scene defines the hosting scene
  56201. * @returns the tiled ground mesh
  56202. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  56203. */
  56204. static CreateTiledGround(name: string, options: {
  56205. xmin: number;
  56206. zmin: number;
  56207. xmax: number;
  56208. zmax: number;
  56209. subdivisions?: {
  56210. w: number;
  56211. h: number;
  56212. };
  56213. precision?: {
  56214. w: number;
  56215. h: number;
  56216. };
  56217. updatable?: boolean;
  56218. }, scene?: Nullable<Scene>): Mesh;
  56219. /**
  56220. * Creates a ground mesh from a height map
  56221. * * The parameter `url` sets the URL of the height map image resource.
  56222. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  56223. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  56224. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  56225. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  56226. * * 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.
  56227. * * 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).
  56228. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  56229. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56230. * @param name defines the name of the mesh
  56231. * @param url defines the url to the height map
  56232. * @param options defines the options used to create the mesh
  56233. * @param scene defines the hosting scene
  56234. * @returns the ground mesh
  56235. * @see https://doc.babylonjs.com/babylon101/height_map
  56236. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  56237. */
  56238. static CreateGroundFromHeightMap(name: string, url: string, options: {
  56239. width?: number;
  56240. height?: number;
  56241. subdivisions?: number;
  56242. minHeight?: number;
  56243. maxHeight?: number;
  56244. colorFilter?: Color3;
  56245. alphaFilter?: number;
  56246. updatable?: boolean;
  56247. onReady?: (mesh: GroundMesh) => void;
  56248. }, scene?: Nullable<Scene>): GroundMesh;
  56249. /**
  56250. * Creates a polygon mesh
  56251. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56252. * * 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
  56253. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56255. * * 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)
  56256. * * Remember you can only change the shape positions, not their number when updating a polygon
  56257. * @param name defines the name of the mesh
  56258. * @param options defines the options used to create the mesh
  56259. * @param scene defines the hosting scene
  56260. * @param earcutInjection can be used to inject your own earcut reference
  56261. * @returns the polygon mesh
  56262. */
  56263. static CreatePolygon(name: string, options: {
  56264. shape: Vector3[];
  56265. holes?: Vector3[][];
  56266. depth?: number;
  56267. faceUV?: Vector4[];
  56268. faceColors?: Color4[];
  56269. updatable?: boolean;
  56270. sideOrientation?: number;
  56271. frontUVs?: Vector4;
  56272. backUVs?: Vector4;
  56273. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56274. /**
  56275. * Creates an extruded polygon mesh, with depth in the Y direction.
  56276. * * 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)
  56277. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56278. * @param name defines the name of the mesh
  56279. * @param options defines the options used to create the mesh
  56280. * @param scene defines the hosting scene
  56281. * @param earcutInjection can be used to inject your own earcut reference
  56282. * @returns the polygon mesh
  56283. */
  56284. static ExtrudePolygon(name: string, options: {
  56285. shape: Vector3[];
  56286. holes?: Vector3[][];
  56287. depth?: number;
  56288. faceUV?: Vector4[];
  56289. faceColors?: Color4[];
  56290. updatable?: boolean;
  56291. sideOrientation?: number;
  56292. frontUVs?: Vector4;
  56293. backUVs?: Vector4;
  56294. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56295. /**
  56296. * Creates a tube mesh.
  56297. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56298. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56299. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56300. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56301. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56302. * * 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)
  56303. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56304. * * 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
  56305. * * 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
  56306. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56307. * * 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
  56308. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56309. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56310. * @param name defines the name of the mesh
  56311. * @param options defines the options used to create the mesh
  56312. * @param scene defines the hosting scene
  56313. * @returns the tube mesh
  56314. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56315. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56316. */
  56317. static CreateTube(name: string, options: {
  56318. path: Vector3[];
  56319. radius?: number;
  56320. tessellation?: number;
  56321. radiusFunction?: {
  56322. (i: number, distance: number): number;
  56323. };
  56324. cap?: number;
  56325. arc?: number;
  56326. updatable?: boolean;
  56327. sideOrientation?: number;
  56328. frontUVs?: Vector4;
  56329. backUVs?: Vector4;
  56330. instance?: Mesh;
  56331. invertUV?: boolean;
  56332. }, scene?: Nullable<Scene>): Mesh;
  56333. /**
  56334. * Creates a polyhedron mesh
  56335. * * 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
  56336. * * The parameter `size` (positive float, default 1) sets the polygon size
  56337. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56338. * * 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`
  56339. * * 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
  56340. * * 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)`)
  56341. * * 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
  56342. * * 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
  56343. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56344. * * 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
  56345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56346. * @param name defines the name of the mesh
  56347. * @param options defines the options used to create the mesh
  56348. * @param scene defines the hosting scene
  56349. * @returns the polyhedron mesh
  56350. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56351. */
  56352. static CreatePolyhedron(name: string, options: {
  56353. type?: number;
  56354. size?: number;
  56355. sizeX?: number;
  56356. sizeY?: number;
  56357. sizeZ?: number;
  56358. custom?: any;
  56359. faceUV?: Vector4[];
  56360. faceColors?: Color4[];
  56361. flat?: boolean;
  56362. updatable?: boolean;
  56363. sideOrientation?: number;
  56364. frontUVs?: Vector4;
  56365. backUVs?: Vector4;
  56366. }, scene?: Nullable<Scene>): Mesh;
  56367. /**
  56368. * Creates a decal mesh.
  56369. * 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
  56370. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56371. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56372. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56373. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56374. * @param name defines the name of the mesh
  56375. * @param sourceMesh defines the mesh where the decal must be applied
  56376. * @param options defines the options used to create the mesh
  56377. * @param scene defines the hosting scene
  56378. * @returns the decal mesh
  56379. * @see https://doc.babylonjs.com/how_to/decals
  56380. */
  56381. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56382. position?: Vector3;
  56383. normal?: Vector3;
  56384. size?: Vector3;
  56385. angle?: number;
  56386. }): Mesh;
  56387. }
  56388. }
  56389. declare module BABYLON {
  56390. /**
  56391. * A simplifier interface for future simplification implementations
  56392. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56393. */
  56394. export interface ISimplifier {
  56395. /**
  56396. * Simplification of a given mesh according to the given settings.
  56397. * Since this requires computation, it is assumed that the function runs async.
  56398. * @param settings The settings of the simplification, including quality and distance
  56399. * @param successCallback A callback that will be called after the mesh was simplified.
  56400. * @param errorCallback in case of an error, this callback will be called. optional.
  56401. */
  56402. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  56403. }
  56404. /**
  56405. * Expected simplification settings.
  56406. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  56407. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56408. */
  56409. export interface ISimplificationSettings {
  56410. /**
  56411. * Gets or sets the expected quality
  56412. */
  56413. quality: number;
  56414. /**
  56415. * Gets or sets the distance when this optimized version should be used
  56416. */
  56417. distance: number;
  56418. /**
  56419. * Gets an already optimized mesh
  56420. */
  56421. optimizeMesh?: boolean;
  56422. }
  56423. /**
  56424. * Class used to specify simplification options
  56425. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56426. */
  56427. export class SimplificationSettings implements ISimplificationSettings {
  56428. /** expected quality */
  56429. quality: number;
  56430. /** distance when this optimized version should be used */
  56431. distance: number;
  56432. /** already optimized mesh */
  56433. optimizeMesh?: boolean | undefined;
  56434. /**
  56435. * Creates a SimplificationSettings
  56436. * @param quality expected quality
  56437. * @param distance distance when this optimized version should be used
  56438. * @param optimizeMesh already optimized mesh
  56439. */
  56440. constructor(
  56441. /** expected quality */
  56442. quality: number,
  56443. /** distance when this optimized version should be used */
  56444. distance: number,
  56445. /** already optimized mesh */
  56446. optimizeMesh?: boolean | undefined);
  56447. }
  56448. /**
  56449. * Interface used to define a simplification task
  56450. */
  56451. export interface ISimplificationTask {
  56452. /**
  56453. * Array of settings
  56454. */
  56455. settings: Array<ISimplificationSettings>;
  56456. /**
  56457. * Simplification type
  56458. */
  56459. simplificationType: SimplificationType;
  56460. /**
  56461. * Mesh to simplify
  56462. */
  56463. mesh: Mesh;
  56464. /**
  56465. * Callback called on success
  56466. */
  56467. successCallback?: () => void;
  56468. /**
  56469. * Defines if parallel processing can be used
  56470. */
  56471. parallelProcessing: boolean;
  56472. }
  56473. /**
  56474. * Queue used to order the simplification tasks
  56475. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56476. */
  56477. export class SimplificationQueue {
  56478. private _simplificationArray;
  56479. /**
  56480. * Gets a boolean indicating that the process is still running
  56481. */
  56482. running: boolean;
  56483. /**
  56484. * Creates a new queue
  56485. */
  56486. constructor();
  56487. /**
  56488. * Adds a new simplification task
  56489. * @param task defines a task to add
  56490. */
  56491. addTask(task: ISimplificationTask): void;
  56492. /**
  56493. * Execute next task
  56494. */
  56495. executeNext(): void;
  56496. /**
  56497. * Execute a simplification task
  56498. * @param task defines the task to run
  56499. */
  56500. runSimplification(task: ISimplificationTask): void;
  56501. private getSimplifier;
  56502. }
  56503. /**
  56504. * The implemented types of simplification
  56505. * At the moment only Quadratic Error Decimation is implemented
  56506. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56507. */
  56508. export enum SimplificationType {
  56509. /** Quadratic error decimation */
  56510. QUADRATIC = 0
  56511. }
  56512. }
  56513. declare module BABYLON {
  56514. interface Scene {
  56515. /** @hidden (Backing field) */ private _simplificationQueue: SimplificationQueue;
  56516. /**
  56517. * Gets or sets the simplification queue attached to the scene
  56518. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56519. */
  56520. simplificationQueue: SimplificationQueue;
  56521. }
  56522. interface Mesh {
  56523. /**
  56524. * Simplify the mesh according to the given array of settings.
  56525. * Function will return immediately and will simplify async
  56526. * @param settings a collection of simplification settings
  56527. * @param parallelProcessing should all levels calculate parallel or one after the other
  56528. * @param simplificationType the type of simplification to run
  56529. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  56530. * @returns the current mesh
  56531. */
  56532. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  56533. }
  56534. /**
  56535. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  56536. * created in a scene
  56537. */
  56538. export class SimplicationQueueSceneComponent implements ISceneComponent {
  56539. /**
  56540. * The component name helpfull to identify the component in the list of scene components.
  56541. */
  56542. readonly name: string;
  56543. /**
  56544. * The scene the component belongs to.
  56545. */
  56546. scene: Scene;
  56547. /**
  56548. * Creates a new instance of the component for the given scene
  56549. * @param scene Defines the scene to register the component in
  56550. */
  56551. constructor(scene: Scene);
  56552. /**
  56553. * Registers the component in a given scene
  56554. */
  56555. register(): void;
  56556. /**
  56557. * Rebuilds the elements related to this component in case of
  56558. * context lost for instance.
  56559. */
  56560. rebuild(): void;
  56561. /**
  56562. * Disposes the component and the associated ressources
  56563. */
  56564. dispose(): void;
  56565. private _beforeCameraUpdate;
  56566. }
  56567. }
  56568. declare module BABYLON {
  56569. /**
  56570. * Navigation plugin interface to add navigation constrained by a navigation mesh
  56571. */
  56572. export interface INavigationEnginePlugin {
  56573. /**
  56574. * plugin name
  56575. */
  56576. name: string;
  56577. /**
  56578. * Creates a navigation mesh
  56579. * @param meshes array of all the geometry used to compute the navigatio mesh
  56580. * @param parameters bunch of parameters used to filter geometry
  56581. */
  56582. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  56583. /**
  56584. * Create a navigation mesh debug mesh
  56585. * @param scene is where the mesh will be added
  56586. * @returns debug display mesh
  56587. */
  56588. createDebugNavMesh(scene: Scene): Mesh;
  56589. /**
  56590. * Get a navigation mesh constrained position, closest to the parameter position
  56591. * @param position world position
  56592. * @returns the closest point to position constrained by the navigation mesh
  56593. */
  56594. getClosestPoint(position: Vector3): Vector3;
  56595. /**
  56596. * Get a navigation mesh constrained position, within a particular radius
  56597. * @param position world position
  56598. * @param maxRadius the maximum distance to the constrained world position
  56599. * @returns the closest point to position constrained by the navigation mesh
  56600. */
  56601. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  56602. /**
  56603. * Compute the final position from a segment made of destination-position
  56604. * @param position world position
  56605. * @param destination world position
  56606. * @returns the resulting point along the navmesh
  56607. */
  56608. moveAlong(position: Vector3, destination: Vector3): Vector3;
  56609. /**
  56610. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  56611. * @param start world position
  56612. * @param end world position
  56613. * @returns array containing world position composing the path
  56614. */
  56615. computePath(start: Vector3, end: Vector3): Vector3[];
  56616. /**
  56617. * If this plugin is supported
  56618. * @returns true if plugin is supported
  56619. */
  56620. isSupported(): boolean;
  56621. /**
  56622. * Create a new Crowd so you can add agents
  56623. * @param maxAgents the maximum agent count in the crowd
  56624. * @param maxAgentRadius the maximum radius an agent can have
  56625. * @param scene to attach the crowd to
  56626. * @returns the crowd you can add agents to
  56627. */
  56628. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  56629. /**
  56630. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56631. * The queries will try to find a solution within those bounds
  56632. * default is (1,1,1)
  56633. * @param extent x,y,z value that define the extent around the queries point of reference
  56634. */
  56635. setDefaultQueryExtent(extent: Vector3): void;
  56636. /**
  56637. * Get the Bounding box extent specified by setDefaultQueryExtent
  56638. * @returns the box extent values
  56639. */
  56640. getDefaultQueryExtent(): Vector3;
  56641. /**
  56642. * Release all resources
  56643. */
  56644. dispose(): void;
  56645. }
  56646. /**
  56647. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  56648. */
  56649. export interface ICrowd {
  56650. /**
  56651. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  56652. * You can attach anything to that node. The node position is updated in the scene update tick.
  56653. * @param pos world position that will be constrained by the navigation mesh
  56654. * @param parameters agent parameters
  56655. * @param transform hooked to the agent that will be update by the scene
  56656. * @returns agent index
  56657. */
  56658. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  56659. /**
  56660. * Returns the agent position in world space
  56661. * @param index agent index returned by addAgent
  56662. * @returns world space position
  56663. */
  56664. getAgentPosition(index: number): Vector3;
  56665. /**
  56666. * Gets the agent velocity in world space
  56667. * @param index agent index returned by addAgent
  56668. * @returns world space velocity
  56669. */
  56670. getAgentVelocity(index: number): Vector3;
  56671. /**
  56672. * remove a particular agent previously created
  56673. * @param index agent index returned by addAgent
  56674. */
  56675. removeAgent(index: number): void;
  56676. /**
  56677. * get the list of all agents attached to this crowd
  56678. * @returns list of agent indices
  56679. */
  56680. getAgents(): number[];
  56681. /**
  56682. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  56683. * @param deltaTime in seconds
  56684. */
  56685. update(deltaTime: number): void;
  56686. /**
  56687. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  56688. * @param index agent index returned by addAgent
  56689. * @param destination targeted world position
  56690. */
  56691. agentGoto(index: number, destination: Vector3): void;
  56692. /**
  56693. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56694. * The queries will try to find a solution within those bounds
  56695. * default is (1,1,1)
  56696. * @param extent x,y,z value that define the extent around the queries point of reference
  56697. */
  56698. setDefaultQueryExtent(extent: Vector3): void;
  56699. /**
  56700. * Get the Bounding box extent specified by setDefaultQueryExtent
  56701. * @returns the box extent values
  56702. */
  56703. getDefaultQueryExtent(): Vector3;
  56704. /**
  56705. * Release all resources
  56706. */
  56707. dispose(): void;
  56708. }
  56709. /**
  56710. * Configures an agent
  56711. */
  56712. export interface IAgentParameters {
  56713. /**
  56714. * Agent radius. [Limit: >= 0]
  56715. */
  56716. radius: number;
  56717. /**
  56718. * Agent height. [Limit: > 0]
  56719. */
  56720. height: number;
  56721. /**
  56722. * Maximum allowed acceleration. [Limit: >= 0]
  56723. */
  56724. maxAcceleration: number;
  56725. /**
  56726. * Maximum allowed speed. [Limit: >= 0]
  56727. */
  56728. maxSpeed: number;
  56729. /**
  56730. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  56731. */
  56732. collisionQueryRange: number;
  56733. /**
  56734. * The path visibility optimization range. [Limit: > 0]
  56735. */
  56736. pathOptimizationRange: number;
  56737. /**
  56738. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  56739. */
  56740. separationWeight: number;
  56741. }
  56742. /**
  56743. * Configures the navigation mesh creation
  56744. */
  56745. export interface INavMeshParameters {
  56746. /**
  56747. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  56748. */
  56749. cs: number;
  56750. /**
  56751. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  56752. */
  56753. ch: number;
  56754. /**
  56755. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  56756. */
  56757. walkableSlopeAngle: number;
  56758. /**
  56759. * Minimum floor to 'ceiling' height that will still allow the floor area to
  56760. * be considered walkable. [Limit: >= 3] [Units: vx]
  56761. */
  56762. walkableHeight: number;
  56763. /**
  56764. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  56765. */
  56766. walkableClimb: number;
  56767. /**
  56768. * The distance to erode/shrink the walkable area of the heightfield away from
  56769. * obstructions. [Limit: >=0] [Units: vx]
  56770. */
  56771. walkableRadius: number;
  56772. /**
  56773. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  56774. */
  56775. maxEdgeLen: number;
  56776. /**
  56777. * The maximum distance a simplfied contour's border edges should deviate
  56778. * the original raw contour. [Limit: >=0] [Units: vx]
  56779. */
  56780. maxSimplificationError: number;
  56781. /**
  56782. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  56783. */
  56784. minRegionArea: number;
  56785. /**
  56786. * Any regions with a span count smaller than this value will, if possible,
  56787. * be merged with larger regions. [Limit: >=0] [Units: vx]
  56788. */
  56789. mergeRegionArea: number;
  56790. /**
  56791. * The maximum number of vertices allowed for polygons generated during the
  56792. * contour to polygon conversion process. [Limit: >= 3]
  56793. */
  56794. maxVertsPerPoly: number;
  56795. /**
  56796. * Sets the sampling distance to use when generating the detail mesh.
  56797. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  56798. */
  56799. detailSampleDist: number;
  56800. /**
  56801. * The maximum distance the detail mesh surface should deviate from heightfield
  56802. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  56803. */
  56804. detailSampleMaxError: number;
  56805. }
  56806. }
  56807. declare module BABYLON {
  56808. /**
  56809. * RecastJS navigation plugin
  56810. */
  56811. export class RecastJSPlugin implements INavigationEnginePlugin {
  56812. /**
  56813. * Reference to the Recast library
  56814. */
  56815. bjsRECAST: any;
  56816. /**
  56817. * plugin name
  56818. */
  56819. name: string;
  56820. /**
  56821. * the first navmesh created. We might extend this to support multiple navmeshes
  56822. */
  56823. navMesh: any;
  56824. /**
  56825. * Initializes the recastJS plugin
  56826. * @param recastInjection can be used to inject your own recast reference
  56827. */
  56828. constructor(recastInjection?: any);
  56829. /**
  56830. * Creates a navigation mesh
  56831. * @param meshes array of all the geometry used to compute the navigatio mesh
  56832. * @param parameters bunch of parameters used to filter geometry
  56833. */
  56834. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  56835. /**
  56836. * Create a navigation mesh debug mesh
  56837. * @param scene is where the mesh will be added
  56838. * @returns debug display mesh
  56839. */
  56840. createDebugNavMesh(scene: Scene): Mesh;
  56841. /**
  56842. * Get a navigation mesh constrained position, closest to the parameter position
  56843. * @param position world position
  56844. * @returns the closest point to position constrained by the navigation mesh
  56845. */
  56846. getClosestPoint(position: Vector3): Vector3;
  56847. /**
  56848. * Get a navigation mesh constrained position, within a particular radius
  56849. * @param position world position
  56850. * @param maxRadius the maximum distance to the constrained world position
  56851. * @returns the closest point to position constrained by the navigation mesh
  56852. */
  56853. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  56854. /**
  56855. * Compute the final position from a segment made of destination-position
  56856. * @param position world position
  56857. * @param destination world position
  56858. * @returns the resulting point along the navmesh
  56859. */
  56860. moveAlong(position: Vector3, destination: Vector3): Vector3;
  56861. /**
  56862. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  56863. * @param start world position
  56864. * @param end world position
  56865. * @returns array containing world position composing the path
  56866. */
  56867. computePath(start: Vector3, end: Vector3): Vector3[];
  56868. /**
  56869. * Create a new Crowd so you can add agents
  56870. * @param maxAgents the maximum agent count in the crowd
  56871. * @param maxAgentRadius the maximum radius an agent can have
  56872. * @param scene to attach the crowd to
  56873. * @returns the crowd you can add agents to
  56874. */
  56875. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  56876. /**
  56877. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56878. * The queries will try to find a solution within those bounds
  56879. * default is (1,1,1)
  56880. * @param extent x,y,z value that define the extent around the queries point of reference
  56881. */
  56882. setDefaultQueryExtent(extent: Vector3): void;
  56883. /**
  56884. * Get the Bounding box extent specified by setDefaultQueryExtent
  56885. * @returns the box extent values
  56886. */
  56887. getDefaultQueryExtent(): Vector3;
  56888. /**
  56889. * Disposes
  56890. */
  56891. dispose(): void;
  56892. /**
  56893. * If this plugin is supported
  56894. * @returns true if plugin is supported
  56895. */
  56896. isSupported(): boolean;
  56897. }
  56898. /**
  56899. * Recast detour crowd implementation
  56900. */
  56901. export class RecastJSCrowd implements ICrowd {
  56902. /**
  56903. * Recast/detour plugin
  56904. */
  56905. bjsRECASTPlugin: RecastJSPlugin;
  56906. /**
  56907. * Link to the detour crowd
  56908. */
  56909. recastCrowd: any;
  56910. /**
  56911. * One transform per agent
  56912. */
  56913. transforms: TransformNode[];
  56914. /**
  56915. * All agents created
  56916. */
  56917. agents: number[];
  56918. /**
  56919. * Link to the scene is kept to unregister the crowd from the scene
  56920. */
  56921. private _scene;
  56922. /**
  56923. * Observer for crowd updates
  56924. */
  56925. private _onBeforeAnimationsObserver;
  56926. /**
  56927. * Constructor
  56928. * @param plugin recastJS plugin
  56929. * @param maxAgents the maximum agent count in the crowd
  56930. * @param maxAgentRadius the maximum radius an agent can have
  56931. * @param scene to attach the crowd to
  56932. * @returns the crowd you can add agents to
  56933. */
  56934. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  56935. /**
  56936. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  56937. * You can attach anything to that node. The node position is updated in the scene update tick.
  56938. * @param pos world position that will be constrained by the navigation mesh
  56939. * @param parameters agent parameters
  56940. * @param transform hooked to the agent that will be update by the scene
  56941. * @returns agent index
  56942. */
  56943. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  56944. /**
  56945. * Returns the agent position in world space
  56946. * @param index agent index returned by addAgent
  56947. * @returns world space position
  56948. */
  56949. getAgentPosition(index: number): Vector3;
  56950. /**
  56951. * Returns the agent velocity in world space
  56952. * @param index agent index returned by addAgent
  56953. * @returns world space velocity
  56954. */
  56955. getAgentVelocity(index: number): Vector3;
  56956. /**
  56957. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  56958. * @param index agent index returned by addAgent
  56959. * @param destination targeted world position
  56960. */
  56961. agentGoto(index: number, destination: Vector3): void;
  56962. /**
  56963. * remove a particular agent previously created
  56964. * @param index agent index returned by addAgent
  56965. */
  56966. removeAgent(index: number): void;
  56967. /**
  56968. * get the list of all agents attached to this crowd
  56969. * @returns list of agent indices
  56970. */
  56971. getAgents(): number[];
  56972. /**
  56973. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  56974. * @param deltaTime in seconds
  56975. */
  56976. update(deltaTime: number): void;
  56977. /**
  56978. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56979. * The queries will try to find a solution within those bounds
  56980. * default is (1,1,1)
  56981. * @param extent x,y,z value that define the extent around the queries point of reference
  56982. */
  56983. setDefaultQueryExtent(extent: Vector3): void;
  56984. /**
  56985. * Get the Bounding box extent specified by setDefaultQueryExtent
  56986. * @returns the box extent values
  56987. */
  56988. getDefaultQueryExtent(): Vector3;
  56989. /**
  56990. * Release all resources
  56991. */
  56992. dispose(): void;
  56993. }
  56994. }
  56995. declare module BABYLON {
  56996. /**
  56997. * Class used to enable access to IndexedDB
  56998. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  56999. */
  57000. export class Database implements IOfflineProvider {
  57001. private _callbackManifestChecked;
  57002. private _currentSceneUrl;
  57003. private _db;
  57004. private _enableSceneOffline;
  57005. private _enableTexturesOffline;
  57006. private _manifestVersionFound;
  57007. private _mustUpdateRessources;
  57008. private _hasReachedQuota;
  57009. private _isSupported;
  57010. private _idbFactory;
  57011. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  57012. private static IsUASupportingBlobStorage;
  57013. /**
  57014. * Gets a boolean indicating if Database storate is enabled (off by default)
  57015. */
  57016. static IDBStorageEnabled: boolean;
  57017. /**
  57018. * Gets a boolean indicating if scene must be saved in the database
  57019. */
  57020. readonly enableSceneOffline: boolean;
  57021. /**
  57022. * Gets a boolean indicating if textures must be saved in the database
  57023. */
  57024. readonly enableTexturesOffline: boolean;
  57025. /**
  57026. * Creates a new Database
  57027. * @param urlToScene defines the url to load the scene
  57028. * @param callbackManifestChecked defines the callback to use when manifest is checked
  57029. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  57030. */
  57031. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  57032. private static _ParseURL;
  57033. private static _ReturnFullUrlLocation;
  57034. private _checkManifestFile;
  57035. /**
  57036. * Open the database and make it available
  57037. * @param successCallback defines the callback to call on success
  57038. * @param errorCallback defines the callback to call on error
  57039. */
  57040. open(successCallback: () => void, errorCallback: () => void): void;
  57041. /**
  57042. * Loads an image from the database
  57043. * @param url defines the url to load from
  57044. * @param image defines the target DOM image
  57045. */
  57046. loadImage(url: string, image: HTMLImageElement): void;
  57047. private _loadImageFromDBAsync;
  57048. private _saveImageIntoDBAsync;
  57049. private _checkVersionFromDB;
  57050. private _loadVersionFromDBAsync;
  57051. private _saveVersionIntoDBAsync;
  57052. /**
  57053. * Loads a file from database
  57054. * @param url defines the URL to load from
  57055. * @param sceneLoaded defines a callback to call on success
  57056. * @param progressCallBack defines a callback to call when progress changed
  57057. * @param errorCallback defines a callback to call on error
  57058. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  57059. */
  57060. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  57061. private _loadFileAsync;
  57062. private _saveFileAsync;
  57063. /**
  57064. * Validates if xhr data is correct
  57065. * @param xhr defines the request to validate
  57066. * @param dataType defines the expected data type
  57067. * @returns true if data is correct
  57068. */
  57069. private static _ValidateXHRData;
  57070. }
  57071. }
  57072. declare module BABYLON {
  57073. /** @hidden */
  57074. export var gpuUpdateParticlesPixelShader: {
  57075. name: string;
  57076. shader: string;
  57077. };
  57078. }
  57079. declare module BABYLON {
  57080. /** @hidden */
  57081. export var gpuUpdateParticlesVertexShader: {
  57082. name: string;
  57083. shader: string;
  57084. };
  57085. }
  57086. declare module BABYLON {
  57087. /** @hidden */
  57088. export var clipPlaneFragmentDeclaration2: {
  57089. name: string;
  57090. shader: string;
  57091. };
  57092. }
  57093. declare module BABYLON {
  57094. /** @hidden */
  57095. export var gpuRenderParticlesPixelShader: {
  57096. name: string;
  57097. shader: string;
  57098. };
  57099. }
  57100. declare module BABYLON {
  57101. /** @hidden */
  57102. export var clipPlaneVertexDeclaration2: {
  57103. name: string;
  57104. shader: string;
  57105. };
  57106. }
  57107. declare module BABYLON {
  57108. /** @hidden */
  57109. export var gpuRenderParticlesVertexShader: {
  57110. name: string;
  57111. shader: string;
  57112. };
  57113. }
  57114. declare module BABYLON {
  57115. /**
  57116. * This represents a GPU particle system in Babylon
  57117. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  57118. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  57119. */
  57120. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  57121. /**
  57122. * The layer mask we are rendering the particles through.
  57123. */
  57124. layerMask: number;
  57125. private _capacity;
  57126. private _activeCount;
  57127. private _currentActiveCount;
  57128. private _accumulatedCount;
  57129. private _renderEffect;
  57130. private _updateEffect;
  57131. private _buffer0;
  57132. private _buffer1;
  57133. private _spriteBuffer;
  57134. private _updateVAO;
  57135. private _renderVAO;
  57136. private _targetIndex;
  57137. private _sourceBuffer;
  57138. private _targetBuffer;
  57139. private _engine;
  57140. private _currentRenderId;
  57141. private _started;
  57142. private _stopped;
  57143. private _timeDelta;
  57144. private _randomTexture;
  57145. private _randomTexture2;
  57146. private _attributesStrideSize;
  57147. private _updateEffectOptions;
  57148. private _randomTextureSize;
  57149. private _actualFrame;
  57150. private readonly _rawTextureWidth;
  57151. /**
  57152. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  57153. */
  57154. static readonly IsSupported: boolean;
  57155. /**
  57156. * An event triggered when the system is disposed.
  57157. */
  57158. onDisposeObservable: Observable<GPUParticleSystem>;
  57159. /**
  57160. * Gets the maximum number of particles active at the same time.
  57161. * @returns The max number of active particles.
  57162. */
  57163. getCapacity(): number;
  57164. /**
  57165. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  57166. * to override the particles.
  57167. */
  57168. forceDepthWrite: boolean;
  57169. /**
  57170. * Gets or set the number of active particles
  57171. */
  57172. activeParticleCount: number;
  57173. private _preWarmDone;
  57174. /**
  57175. * Is this system ready to be used/rendered
  57176. * @return true if the system is ready
  57177. */
  57178. isReady(): boolean;
  57179. /**
  57180. * Gets if the system has been started. (Note: this will still be true after stop is called)
  57181. * @returns True if it has been started, otherwise false.
  57182. */
  57183. isStarted(): boolean;
  57184. /**
  57185. * Starts the particle system and begins to emit
  57186. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  57187. */
  57188. start(delay?: number): void;
  57189. /**
  57190. * Stops the particle system.
  57191. */
  57192. stop(): void;
  57193. /**
  57194. * Remove all active particles
  57195. */
  57196. reset(): void;
  57197. /**
  57198. * Returns the string "GPUParticleSystem"
  57199. * @returns a string containing the class name
  57200. */
  57201. getClassName(): string;
  57202. private _colorGradientsTexture;
  57203. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  57204. /**
  57205. * Adds a new color gradient
  57206. * @param gradient defines the gradient to use (between 0 and 1)
  57207. * @param color1 defines the color to affect to the specified gradient
  57208. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  57209. * @returns the current particle system
  57210. */
  57211. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  57212. /**
  57213. * Remove a specific color gradient
  57214. * @param gradient defines the gradient to remove
  57215. * @returns the current particle system
  57216. */
  57217. removeColorGradient(gradient: number): GPUParticleSystem;
  57218. private _angularSpeedGradientsTexture;
  57219. private _sizeGradientsTexture;
  57220. private _velocityGradientsTexture;
  57221. private _limitVelocityGradientsTexture;
  57222. private _dragGradientsTexture;
  57223. private _addFactorGradient;
  57224. /**
  57225. * Adds a new size gradient
  57226. * @param gradient defines the gradient to use (between 0 and 1)
  57227. * @param factor defines the size factor to affect to the specified gradient
  57228. * @returns the current particle system
  57229. */
  57230. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  57231. /**
  57232. * Remove a specific size gradient
  57233. * @param gradient defines the gradient to remove
  57234. * @returns the current particle system
  57235. */
  57236. removeSizeGradient(gradient: number): GPUParticleSystem;
  57237. /**
  57238. * Adds a new angular speed gradient
  57239. * @param gradient defines the gradient to use (between 0 and 1)
  57240. * @param factor defines the angular speed to affect to the specified gradient
  57241. * @returns the current particle system
  57242. */
  57243. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  57244. /**
  57245. * Remove a specific angular speed gradient
  57246. * @param gradient defines the gradient to remove
  57247. * @returns the current particle system
  57248. */
  57249. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  57250. /**
  57251. * Adds a new velocity gradient
  57252. * @param gradient defines the gradient to use (between 0 and 1)
  57253. * @param factor defines the velocity to affect to the specified gradient
  57254. * @returns the current particle system
  57255. */
  57256. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57257. /**
  57258. * Remove a specific velocity gradient
  57259. * @param gradient defines the gradient to remove
  57260. * @returns the current particle system
  57261. */
  57262. removeVelocityGradient(gradient: number): GPUParticleSystem;
  57263. /**
  57264. * Adds a new limit velocity gradient
  57265. * @param gradient defines the gradient to use (between 0 and 1)
  57266. * @param factor defines the limit velocity value to affect to the specified gradient
  57267. * @returns the current particle system
  57268. */
  57269. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57270. /**
  57271. * Remove a specific limit velocity gradient
  57272. * @param gradient defines the gradient to remove
  57273. * @returns the current particle system
  57274. */
  57275. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  57276. /**
  57277. * Adds a new drag gradient
  57278. * @param gradient defines the gradient to use (between 0 and 1)
  57279. * @param factor defines the drag value to affect to the specified gradient
  57280. * @returns the current particle system
  57281. */
  57282. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  57283. /**
  57284. * Remove a specific drag gradient
  57285. * @param gradient defines the gradient to remove
  57286. * @returns the current particle system
  57287. */
  57288. removeDragGradient(gradient: number): GPUParticleSystem;
  57289. /**
  57290. * Not supported by GPUParticleSystem
  57291. * @param gradient defines the gradient to use (between 0 and 1)
  57292. * @param factor defines the emit rate value to affect to the specified gradient
  57293. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57294. * @returns the current particle system
  57295. */
  57296. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57297. /**
  57298. * Not supported by GPUParticleSystem
  57299. * @param gradient defines the gradient to remove
  57300. * @returns the current particle system
  57301. */
  57302. removeEmitRateGradient(gradient: number): IParticleSystem;
  57303. /**
  57304. * Not supported by GPUParticleSystem
  57305. * @param gradient defines the gradient to use (between 0 and 1)
  57306. * @param factor defines the start size value to affect to the specified gradient
  57307. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57308. * @returns the current particle system
  57309. */
  57310. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57311. /**
  57312. * Not supported by GPUParticleSystem
  57313. * @param gradient defines the gradient to remove
  57314. * @returns the current particle system
  57315. */
  57316. removeStartSizeGradient(gradient: number): IParticleSystem;
  57317. /**
  57318. * Not supported by GPUParticleSystem
  57319. * @param gradient defines the gradient to use (between 0 and 1)
  57320. * @param min defines the color remap minimal range
  57321. * @param max defines the color remap maximal range
  57322. * @returns the current particle system
  57323. */
  57324. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57325. /**
  57326. * Not supported by GPUParticleSystem
  57327. * @param gradient defines the gradient to remove
  57328. * @returns the current particle system
  57329. */
  57330. removeColorRemapGradient(): IParticleSystem;
  57331. /**
  57332. * Not supported by GPUParticleSystem
  57333. * @param gradient defines the gradient to use (between 0 and 1)
  57334. * @param min defines the alpha remap minimal range
  57335. * @param max defines the alpha remap maximal range
  57336. * @returns the current particle system
  57337. */
  57338. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57339. /**
  57340. * Not supported by GPUParticleSystem
  57341. * @param gradient defines the gradient to remove
  57342. * @returns the current particle system
  57343. */
  57344. removeAlphaRemapGradient(): IParticleSystem;
  57345. /**
  57346. * Not supported by GPUParticleSystem
  57347. * @param gradient defines the gradient to use (between 0 and 1)
  57348. * @param color defines the color to affect to the specified gradient
  57349. * @returns the current particle system
  57350. */
  57351. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  57352. /**
  57353. * Not supported by GPUParticleSystem
  57354. * @param gradient defines the gradient to remove
  57355. * @returns the current particle system
  57356. */
  57357. removeRampGradient(): IParticleSystem;
  57358. /**
  57359. * Not supported by GPUParticleSystem
  57360. * @returns the list of ramp gradients
  57361. */
  57362. getRampGradients(): Nullable<Array<Color3Gradient>>;
  57363. /**
  57364. * Not supported by GPUParticleSystem
  57365. * Gets or sets a boolean indicating that ramp gradients must be used
  57366. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  57367. */
  57368. useRampGradients: boolean;
  57369. /**
  57370. * Not supported by GPUParticleSystem
  57371. * @param gradient defines the gradient to use (between 0 and 1)
  57372. * @param factor defines the life time factor to affect to the specified gradient
  57373. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57374. * @returns the current particle system
  57375. */
  57376. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57377. /**
  57378. * Not supported by GPUParticleSystem
  57379. * @param gradient defines the gradient to remove
  57380. * @returns the current particle system
  57381. */
  57382. removeLifeTimeGradient(gradient: number): IParticleSystem;
  57383. /**
  57384. * Instantiates a GPU particle system.
  57385. * 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.
  57386. * @param name The name of the particle system
  57387. * @param options The options used to create the system
  57388. * @param scene The scene the particle system belongs to
  57389. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  57390. */
  57391. constructor(name: string, options: Partial<{
  57392. capacity: number;
  57393. randomTextureSize: number;
  57394. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  57395. protected _reset(): void;
  57396. private _createUpdateVAO;
  57397. private _createRenderVAO;
  57398. private _initialize;
  57399. /** @hidden */ private _recreateUpdateEffect(): void;
  57400. /** @hidden */ private _recreateRenderEffect(): void;
  57401. /**
  57402. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  57403. * @param preWarm defines if we are in the pre-warmimg phase
  57404. */
  57405. animate(preWarm?: boolean): void;
  57406. private _createFactorGradientTexture;
  57407. private _createSizeGradientTexture;
  57408. private _createAngularSpeedGradientTexture;
  57409. private _createVelocityGradientTexture;
  57410. private _createLimitVelocityGradientTexture;
  57411. private _createDragGradientTexture;
  57412. private _createColorGradientTexture;
  57413. /**
  57414. * Renders the particle system in its current state
  57415. * @param preWarm defines if the system should only update the particles but not render them
  57416. * @returns the current number of particles
  57417. */
  57418. render(preWarm?: boolean): number;
  57419. /**
  57420. * Rebuilds the particle system
  57421. */
  57422. rebuild(): void;
  57423. private _releaseBuffers;
  57424. private _releaseVAOs;
  57425. /**
  57426. * Disposes the particle system and free the associated resources
  57427. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  57428. */
  57429. dispose(disposeTexture?: boolean): void;
  57430. /**
  57431. * Clones the particle system.
  57432. * @param name The name of the cloned object
  57433. * @param newEmitter The new emitter to use
  57434. * @returns the cloned particle system
  57435. */
  57436. clone(name: string, newEmitter: any): GPUParticleSystem;
  57437. /**
  57438. * Serializes the particle system to a JSON object.
  57439. * @returns the JSON object
  57440. */
  57441. serialize(): any;
  57442. /**
  57443. * Parses a JSON object to create a GPU particle system.
  57444. * @param parsedParticleSystem The JSON object to parse
  57445. * @param scene The scene to create the particle system in
  57446. * @param rootUrl The root url to use to load external dependencies like texture
  57447. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  57448. * @returns the parsed GPU particle system
  57449. */
  57450. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  57451. }
  57452. }
  57453. declare module BABYLON {
  57454. /**
  57455. * Represents a set of particle systems working together to create a specific effect
  57456. */
  57457. export class ParticleSystemSet implements IDisposable {
  57458. /**
  57459. * Gets or sets base Assets URL
  57460. */
  57461. static BaseAssetsUrl: string;
  57462. private _emitterCreationOptions;
  57463. private _emitterNode;
  57464. /**
  57465. * Gets the particle system list
  57466. */
  57467. systems: IParticleSystem[];
  57468. /**
  57469. * Gets the emitter node used with this set
  57470. */
  57471. readonly emitterNode: Nullable<TransformNode>;
  57472. /**
  57473. * Creates a new emitter mesh as a sphere
  57474. * @param options defines the options used to create the sphere
  57475. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  57476. * @param scene defines the hosting scene
  57477. */
  57478. setEmitterAsSphere(options: {
  57479. diameter: number;
  57480. segments: number;
  57481. color: Color3;
  57482. }, renderingGroupId: number, scene: Scene): void;
  57483. /**
  57484. * Starts all particle systems of the set
  57485. * @param emitter defines an optional mesh to use as emitter for the particle systems
  57486. */
  57487. start(emitter?: AbstractMesh): void;
  57488. /**
  57489. * Release all associated resources
  57490. */
  57491. dispose(): void;
  57492. /**
  57493. * Serialize the set into a JSON compatible object
  57494. * @returns a JSON compatible representation of the set
  57495. */
  57496. serialize(): any;
  57497. /**
  57498. * Parse a new ParticleSystemSet from a serialized source
  57499. * @param data defines a JSON compatible representation of the set
  57500. * @param scene defines the hosting scene
  57501. * @param gpu defines if we want GPU particles or CPU particles
  57502. * @returns a new ParticleSystemSet
  57503. */
  57504. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  57505. }
  57506. }
  57507. declare module BABYLON {
  57508. /**
  57509. * This class is made for on one-liner static method to help creating particle system set.
  57510. */
  57511. export class ParticleHelper {
  57512. /**
  57513. * Gets or sets base Assets URL
  57514. */
  57515. static BaseAssetsUrl: string;
  57516. /**
  57517. * Create a default particle system that you can tweak
  57518. * @param emitter defines the emitter to use
  57519. * @param capacity defines the system capacity (default is 500 particles)
  57520. * @param scene defines the hosting scene
  57521. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  57522. * @returns the new Particle system
  57523. */
  57524. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  57525. /**
  57526. * This is the main static method (one-liner) of this helper to create different particle systems
  57527. * @param type This string represents the type to the particle system to create
  57528. * @param scene The scene where the particle system should live
  57529. * @param gpu If the system will use gpu
  57530. * @returns the ParticleSystemSet created
  57531. */
  57532. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  57533. /**
  57534. * Static function used to export a particle system to a ParticleSystemSet variable.
  57535. * Please note that the emitter shape is not exported
  57536. * @param systems defines the particle systems to export
  57537. * @returns the created particle system set
  57538. */
  57539. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  57540. }
  57541. }
  57542. declare module BABYLON {
  57543. interface Engine {
  57544. /**
  57545. * Create an effect to use with particle systems.
  57546. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  57547. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  57548. * @param uniformsNames defines a list of attribute names
  57549. * @param samplers defines an array of string used to represent textures
  57550. * @param defines defines the string containing the defines to use to compile the shaders
  57551. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  57552. * @param onCompiled defines a function to call when the effect creation is successful
  57553. * @param onError defines a function to call when the effect creation has failed
  57554. * @returns the new Effect
  57555. */
  57556. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  57557. }
  57558. interface Mesh {
  57559. /**
  57560. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  57561. * @returns an array of IParticleSystem
  57562. */
  57563. getEmittedParticleSystems(): IParticleSystem[];
  57564. /**
  57565. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  57566. * @returns an array of IParticleSystem
  57567. */
  57568. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  57569. }
  57570. /**
  57571. * @hidden
  57572. */
  57573. export var _IDoNeedToBeInTheBuild: number;
  57574. }
  57575. declare module BABYLON {
  57576. /** Defines the 4 color options */
  57577. export enum PointColor {
  57578. /** color value */
  57579. Color = 2,
  57580. /** uv value */
  57581. UV = 1,
  57582. /** random value */
  57583. Random = 0,
  57584. /** stated value */
  57585. Stated = 3
  57586. }
  57587. /**
  57588. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  57589. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  57590. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  57591. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  57592. *
  57593. * Full documentation here : TO BE ENTERED
  57594. */
  57595. export class PointsCloudSystem implements IDisposable {
  57596. /**
  57597. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  57598. * Example : var p = SPS.particles[i];
  57599. */
  57600. particles: CloudPoint[];
  57601. /**
  57602. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  57603. */
  57604. nbParticles: number;
  57605. /**
  57606. * This a counter for your own usage. It's not set by any SPS functions.
  57607. */
  57608. counter: number;
  57609. /**
  57610. * The PCS name. This name is also given to the underlying mesh.
  57611. */
  57612. name: string;
  57613. /**
  57614. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  57615. */
  57616. mesh: Mesh;
  57617. /**
  57618. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  57619. * Please read :
  57620. */
  57621. vars: any;
  57622. /**
  57623. * @hidden
  57624. */ private _size: number;
  57625. private _scene;
  57626. private _promises;
  57627. private _positions;
  57628. private _indices;
  57629. private _normals;
  57630. private _colors;
  57631. private _uvs;
  57632. private _indices32;
  57633. private _positions32;
  57634. private _colors32;
  57635. private _uvs32;
  57636. private _updatable;
  57637. private _isVisibilityBoxLocked;
  57638. private _alwaysVisible;
  57639. private _groups;
  57640. private _groupCounter;
  57641. private _computeParticleColor;
  57642. private _computeParticleTexture;
  57643. private _computeParticleRotation;
  57644. private _computeBoundingBox;
  57645. private _isReady;
  57646. /**
  57647. * Creates a PCS (Points Cloud System) object
  57648. * @param name (String) is the PCS name, this will be the underlying mesh name
  57649. * @param pointSize (number) is the size for each point
  57650. * @param scene (Scene) is the scene in which the PCS is added
  57651. * @param options defines the options of the PCS e.g.
  57652. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  57653. */
  57654. constructor(name: string, pointSize: number, scene: Scene, options?: {
  57655. updatable?: boolean;
  57656. });
  57657. /**
  57658. * Builds the PCS underlying mesh. Returns a standard Mesh.
  57659. * If no points were added to the PCS, the returned mesh is just a single point.
  57660. * @returns a promise for the created mesh
  57661. */
  57662. buildMeshAsync(): Promise<Mesh>;
  57663. /**
  57664. * @hidden
  57665. */
  57666. private _buildMesh;
  57667. private _addParticle;
  57668. private _randomUnitVector;
  57669. private _getColorIndicesForCoord;
  57670. private _setPointsColorOrUV;
  57671. private _colorFromTexture;
  57672. private _calculateDensity;
  57673. /**
  57674. * Adds points to the PCS in random positions within a unit sphere
  57675. * @param nb (positive integer) the number of particles to be created from this model
  57676. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  57677. * @returns the number of groups in the system
  57678. */
  57679. addPoints(nb: number, pointFunction?: any): number;
  57680. /**
  57681. * Adds points to the PCS from the surface of the model shape
  57682. * @param mesh is any Mesh object that will be used as a surface model for the points
  57683. * @param nb (positive integer) the number of particles to be created from this model
  57684. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  57685. * @param color (color3) to be used when colorWith is stated
  57686. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  57687. * @returns the number of groups in the system
  57688. */
  57689. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  57690. /**
  57691. * Adds points to the PCS inside the model shape
  57692. * @param mesh is any Mesh object that will be used as a surface model for the points
  57693. * @param nb (positive integer) the number of particles to be created from this model
  57694. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible),
  57695. * @param color (color4) to be used when colorWith is stated
  57696. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  57697. * @returns the number of groups in the system
  57698. */
  57699. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  57700. /**
  57701. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  57702. * This method calls `updateParticle()` for each particle of the SPS.
  57703. * For an animated SPS, it is usually called within the render loop.
  57704. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  57705. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  57706. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  57707. * @returns the PCS.
  57708. */
  57709. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  57710. /**
  57711. * Disposes the PCS.
  57712. */
  57713. dispose(): void;
  57714. /**
  57715. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  57716. * doc :
  57717. * @returns the PCS.
  57718. */
  57719. refreshVisibleSize(): PointsCloudSystem;
  57720. /**
  57721. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  57722. * @param size the size (float) of the visibility box
  57723. * note : this doesn't lock the PCS mesh bounding box.
  57724. * doc :
  57725. */
  57726. setVisibilityBox(size: number): void;
  57727. /**
  57728. * Gets whether the PCS is always visible or not
  57729. * doc :
  57730. */
  57731. /**
  57732. * Sets the PCS as always visible or not
  57733. * doc :
  57734. */
  57735. isAlwaysVisible: boolean;
  57736. /**
  57737. * Tells to `setParticles()` to compute the particle rotations or not
  57738. * Default value : false. The PCS is faster when it's set to false
  57739. * Note : particle rotations are only applied to parent particles
  57740. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  57741. */
  57742. computeParticleRotation: boolean;
  57743. /**
  57744. * Tells to `setParticles()` to compute the particle colors or not.
  57745. * Default value : true. The PCS is faster when it's set to false.
  57746. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  57747. */
  57748. /**
  57749. * Gets if `setParticles()` computes the particle colors or not.
  57750. * Default value : false. The PCS is faster when it's set to false.
  57751. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  57752. */
  57753. computeParticleColor: boolean;
  57754. /**
  57755. * Gets if `setParticles()` computes the particle textures or not.
  57756. * Default value : false. The PCS is faster when it's set to false.
  57757. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  57758. */
  57759. computeParticleTexture: boolean;
  57760. /**
  57761. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  57762. */
  57763. /**
  57764. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  57765. */
  57766. computeBoundingBox: boolean;
  57767. /**
  57768. * This function does nothing. It may be overwritten to set all the particle first values.
  57769. * The PCS doesn't call this function, you may have to call it by your own.
  57770. * doc :
  57771. */
  57772. initParticles(): void;
  57773. /**
  57774. * This function does nothing. It may be overwritten to recycle a particle
  57775. * The PCS doesn't call this function, you can to call it
  57776. * doc :
  57777. * @param particle The particle to recycle
  57778. * @returns the recycled particle
  57779. */
  57780. recycleParticle(particle: CloudPoint): CloudPoint;
  57781. /**
  57782. * Updates a particle : this function should be overwritten by the user.
  57783. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  57784. * doc :
  57785. * @example : just set a particle position or velocity and recycle conditions
  57786. * @param particle The particle to update
  57787. * @returns the updated particle
  57788. */
  57789. updateParticle(particle: CloudPoint): CloudPoint;
  57790. /**
  57791. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  57792. * This does nothing and may be overwritten by the user.
  57793. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  57794. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  57795. * @param update the boolean update value actually passed to setParticles()
  57796. */
  57797. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  57798. /**
  57799. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  57800. * This will be passed three parameters.
  57801. * This does nothing and may be overwritten by the user.
  57802. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  57803. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  57804. * @param update the boolean update value actually passed to setParticles()
  57805. */
  57806. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  57807. }
  57808. }
  57809. declare module BABYLON {
  57810. /**
  57811. * Represents one particle of a points cloud system.
  57812. */
  57813. export class CloudPoint {
  57814. /**
  57815. * particle global index
  57816. */
  57817. idx: number;
  57818. /**
  57819. * The color of the particle
  57820. */
  57821. color: Nullable<Color4>;
  57822. /**
  57823. * The world space position of the particle.
  57824. */
  57825. position: Vector3;
  57826. /**
  57827. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  57828. */
  57829. rotation: Vector3;
  57830. /**
  57831. * The world space rotation quaternion of the particle.
  57832. */
  57833. rotationQuaternion: Nullable<Quaternion>;
  57834. /**
  57835. * The uv of the particle.
  57836. */
  57837. uv: Nullable<Vector2>;
  57838. /**
  57839. * The current speed of the particle.
  57840. */
  57841. velocity: Vector3;
  57842. /**
  57843. * The pivot point in the particle local space.
  57844. */
  57845. pivot: Vector3;
  57846. /**
  57847. * Must the particle be translated from its pivot point in its local space ?
  57848. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  57849. * Default : false
  57850. */
  57851. translateFromPivot: boolean;
  57852. /**
  57853. * Index of this particle in the global "positions" array (Internal use)
  57854. * @hidden
  57855. */ private _pos: number;
  57856. /**
  57857. * @hidden Index of this particle in the global "indices" array (Internal use)
  57858. */ private _ind: number;
  57859. /**
  57860. * Group this particle belongs to
  57861. */ private _group: PointsGroup;
  57862. /**
  57863. * Group id of this particle
  57864. */
  57865. groupId: number;
  57866. /**
  57867. * Index of the particle in its group id (Internal use)
  57868. */
  57869. idxInGroup: number;
  57870. /**
  57871. * @hidden Particle BoundingInfo object (Internal use)
  57872. */ private _boundingInfo: BoundingInfo;
  57873. /**
  57874. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  57875. */ private _pcs: PointsCloudSystem;
  57876. /**
  57877. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  57878. */ private _stillInvisible: boolean;
  57879. /**
  57880. * @hidden Last computed particle rotation matrix
  57881. */ private _rotationMatrix: number[];
  57882. /**
  57883. * Parent particle Id, if any.
  57884. * Default null.
  57885. */
  57886. parentId: Nullable<number>;
  57887. /**
  57888. * @hidden Internal global position in the PCS.
  57889. */ private _globalPosition: Vector3;
  57890. /**
  57891. * Creates a Point Cloud object.
  57892. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  57893. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  57894. * @param group (PointsGroup) is the group the particle belongs to
  57895. * @param groupId (integer) is the group identifier in the PCS.
  57896. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  57897. * @param pcs defines the PCS it is associated to
  57898. */
  57899. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  57900. /**
  57901. * get point size
  57902. */
  57903. /**
  57904. * Set point size
  57905. */
  57906. size: Vector3;
  57907. /**
  57908. * Legacy support, changed quaternion to rotationQuaternion
  57909. */
  57910. /**
  57911. * Legacy support, changed quaternion to rotationQuaternion
  57912. */
  57913. quaternion: Nullable<Quaternion>;
  57914. /**
  57915. * Returns a boolean. True if the particle intersects a mesh, else false
  57916. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  57917. * @param target is the object (point or mesh) what the intersection is computed against
  57918. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  57919. * @returns true if it intersects
  57920. */
  57921. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  57922. /**
  57923. * get the rotation matrix of the particle
  57924. * @hidden
  57925. */
  57926. getRotationMatrix(m: Matrix): void;
  57927. }
  57928. /**
  57929. * Represents a group of points in a points cloud system
  57930. * * PCS internal tool, don't use it manually.
  57931. */
  57932. export class PointsGroup {
  57933. /**
  57934. * The group id
  57935. * @hidden
  57936. */
  57937. groupID: number;
  57938. /**
  57939. * image data for group (internal use)
  57940. * @hidden
  57941. */ private _groupImageData: Nullable<ArrayBufferView>;
  57942. /**
  57943. * Image Width (internal use)
  57944. * @hidden
  57945. */ private _groupImgWidth: number;
  57946. /**
  57947. * Image Height (internal use)
  57948. * @hidden
  57949. */ private _groupImgHeight: number;
  57950. /**
  57951. * Custom position function (internal use)
  57952. * @hidden
  57953. */ private _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  57954. /**
  57955. * density per facet for surface points
  57956. * @hidden
  57957. */ private _groupDensity: number[];
  57958. /**
  57959. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  57960. * PCS internal tool, don't use it manually.
  57961. * @hidden
  57962. */
  57963. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  57964. }
  57965. }
  57966. declare module BABYLON {
  57967. interface Scene {
  57968. /** @hidden (Backing field) */ private _physicsEngine: Nullable<IPhysicsEngine>;
  57969. /**
  57970. * Gets the current physics engine
  57971. * @returns a IPhysicsEngine or null if none attached
  57972. */
  57973. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  57974. /**
  57975. * Enables physics to the current scene
  57976. * @param gravity defines the scene's gravity for the physics engine
  57977. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  57978. * @return a boolean indicating if the physics engine was initialized
  57979. */
  57980. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  57981. /**
  57982. * Disables and disposes the physics engine associated with the scene
  57983. */
  57984. disablePhysicsEngine(): void;
  57985. /**
  57986. * Gets a boolean indicating if there is an active physics engine
  57987. * @returns a boolean indicating if there is an active physics engine
  57988. */
  57989. isPhysicsEnabled(): boolean;
  57990. /**
  57991. * Deletes a physics compound impostor
  57992. * @param compound defines the compound to delete
  57993. */
  57994. deleteCompoundImpostor(compound: any): void;
  57995. /**
  57996. * An event triggered when physic simulation is about to be run
  57997. */
  57998. onBeforePhysicsObservable: Observable<Scene>;
  57999. /**
  58000. * An event triggered when physic simulation has been done
  58001. */
  58002. onAfterPhysicsObservable: Observable<Scene>;
  58003. }
  58004. interface AbstractMesh {
  58005. /** @hidden */ private _physicsImpostor: Nullable<PhysicsImpostor>;
  58006. /**
  58007. * Gets or sets impostor used for physic simulation
  58008. * @see http://doc.babylonjs.com/features/physics_engine
  58009. */
  58010. physicsImpostor: Nullable<PhysicsImpostor>;
  58011. /**
  58012. * Gets the current physics impostor
  58013. * @see http://doc.babylonjs.com/features/physics_engine
  58014. * @returns a physics impostor or null
  58015. */
  58016. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  58017. /** Apply a physic impulse to the mesh
  58018. * @param force defines the force to apply
  58019. * @param contactPoint defines where to apply the force
  58020. * @returns the current mesh
  58021. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  58022. */
  58023. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  58024. /**
  58025. * Creates a physic joint between two meshes
  58026. * @param otherMesh defines the other mesh to use
  58027. * @param pivot1 defines the pivot to use on this mesh
  58028. * @param pivot2 defines the pivot to use on the other mesh
  58029. * @param options defines additional options (can be plugin dependent)
  58030. * @returns the current mesh
  58031. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  58032. */
  58033. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  58034. /** @hidden */ private _disposePhysicsObserver: Nullable<Observer<Node>>;
  58035. }
  58036. /**
  58037. * Defines the physics engine scene component responsible to manage a physics engine
  58038. */
  58039. export class PhysicsEngineSceneComponent implements ISceneComponent {
  58040. /**
  58041. * The component name helpful to identify the component in the list of scene components.
  58042. */
  58043. readonly name: string;
  58044. /**
  58045. * The scene the component belongs to.
  58046. */
  58047. scene: Scene;
  58048. /**
  58049. * Creates a new instance of the component for the given scene
  58050. * @param scene Defines the scene to register the component in
  58051. */
  58052. constructor(scene: Scene);
  58053. /**
  58054. * Registers the component in a given scene
  58055. */
  58056. register(): void;
  58057. /**
  58058. * Rebuilds the elements related to this component in case of
  58059. * context lost for instance.
  58060. */
  58061. rebuild(): void;
  58062. /**
  58063. * Disposes the component and the associated ressources
  58064. */
  58065. dispose(): void;
  58066. }
  58067. }
  58068. declare module BABYLON {
  58069. /**
  58070. * A helper for physics simulations
  58071. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58072. */
  58073. export class PhysicsHelper {
  58074. private _scene;
  58075. private _physicsEngine;
  58076. /**
  58077. * Initializes the Physics helper
  58078. * @param scene Babylon.js scene
  58079. */
  58080. constructor(scene: Scene);
  58081. /**
  58082. * Applies a radial explosion impulse
  58083. * @param origin the origin of the explosion
  58084. * @param radiusOrEventOptions the radius or the options of radial explosion
  58085. * @param strength the explosion strength
  58086. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58087. * @returns A physics radial explosion event, or null
  58088. */
  58089. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  58090. /**
  58091. * Applies a radial explosion force
  58092. * @param origin the origin of the explosion
  58093. * @param radiusOrEventOptions the radius or the options of radial explosion
  58094. * @param strength the explosion strength
  58095. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58096. * @returns A physics radial explosion event, or null
  58097. */
  58098. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  58099. /**
  58100. * Creates a gravitational field
  58101. * @param origin the origin of the explosion
  58102. * @param radiusOrEventOptions the radius or the options of radial explosion
  58103. * @param strength the explosion strength
  58104. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58105. * @returns A physics gravitational field event, or null
  58106. */
  58107. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  58108. /**
  58109. * Creates a physics updraft event
  58110. * @param origin the origin of the updraft
  58111. * @param radiusOrEventOptions the radius or the options of the updraft
  58112. * @param strength the strength of the updraft
  58113. * @param height the height of the updraft
  58114. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  58115. * @returns A physics updraft event, or null
  58116. */
  58117. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  58118. /**
  58119. * Creates a physics vortex event
  58120. * @param origin the of the vortex
  58121. * @param radiusOrEventOptions the radius or the options of the vortex
  58122. * @param strength the strength of the vortex
  58123. * @param height the height of the vortex
  58124. * @returns a Physics vortex event, or null
  58125. * A physics vortex event or null
  58126. */
  58127. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  58128. }
  58129. /**
  58130. * Represents a physics radial explosion event
  58131. */
  58132. class PhysicsRadialExplosionEvent {
  58133. private _scene;
  58134. private _options;
  58135. private _sphere;
  58136. private _dataFetched;
  58137. /**
  58138. * Initializes a radial explosioin event
  58139. * @param _scene BabylonJS scene
  58140. * @param _options The options for the vortex event
  58141. */
  58142. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  58143. /**
  58144. * Returns the data related to the radial explosion event (sphere).
  58145. * @returns The radial explosion event data
  58146. */
  58147. getData(): PhysicsRadialExplosionEventData;
  58148. /**
  58149. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  58150. * @param impostor A physics imposter
  58151. * @param origin the origin of the explosion
  58152. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  58153. */
  58154. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  58155. /**
  58156. * Triggers affecterd impostors callbacks
  58157. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  58158. */
  58159. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  58160. /**
  58161. * Disposes the sphere.
  58162. * @param force Specifies if the sphere should be disposed by force
  58163. */
  58164. dispose(force?: boolean): void;
  58165. /*** Helpers ***/
  58166. private _prepareSphere;
  58167. private _intersectsWithSphere;
  58168. }
  58169. /**
  58170. * Represents a gravitational field event
  58171. */
  58172. class PhysicsGravitationalFieldEvent {
  58173. private _physicsHelper;
  58174. private _scene;
  58175. private _origin;
  58176. private _options;
  58177. private _tickCallback;
  58178. private _sphere;
  58179. private _dataFetched;
  58180. /**
  58181. * Initializes the physics gravitational field event
  58182. * @param _physicsHelper A physics helper
  58183. * @param _scene BabylonJS scene
  58184. * @param _origin The origin position of the gravitational field event
  58185. * @param _options The options for the vortex event
  58186. */
  58187. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  58188. /**
  58189. * Returns the data related to the gravitational field event (sphere).
  58190. * @returns A gravitational field event
  58191. */
  58192. getData(): PhysicsGravitationalFieldEventData;
  58193. /**
  58194. * Enables the gravitational field.
  58195. */
  58196. enable(): void;
  58197. /**
  58198. * Disables the gravitational field.
  58199. */
  58200. disable(): void;
  58201. /**
  58202. * Disposes the sphere.
  58203. * @param force The force to dispose from the gravitational field event
  58204. */
  58205. dispose(force?: boolean): void;
  58206. private _tick;
  58207. }
  58208. /**
  58209. * Represents a physics updraft event
  58210. */
  58211. class PhysicsUpdraftEvent {
  58212. private _scene;
  58213. private _origin;
  58214. private _options;
  58215. private _physicsEngine;
  58216. private _originTop;
  58217. private _originDirection;
  58218. private _tickCallback;
  58219. private _cylinder;
  58220. private _cylinderPosition;
  58221. private _dataFetched;
  58222. /**
  58223. * Initializes the physics updraft event
  58224. * @param _scene BabylonJS scene
  58225. * @param _origin The origin position of the updraft
  58226. * @param _options The options for the updraft event
  58227. */
  58228. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  58229. /**
  58230. * Returns the data related to the updraft event (cylinder).
  58231. * @returns A physics updraft event
  58232. */
  58233. getData(): PhysicsUpdraftEventData;
  58234. /**
  58235. * Enables the updraft.
  58236. */
  58237. enable(): void;
  58238. /**
  58239. * Disables the updraft.
  58240. */
  58241. disable(): void;
  58242. /**
  58243. * Disposes the cylinder.
  58244. * @param force Specifies if the updraft should be disposed by force
  58245. */
  58246. dispose(force?: boolean): void;
  58247. private getImpostorHitData;
  58248. private _tick;
  58249. /*** Helpers ***/
  58250. private _prepareCylinder;
  58251. private _intersectsWithCylinder;
  58252. }
  58253. /**
  58254. * Represents a physics vortex event
  58255. */
  58256. class PhysicsVortexEvent {
  58257. private _scene;
  58258. private _origin;
  58259. private _options;
  58260. private _physicsEngine;
  58261. private _originTop;
  58262. private _tickCallback;
  58263. private _cylinder;
  58264. private _cylinderPosition;
  58265. private _dataFetched;
  58266. /**
  58267. * Initializes the physics vortex event
  58268. * @param _scene The BabylonJS scene
  58269. * @param _origin The origin position of the vortex
  58270. * @param _options The options for the vortex event
  58271. */
  58272. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  58273. /**
  58274. * Returns the data related to the vortex event (cylinder).
  58275. * @returns The physics vortex event data
  58276. */
  58277. getData(): PhysicsVortexEventData;
  58278. /**
  58279. * Enables the vortex.
  58280. */
  58281. enable(): void;
  58282. /**
  58283. * Disables the cortex.
  58284. */
  58285. disable(): void;
  58286. /**
  58287. * Disposes the sphere.
  58288. * @param force
  58289. */
  58290. dispose(force?: boolean): void;
  58291. private getImpostorHitData;
  58292. private _tick;
  58293. /*** Helpers ***/
  58294. private _prepareCylinder;
  58295. private _intersectsWithCylinder;
  58296. }
  58297. /**
  58298. * Options fot the radial explosion event
  58299. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58300. */
  58301. export class PhysicsRadialExplosionEventOptions {
  58302. /**
  58303. * The radius of the sphere for the radial explosion.
  58304. */
  58305. radius: number;
  58306. /**
  58307. * The strenth of the explosion.
  58308. */
  58309. strength: number;
  58310. /**
  58311. * The strenght of the force in correspondence to the distance of the affected object
  58312. */
  58313. falloff: PhysicsRadialImpulseFalloff;
  58314. /**
  58315. * Sphere options for the radial explosion.
  58316. */
  58317. sphere: {
  58318. segments: number;
  58319. diameter: number;
  58320. };
  58321. /**
  58322. * Sphere options for the radial explosion.
  58323. */
  58324. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  58325. }
  58326. /**
  58327. * Options fot the updraft event
  58328. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58329. */
  58330. export class PhysicsUpdraftEventOptions {
  58331. /**
  58332. * The radius of the cylinder for the vortex
  58333. */
  58334. radius: number;
  58335. /**
  58336. * The strenth of the updraft.
  58337. */
  58338. strength: number;
  58339. /**
  58340. * The height of the cylinder for the updraft.
  58341. */
  58342. height: number;
  58343. /**
  58344. * The mode for the the updraft.
  58345. */
  58346. updraftMode: PhysicsUpdraftMode;
  58347. }
  58348. /**
  58349. * Options fot the vortex event
  58350. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58351. */
  58352. export class PhysicsVortexEventOptions {
  58353. /**
  58354. * The radius of the cylinder for the vortex
  58355. */
  58356. radius: number;
  58357. /**
  58358. * The strenth of the vortex.
  58359. */
  58360. strength: number;
  58361. /**
  58362. * The height of the cylinder for the vortex.
  58363. */
  58364. height: number;
  58365. /**
  58366. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  58367. */
  58368. centripetalForceThreshold: number;
  58369. /**
  58370. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  58371. */
  58372. centripetalForceMultiplier: number;
  58373. /**
  58374. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  58375. */
  58376. centrifugalForceMultiplier: number;
  58377. /**
  58378. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  58379. */
  58380. updraftForceMultiplier: number;
  58381. }
  58382. /**
  58383. * The strenght of the force in correspondence to the distance of the affected object
  58384. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58385. */
  58386. export enum PhysicsRadialImpulseFalloff {
  58387. /** Defines that impulse is constant in strength across it's whole radius */
  58388. Constant = 0,
  58389. /** Defines that impulse gets weaker if it's further from the origin */
  58390. Linear = 1
  58391. }
  58392. /**
  58393. * The strength of the force in correspondence to the distance of the affected object
  58394. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58395. */
  58396. export enum PhysicsUpdraftMode {
  58397. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  58398. Center = 0,
  58399. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  58400. Perpendicular = 1
  58401. }
  58402. /**
  58403. * Interface for a physics hit data
  58404. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58405. */
  58406. export interface PhysicsHitData {
  58407. /**
  58408. * The force applied at the contact point
  58409. */
  58410. force: Vector3;
  58411. /**
  58412. * The contact point
  58413. */
  58414. contactPoint: Vector3;
  58415. /**
  58416. * The distance from the origin to the contact point
  58417. */
  58418. distanceFromOrigin: number;
  58419. }
  58420. /**
  58421. * Interface for radial explosion event data
  58422. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58423. */
  58424. export interface PhysicsRadialExplosionEventData {
  58425. /**
  58426. * A sphere used for the radial explosion event
  58427. */
  58428. sphere: Mesh;
  58429. }
  58430. /**
  58431. * Interface for gravitational field event data
  58432. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58433. */
  58434. export interface PhysicsGravitationalFieldEventData {
  58435. /**
  58436. * A sphere mesh used for the gravitational field event
  58437. */
  58438. sphere: Mesh;
  58439. }
  58440. /**
  58441. * Interface for updraft event data
  58442. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58443. */
  58444. export interface PhysicsUpdraftEventData {
  58445. /**
  58446. * A cylinder used for the updraft event
  58447. */
  58448. cylinder: Mesh;
  58449. }
  58450. /**
  58451. * Interface for vortex event data
  58452. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58453. */
  58454. export interface PhysicsVortexEventData {
  58455. /**
  58456. * A cylinder used for the vortex event
  58457. */
  58458. cylinder: Mesh;
  58459. }
  58460. /**
  58461. * Interface for an affected physics impostor
  58462. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58463. */
  58464. export interface PhysicsAffectedImpostorWithData {
  58465. /**
  58466. * The impostor affected by the effect
  58467. */
  58468. impostor: PhysicsImpostor;
  58469. /**
  58470. * The data about the hit/horce from the explosion
  58471. */
  58472. hitData: PhysicsHitData;
  58473. }
  58474. }
  58475. declare module BABYLON {
  58476. /** @hidden */
  58477. export var blackAndWhitePixelShader: {
  58478. name: string;
  58479. shader: string;
  58480. };
  58481. }
  58482. declare module BABYLON {
  58483. /**
  58484. * Post process used to render in black and white
  58485. */
  58486. export class BlackAndWhitePostProcess extends PostProcess {
  58487. /**
  58488. * Linear about to convert he result to black and white (default: 1)
  58489. */
  58490. degree: number;
  58491. /**
  58492. * Creates a black and white post process
  58493. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  58494. * @param name The name of the effect.
  58495. * @param options The required width/height ratio to downsize to before computing the render pass.
  58496. * @param camera The camera to apply the render pass to.
  58497. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58498. * @param engine The engine which the post process will be applied. (default: current engine)
  58499. * @param reusable If the post process can be reused on the same frame. (default: false)
  58500. */
  58501. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58502. }
  58503. }
  58504. declare module BABYLON {
  58505. /**
  58506. * This represents a set of one or more post processes in Babylon.
  58507. * A post process can be used to apply a shader to a texture after it is rendered.
  58508. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58509. */
  58510. export class PostProcessRenderEffect {
  58511. private _postProcesses;
  58512. private _getPostProcesses;
  58513. private _singleInstance;
  58514. private _cameras;
  58515. private _indicesForCamera;
  58516. /**
  58517. * Name of the effect
  58518. * @hidden
  58519. */ private _name: string;
  58520. /**
  58521. * Instantiates a post process render effect.
  58522. * A post process can be used to apply a shader to a texture after it is rendered.
  58523. * @param engine The engine the effect is tied to
  58524. * @param name The name of the effect
  58525. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  58526. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  58527. */
  58528. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  58529. /**
  58530. * Checks if all the post processes in the effect are supported.
  58531. */
  58532. readonly isSupported: boolean;
  58533. /**
  58534. * Updates the current state of the effect
  58535. * @hidden
  58536. */ private _update(): void;
  58537. /**
  58538. * Attaches the effect on cameras
  58539. * @param cameras The camera to attach to.
  58540. * @hidden
  58541. */ private _attachCameras(cameras: Camera): void;
  58542. /**
  58543. * Attaches the effect on cameras
  58544. * @param cameras The camera to attach to.
  58545. * @hidden
  58546. */ private _attachCameras(cameras: Camera[]): void;
  58547. /**
  58548. * Detaches the effect on cameras
  58549. * @param cameras The camera to detatch from.
  58550. * @hidden
  58551. */ private _detachCameras(cameras: Camera): void;
  58552. /**
  58553. * Detatches the effect on cameras
  58554. * @param cameras The camera to detatch from.
  58555. * @hidden
  58556. */ private _detachCameras(cameras: Camera[]): void;
  58557. /**
  58558. * Enables the effect on given cameras
  58559. * @param cameras The camera to enable.
  58560. * @hidden
  58561. */ private _enable(cameras: Camera): void;
  58562. /**
  58563. * Enables the effect on given cameras
  58564. * @param cameras The camera to enable.
  58565. * @hidden
  58566. */ private _enable(cameras: Nullable<Camera[]>): void;
  58567. /**
  58568. * Disables the effect on the given cameras
  58569. * @param cameras The camera to disable.
  58570. * @hidden
  58571. */ private _disable(cameras: Camera): void;
  58572. /**
  58573. * Disables the effect on the given cameras
  58574. * @param cameras The camera to disable.
  58575. * @hidden
  58576. */ private _disable(cameras: Nullable<Camera[]>): void;
  58577. /**
  58578. * Gets a list of the post processes contained in the effect.
  58579. * @param camera The camera to get the post processes on.
  58580. * @returns The list of the post processes in the effect.
  58581. */
  58582. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  58583. }
  58584. }
  58585. declare module BABYLON {
  58586. /** @hidden */
  58587. export var extractHighlightsPixelShader: {
  58588. name: string;
  58589. shader: string;
  58590. };
  58591. }
  58592. declare module BABYLON {
  58593. /**
  58594. * 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.
  58595. */
  58596. export class ExtractHighlightsPostProcess extends PostProcess {
  58597. /**
  58598. * The luminance threshold, pixels below this value will be set to black.
  58599. */
  58600. threshold: number;
  58601. /** @hidden */ private _exposure: number;
  58602. /**
  58603. * Post process which has the input texture to be used when performing highlight extraction
  58604. * @hidden
  58605. */ private _inputPostProcess: Nullable<PostProcess>;
  58606. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58607. }
  58608. }
  58609. declare module BABYLON {
  58610. /** @hidden */
  58611. export var bloomMergePixelShader: {
  58612. name: string;
  58613. shader: string;
  58614. };
  58615. }
  58616. declare module BABYLON {
  58617. /**
  58618. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58619. */
  58620. export class BloomMergePostProcess extends PostProcess {
  58621. /** Weight of the bloom to be added to the original input. */
  58622. weight: number;
  58623. /**
  58624. * Creates a new instance of @see BloomMergePostProcess
  58625. * @param name The name of the effect.
  58626. * @param originalFromInput Post process which's input will be used for the merge.
  58627. * @param blurred Blurred highlights post process which's output will be used.
  58628. * @param weight Weight of the bloom to be added to the original input.
  58629. * @param options The required width/height ratio to downsize to before computing the render pass.
  58630. * @param camera The camera to apply the render pass to.
  58631. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58632. * @param engine The engine which the post process will be applied. (default: current engine)
  58633. * @param reusable If the post process can be reused on the same frame. (default: false)
  58634. * @param textureType Type of textures used when performing the post process. (default: 0)
  58635. * @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)
  58636. */
  58637. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  58638. /** Weight of the bloom to be added to the original input. */
  58639. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58640. }
  58641. }
  58642. declare module BABYLON {
  58643. /**
  58644. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  58645. */
  58646. export class BloomEffect extends PostProcessRenderEffect {
  58647. private bloomScale;
  58648. /**
  58649. * @hidden Internal
  58650. */ private _effects: Array<PostProcess>;
  58651. /**
  58652. * @hidden Internal
  58653. */ private _downscale: ExtractHighlightsPostProcess;
  58654. private _blurX;
  58655. private _blurY;
  58656. private _merge;
  58657. /**
  58658. * The luminance threshold to find bright areas of the image to bloom.
  58659. */
  58660. threshold: number;
  58661. /**
  58662. * The strength of the bloom.
  58663. */
  58664. weight: number;
  58665. /**
  58666. * Specifies the size of the bloom blur kernel, relative to the final output size
  58667. */
  58668. kernel: number;
  58669. /**
  58670. * Creates a new instance of @see BloomEffect
  58671. * @param scene The scene the effect belongs to.
  58672. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  58673. * @param bloomKernel The size of the kernel to be used when applying the blur.
  58674. * @param bloomWeight The the strength of bloom.
  58675. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58676. * @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)
  58677. */
  58678. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  58679. /**
  58680. * Disposes each of the internal effects for a given camera.
  58681. * @param camera The camera to dispose the effect on.
  58682. */
  58683. disposeEffects(camera: Camera): void;
  58684. /**
  58685. * @hidden Internal
  58686. */ private _updateEffects(): void;
  58687. /**
  58688. * Internal
  58689. * @returns if all the contained post processes are ready.
  58690. * @hidden
  58691. */ private _isReady(): boolean;
  58692. }
  58693. }
  58694. declare module BABYLON {
  58695. /** @hidden */
  58696. export var chromaticAberrationPixelShader: {
  58697. name: string;
  58698. shader: string;
  58699. };
  58700. }
  58701. declare module BABYLON {
  58702. /**
  58703. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  58704. */
  58705. export class ChromaticAberrationPostProcess extends PostProcess {
  58706. /**
  58707. * The amount of seperation of rgb channels (default: 30)
  58708. */
  58709. aberrationAmount: number;
  58710. /**
  58711. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  58712. */
  58713. radialIntensity: number;
  58714. /**
  58715. * 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))
  58716. */
  58717. direction: Vector2;
  58718. /**
  58719. * 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))
  58720. */
  58721. centerPosition: Vector2;
  58722. /**
  58723. * Creates a new instance ChromaticAberrationPostProcess
  58724. * @param name The name of the effect.
  58725. * @param screenWidth The width of the screen to apply the effect on.
  58726. * @param screenHeight The height of the screen to apply the effect on.
  58727. * @param options The required width/height ratio to downsize to before computing the render pass.
  58728. * @param camera The camera to apply the render pass to.
  58729. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58730. * @param engine The engine which the post process will be applied. (default: current engine)
  58731. * @param reusable If the post process can be reused on the same frame. (default: false)
  58732. * @param textureType Type of textures used when performing the post process. (default: 0)
  58733. * @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)
  58734. */
  58735. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58736. }
  58737. }
  58738. declare module BABYLON {
  58739. /** @hidden */
  58740. export var circleOfConfusionPixelShader: {
  58741. name: string;
  58742. shader: string;
  58743. };
  58744. }
  58745. declare module BABYLON {
  58746. /**
  58747. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  58748. */
  58749. export class CircleOfConfusionPostProcess extends PostProcess {
  58750. /**
  58751. * 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.
  58752. */
  58753. lensSize: number;
  58754. /**
  58755. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58756. */
  58757. fStop: number;
  58758. /**
  58759. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58760. */
  58761. focusDistance: number;
  58762. /**
  58763. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  58764. */
  58765. focalLength: number;
  58766. private _depthTexture;
  58767. /**
  58768. * Creates a new instance CircleOfConfusionPostProcess
  58769. * @param name The name of the effect.
  58770. * @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.
  58771. * @param options The required width/height ratio to downsize to before computing the render pass.
  58772. * @param camera The camera to apply the render pass to.
  58773. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58774. * @param engine The engine which the post process will be applied. (default: current engine)
  58775. * @param reusable If the post process can be reused on the same frame. (default: false)
  58776. * @param textureType Type of textures used when performing the post process. (default: 0)
  58777. * @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)
  58778. */
  58779. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58780. /**
  58781. * 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.
  58782. */
  58783. depthTexture: RenderTargetTexture;
  58784. }
  58785. }
  58786. declare module BABYLON {
  58787. /** @hidden */
  58788. export var colorCorrectionPixelShader: {
  58789. name: string;
  58790. shader: string;
  58791. };
  58792. }
  58793. declare module BABYLON {
  58794. /**
  58795. *
  58796. * This post-process allows the modification of rendered colors by using
  58797. * a 'look-up table' (LUT). This effect is also called Color Grading.
  58798. *
  58799. * The object needs to be provided an url to a texture containing the color
  58800. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  58801. * Use an image editing software to tweak the LUT to match your needs.
  58802. *
  58803. * For an example of a color LUT, see here:
  58804. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  58805. * For explanations on color grading, see here:
  58806. * @see http://udn.epicgames.com/Three/ColorGrading.html
  58807. *
  58808. */
  58809. export class ColorCorrectionPostProcess extends PostProcess {
  58810. private _colorTableTexture;
  58811. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58812. }
  58813. }
  58814. declare module BABYLON {
  58815. /** @hidden */
  58816. export var convolutionPixelShader: {
  58817. name: string;
  58818. shader: string;
  58819. };
  58820. }
  58821. declare module BABYLON {
  58822. /**
  58823. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  58824. * input texture to perform effects such as edge detection or sharpening
  58825. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58826. */
  58827. export class ConvolutionPostProcess extends PostProcess {
  58828. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58829. kernel: number[];
  58830. /**
  58831. * Creates a new instance ConvolutionPostProcess
  58832. * @param name The name of the effect.
  58833. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  58834. * @param options The required width/height ratio to downsize to before computing the render pass.
  58835. * @param camera The camera to apply the render pass to.
  58836. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58837. * @param engine The engine which the post process will be applied. (default: current engine)
  58838. * @param reusable If the post process can be reused on the same frame. (default: false)
  58839. * @param textureType Type of textures used when performing the post process. (default: 0)
  58840. */
  58841. constructor(name: string,
  58842. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58843. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58844. /**
  58845. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58846. */
  58847. static EdgeDetect0Kernel: number[];
  58848. /**
  58849. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58850. */
  58851. static EdgeDetect1Kernel: number[];
  58852. /**
  58853. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58854. */
  58855. static EdgeDetect2Kernel: number[];
  58856. /**
  58857. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58858. */
  58859. static SharpenKernel: number[];
  58860. /**
  58861. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58862. */
  58863. static EmbossKernel: number[];
  58864. /**
  58865. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58866. */
  58867. static GaussianKernel: number[];
  58868. }
  58869. }
  58870. declare module BABYLON {
  58871. /**
  58872. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  58873. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  58874. * based on samples that have a large difference in distance than the center pixel.
  58875. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  58876. */
  58877. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  58878. direction: Vector2;
  58879. /**
  58880. * Creates a new instance CircleOfConfusionPostProcess
  58881. * @param name The name of the effect.
  58882. * @param scene The scene the effect belongs to.
  58883. * @param direction The direction the blur should be applied.
  58884. * @param kernel The size of the kernel used to blur.
  58885. * @param options The required width/height ratio to downsize to before computing the render pass.
  58886. * @param camera The camera to apply the render pass to.
  58887. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  58888. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  58889. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58890. * @param engine The engine which the post process will be applied. (default: current engine)
  58891. * @param reusable If the post process can be reused on the same frame. (default: false)
  58892. * @param textureType Type of textures used when performing the post process. (default: 0)
  58893. * @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)
  58894. */
  58895. 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);
  58896. }
  58897. }
  58898. declare module BABYLON {
  58899. /** @hidden */
  58900. export var depthOfFieldMergePixelShader: {
  58901. name: string;
  58902. shader: string;
  58903. };
  58904. }
  58905. declare module BABYLON {
  58906. /**
  58907. * Options to be set when merging outputs from the default pipeline.
  58908. */
  58909. export class DepthOfFieldMergePostProcessOptions {
  58910. /**
  58911. * The original image to merge on top of
  58912. */
  58913. originalFromInput: PostProcess;
  58914. /**
  58915. * Parameters to perform the merge of the depth of field effect
  58916. */
  58917. depthOfField?: {
  58918. circleOfConfusion: PostProcess;
  58919. blurSteps: Array<PostProcess>;
  58920. };
  58921. /**
  58922. * Parameters to perform the merge of bloom effect
  58923. */
  58924. bloom?: {
  58925. blurred: PostProcess;
  58926. weight: number;
  58927. };
  58928. }
  58929. /**
  58930. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58931. */
  58932. export class DepthOfFieldMergePostProcess extends PostProcess {
  58933. private blurSteps;
  58934. /**
  58935. * Creates a new instance of DepthOfFieldMergePostProcess
  58936. * @param name The name of the effect.
  58937. * @param originalFromInput Post process which's input will be used for the merge.
  58938. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  58939. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  58940. * @param options The required width/height ratio to downsize to before computing the render pass.
  58941. * @param camera The camera to apply the render pass to.
  58942. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58943. * @param engine The engine which the post process will be applied. (default: current engine)
  58944. * @param reusable If the post process can be reused on the same frame. (default: false)
  58945. * @param textureType Type of textures used when performing the post process. (default: 0)
  58946. * @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)
  58947. */
  58948. 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);
  58949. /**
  58950. * Updates the effect with the current post process compile time values and recompiles the shader.
  58951. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  58952. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  58953. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  58954. * @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
  58955. * @param onCompiled Called when the shader has been compiled.
  58956. * @param onError Called if there is an error when compiling a shader.
  58957. */
  58958. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  58959. }
  58960. }
  58961. declare module BABYLON {
  58962. /**
  58963. * Specifies the level of max blur that should be applied when using the depth of field effect
  58964. */
  58965. export enum DepthOfFieldEffectBlurLevel {
  58966. /**
  58967. * Subtle blur
  58968. */
  58969. Low = 0,
  58970. /**
  58971. * Medium blur
  58972. */
  58973. Medium = 1,
  58974. /**
  58975. * Large blur
  58976. */
  58977. High = 2
  58978. }
  58979. /**
  58980. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  58981. */
  58982. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  58983. private _circleOfConfusion;
  58984. /**
  58985. * @hidden Internal, blurs from high to low
  58986. */ private _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  58987. private _depthOfFieldBlurY;
  58988. private _dofMerge;
  58989. /**
  58990. * @hidden Internal post processes in depth of field effect
  58991. */ private _effects: Array<PostProcess>;
  58992. /**
  58993. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  58994. */
  58995. focalLength: number;
  58996. /**
  58997. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58998. */
  58999. fStop: number;
  59000. /**
  59001. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  59002. */
  59003. focusDistance: number;
  59004. /**
  59005. * 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.
  59006. */
  59007. lensSize: number;
  59008. /**
  59009. * Creates a new instance DepthOfFieldEffect
  59010. * @param scene The scene the effect belongs to.
  59011. * @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.
  59012. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  59013. * @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)
  59014. */
  59015. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  59016. /**
  59017. * Get the current class name of the current effet
  59018. * @returns "DepthOfFieldEffect"
  59019. */
  59020. getClassName(): string;
  59021. /**
  59022. * 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.
  59023. */
  59024. depthTexture: RenderTargetTexture;
  59025. /**
  59026. * Disposes each of the internal effects for a given camera.
  59027. * @param camera The camera to dispose the effect on.
  59028. */
  59029. disposeEffects(camera: Camera): void;
  59030. /**
  59031. * @hidden Internal
  59032. */ private _updateEffects(): void;
  59033. /**
  59034. * Internal
  59035. * @returns if all the contained post processes are ready.
  59036. * @hidden
  59037. */ private _isReady(): boolean;
  59038. }
  59039. }
  59040. declare module BABYLON {
  59041. /** @hidden */
  59042. export var displayPassPixelShader: {
  59043. name: string;
  59044. shader: string;
  59045. };
  59046. }
  59047. declare module BABYLON {
  59048. /**
  59049. * DisplayPassPostProcess which produces an output the same as it's input
  59050. */
  59051. export class DisplayPassPostProcess extends PostProcess {
  59052. /**
  59053. * Creates the DisplayPassPostProcess
  59054. * @param name The name of the effect.
  59055. * @param options The required width/height ratio to downsize to before computing the render pass.
  59056. * @param camera The camera to apply the render pass to.
  59057. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59058. * @param engine The engine which the post process will be applied. (default: current engine)
  59059. * @param reusable If the post process can be reused on the same frame. (default: false)
  59060. */
  59061. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59062. }
  59063. }
  59064. declare module BABYLON {
  59065. /** @hidden */
  59066. export var filterPixelShader: {
  59067. name: string;
  59068. shader: string;
  59069. };
  59070. }
  59071. declare module BABYLON {
  59072. /**
  59073. * Applies a kernel filter to the image
  59074. */
  59075. export class FilterPostProcess extends PostProcess {
  59076. /** The matrix to be applied to the image */
  59077. kernelMatrix: Matrix;
  59078. /**
  59079. *
  59080. * @param name The name of the effect.
  59081. * @param kernelMatrix The matrix to be applied to the image
  59082. * @param options The required width/height ratio to downsize to before computing the render pass.
  59083. * @param camera The camera to apply the render pass to.
  59084. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59085. * @param engine The engine which the post process will be applied. (default: current engine)
  59086. * @param reusable If the post process can be reused on the same frame. (default: false)
  59087. */
  59088. constructor(name: string,
  59089. /** The matrix to be applied to the image */
  59090. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59091. }
  59092. }
  59093. declare module BABYLON {
  59094. /** @hidden */
  59095. export var fxaaPixelShader: {
  59096. name: string;
  59097. shader: string;
  59098. };
  59099. }
  59100. declare module BABYLON {
  59101. /** @hidden */
  59102. export var fxaaVertexShader: {
  59103. name: string;
  59104. shader: string;
  59105. };
  59106. }
  59107. declare module BABYLON {
  59108. /**
  59109. * Fxaa post process
  59110. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  59111. */
  59112. export class FxaaPostProcess extends PostProcess {
  59113. /** @hidden */
  59114. texelWidth: number;
  59115. /** @hidden */
  59116. texelHeight: number;
  59117. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59118. private _getDefines;
  59119. }
  59120. }
  59121. declare module BABYLON {
  59122. /** @hidden */
  59123. export var grainPixelShader: {
  59124. name: string;
  59125. shader: string;
  59126. };
  59127. }
  59128. declare module BABYLON {
  59129. /**
  59130. * The GrainPostProcess adds noise to the image at mid luminance levels
  59131. */
  59132. export class GrainPostProcess extends PostProcess {
  59133. /**
  59134. * The intensity of the grain added (default: 30)
  59135. */
  59136. intensity: number;
  59137. /**
  59138. * If the grain should be randomized on every frame
  59139. */
  59140. animated: boolean;
  59141. /**
  59142. * Creates a new instance of @see GrainPostProcess
  59143. * @param name The name of the effect.
  59144. * @param options The required width/height ratio to downsize to before computing the render pass.
  59145. * @param camera The camera to apply the render pass to.
  59146. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59147. * @param engine The engine which the post process will be applied. (default: current engine)
  59148. * @param reusable If the post process can be reused on the same frame. (default: false)
  59149. * @param textureType Type of textures used when performing the post process. (default: 0)
  59150. * @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)
  59151. */
  59152. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59153. }
  59154. }
  59155. declare module BABYLON {
  59156. /** @hidden */
  59157. export var highlightsPixelShader: {
  59158. name: string;
  59159. shader: string;
  59160. };
  59161. }
  59162. declare module BABYLON {
  59163. /**
  59164. * Extracts highlights from the image
  59165. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  59166. */
  59167. export class HighlightsPostProcess extends PostProcess {
  59168. /**
  59169. * Extracts highlights from the image
  59170. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  59171. * @param name The name of the effect.
  59172. * @param options The required width/height ratio to downsize to before computing the render pass.
  59173. * @param camera The camera to apply the render pass to.
  59174. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59175. * @param engine The engine which the post process will be applied. (default: current engine)
  59176. * @param reusable If the post process can be reused on the same frame. (default: false)
  59177. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  59178. */
  59179. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59180. }
  59181. }
  59182. declare module BABYLON {
  59183. /** @hidden */
  59184. export var mrtFragmentDeclaration: {
  59185. name: string;
  59186. shader: string;
  59187. };
  59188. }
  59189. declare module BABYLON {
  59190. /** @hidden */
  59191. export var geometryPixelShader: {
  59192. name: string;
  59193. shader: string;
  59194. };
  59195. }
  59196. declare module BABYLON {
  59197. /** @hidden */
  59198. export var geometryVertexShader: {
  59199. name: string;
  59200. shader: string;
  59201. };
  59202. }
  59203. declare module BABYLON {
  59204. /** @hidden */
  59205. interface ISavedTransformationMatrix {
  59206. world: Matrix;
  59207. viewProjection: Matrix;
  59208. }
  59209. /**
  59210. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  59211. */
  59212. export class GeometryBufferRenderer {
  59213. /**
  59214. * Constant used to retrieve the position texture index in the G-Buffer textures array
  59215. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  59216. */
  59217. static readonly POSITION_TEXTURE_TYPE: number;
  59218. /**
  59219. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  59220. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  59221. */
  59222. static readonly VELOCITY_TEXTURE_TYPE: number;
  59223. /**
  59224. * Dictionary used to store the previous transformation matrices of each rendered mesh
  59225. * in order to compute objects velocities when enableVelocity is set to "true"
  59226. * @hidden
  59227. */ private _previousTransformationMatrices: {
  59228. [index: number]: ISavedTransformationMatrix;
  59229. };
  59230. /**
  59231. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  59232. * in order to compute objects velocities when enableVelocity is set to "true"
  59233. * @hidden
  59234. */ private _previousBonesTransformationMatrices: {
  59235. [index: number]: Float32Array;
  59236. };
  59237. /**
  59238. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  59239. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  59240. */
  59241. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  59242. private _scene;
  59243. private _multiRenderTarget;
  59244. private _ratio;
  59245. private _enablePosition;
  59246. private _enableVelocity;
  59247. private _positionIndex;
  59248. private _velocityIndex;
  59249. protected _effect: Effect;
  59250. protected _cachedDefines: string;
  59251. /**
  59252. * Set the render list (meshes to be rendered) used in the G buffer.
  59253. */
  59254. renderList: Mesh[];
  59255. /**
  59256. * Gets wether or not G buffer are supported by the running hardware.
  59257. * This requires draw buffer supports
  59258. */
  59259. readonly isSupported: boolean;
  59260. /**
  59261. * Returns the index of the given texture type in the G-Buffer textures array
  59262. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  59263. * @returns the index of the given texture type in the G-Buffer textures array
  59264. */
  59265. getTextureIndex(textureType: number): number;
  59266. /**
  59267. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  59268. */
  59269. /**
  59270. * Sets whether or not objects positions are enabled for the G buffer.
  59271. */
  59272. enablePosition: boolean;
  59273. /**
  59274. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  59275. */
  59276. /**
  59277. * Sets wether or not objects velocities are enabled for the G buffer.
  59278. */
  59279. enableVelocity: boolean;
  59280. /**
  59281. * Gets the scene associated with the buffer.
  59282. */
  59283. readonly scene: Scene;
  59284. /**
  59285. * Gets the ratio used by the buffer during its creation.
  59286. * How big is the buffer related to the main canvas.
  59287. */
  59288. readonly ratio: number;
  59289. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  59290. /**
  59291. * Creates a new G Buffer for the scene
  59292. * @param scene The scene the buffer belongs to
  59293. * @param ratio How big is the buffer related to the main canvas.
  59294. */
  59295. constructor(scene: Scene, ratio?: number);
  59296. /**
  59297. * Checks wether everything is ready to render a submesh to the G buffer.
  59298. * @param subMesh the submesh to check readiness for
  59299. * @param useInstances is the mesh drawn using instance or not
  59300. * @returns true if ready otherwise false
  59301. */
  59302. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59303. /**
  59304. * Gets the current underlying G Buffer.
  59305. * @returns the buffer
  59306. */
  59307. getGBuffer(): MultiRenderTarget;
  59308. /**
  59309. * Gets the number of samples used to render the buffer (anti aliasing).
  59310. */
  59311. /**
  59312. * Sets the number of samples used to render the buffer (anti aliasing).
  59313. */
  59314. samples: number;
  59315. /**
  59316. * Disposes the renderer and frees up associated resources.
  59317. */
  59318. dispose(): void;
  59319. protected _createRenderTargets(): void;
  59320. private _copyBonesTransformationMatrices;
  59321. }
  59322. }
  59323. declare module BABYLON {
  59324. interface Scene {
  59325. /** @hidden (Backing field) */ private _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  59326. /**
  59327. * Gets or Sets the current geometry buffer associated to the scene.
  59328. */
  59329. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  59330. /**
  59331. * Enables a GeometryBufferRender and associates it with the scene
  59332. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  59333. * @returns the GeometryBufferRenderer
  59334. */
  59335. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  59336. /**
  59337. * Disables the GeometryBufferRender associated with the scene
  59338. */
  59339. disableGeometryBufferRenderer(): void;
  59340. }
  59341. /**
  59342. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  59343. * in several rendering techniques.
  59344. */
  59345. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  59346. /**
  59347. * The component name helpful to identify the component in the list of scene components.
  59348. */
  59349. readonly name: string;
  59350. /**
  59351. * The scene the component belongs to.
  59352. */
  59353. scene: Scene;
  59354. /**
  59355. * Creates a new instance of the component for the given scene
  59356. * @param scene Defines the scene to register the component in
  59357. */
  59358. constructor(scene: Scene);
  59359. /**
  59360. * Registers the component in a given scene
  59361. */
  59362. register(): void;
  59363. /**
  59364. * Rebuilds the elements related to this component in case of
  59365. * context lost for instance.
  59366. */
  59367. rebuild(): void;
  59368. /**
  59369. * Disposes the component and the associated ressources
  59370. */
  59371. dispose(): void;
  59372. private _gatherRenderTargets;
  59373. }
  59374. }
  59375. declare module BABYLON {
  59376. /** @hidden */
  59377. export var motionBlurPixelShader: {
  59378. name: string;
  59379. shader: string;
  59380. };
  59381. }
  59382. declare module BABYLON {
  59383. /**
  59384. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  59385. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  59386. * As an example, all you have to do is to create the post-process:
  59387. * var mb = new BABYLON.MotionBlurPostProcess(
  59388. * 'mb', // The name of the effect.
  59389. * scene, // The scene containing the objects to blur according to their velocity.
  59390. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  59391. * camera // The camera to apply the render pass to.
  59392. * );
  59393. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  59394. */
  59395. export class MotionBlurPostProcess extends PostProcess {
  59396. /**
  59397. * Defines how much the image is blurred by the movement. Default value is equal to 1
  59398. */
  59399. motionStrength: number;
  59400. /**
  59401. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  59402. */
  59403. /**
  59404. * Sets the number of iterations to be used for motion blur quality
  59405. */
  59406. motionBlurSamples: number;
  59407. private _motionBlurSamples;
  59408. private _geometryBufferRenderer;
  59409. /**
  59410. * Creates a new instance MotionBlurPostProcess
  59411. * @param name The name of the effect.
  59412. * @param scene The scene containing the objects to blur according to their velocity.
  59413. * @param options The required width/height ratio to downsize to before computing the render pass.
  59414. * @param camera The camera to apply the render pass to.
  59415. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59416. * @param engine The engine which the post process will be applied. (default: current engine)
  59417. * @param reusable If the post process can be reused on the same frame. (default: false)
  59418. * @param textureType Type of textures used when performing the post process. (default: 0)
  59419. * @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)
  59420. */
  59421. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59422. /**
  59423. * Excludes the given skinned mesh from computing bones velocities.
  59424. * Computing bones velocities can have a cost and that cost. The cost can be saved by calling this function and by passing the skinned mesh reference to ignore.
  59425. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  59426. */
  59427. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  59428. /**
  59429. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  59430. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  59431. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  59432. */
  59433. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  59434. /**
  59435. * Disposes the post process.
  59436. * @param camera The camera to dispose the post process on.
  59437. */
  59438. dispose(camera?: Camera): void;
  59439. }
  59440. }
  59441. declare module BABYLON {
  59442. /** @hidden */
  59443. export var refractionPixelShader: {
  59444. name: string;
  59445. shader: string;
  59446. };
  59447. }
  59448. declare module BABYLON {
  59449. /**
  59450. * Post process which applies a refractin texture
  59451. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  59452. */
  59453. export class RefractionPostProcess extends PostProcess {
  59454. /** the base color of the refraction (used to taint the rendering) */
  59455. color: Color3;
  59456. /** simulated refraction depth */
  59457. depth: number;
  59458. /** the coefficient of the base color (0 to remove base color tainting) */
  59459. colorLevel: number;
  59460. private _refTexture;
  59461. private _ownRefractionTexture;
  59462. /**
  59463. * Gets or sets the refraction texture
  59464. * Please note that you are responsible for disposing the texture if you set it manually
  59465. */
  59466. refractionTexture: Texture;
  59467. /**
  59468. * Initializes the RefractionPostProcess
  59469. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  59470. * @param name The name of the effect.
  59471. * @param refractionTextureUrl Url of the refraction texture to use
  59472. * @param color the base color of the refraction (used to taint the rendering)
  59473. * @param depth simulated refraction depth
  59474. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  59475. * @param camera The camera to apply the render pass to.
  59476. * @param options The required width/height ratio to downsize to before computing the render pass.
  59477. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59478. * @param engine The engine which the post process will be applied. (default: current engine)
  59479. * @param reusable If the post process can be reused on the same frame. (default: false)
  59480. */
  59481. constructor(name: string, refractionTextureUrl: string,
  59482. /** the base color of the refraction (used to taint the rendering) */
  59483. color: Color3,
  59484. /** simulated refraction depth */
  59485. depth: number,
  59486. /** the coefficient of the base color (0 to remove base color tainting) */
  59487. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59488. /**
  59489. * Disposes of the post process
  59490. * @param camera Camera to dispose post process on
  59491. */
  59492. dispose(camera: Camera): void;
  59493. }
  59494. }
  59495. declare module BABYLON {
  59496. /** @hidden */
  59497. export var sharpenPixelShader: {
  59498. name: string;
  59499. shader: string;
  59500. };
  59501. }
  59502. declare module BABYLON {
  59503. /**
  59504. * The SharpenPostProcess applies a sharpen kernel to every pixel
  59505. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  59506. */
  59507. export class SharpenPostProcess extends PostProcess {
  59508. /**
  59509. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  59510. */
  59511. colorAmount: number;
  59512. /**
  59513. * How much sharpness should be applied (default: 0.3)
  59514. */
  59515. edgeAmount: number;
  59516. /**
  59517. * Creates a new instance ConvolutionPostProcess
  59518. * @param name The name of the effect.
  59519. * @param options The required width/height ratio to downsize to before computing the render pass.
  59520. * @param camera The camera to apply the render pass to.
  59521. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59522. * @param engine The engine which the post process will be applied. (default: current engine)
  59523. * @param reusable If the post process can be reused on the same frame. (default: false)
  59524. * @param textureType Type of textures used when performing the post process. (default: 0)
  59525. * @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)
  59526. */
  59527. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59528. }
  59529. }
  59530. declare module BABYLON {
  59531. /**
  59532. * PostProcessRenderPipeline
  59533. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59534. */
  59535. export class PostProcessRenderPipeline {
  59536. private engine;
  59537. private _renderEffects;
  59538. private _renderEffectsForIsolatedPass;
  59539. /**
  59540. * List of inspectable custom properties (used by the Inspector)
  59541. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  59542. */
  59543. inspectableCustomProperties: IInspectable[];
  59544. /**
  59545. * @hidden
  59546. */
  59547. protected _cameras: Camera[];
  59548. /** @hidden */ private _name: string;
  59549. /**
  59550. * Gets pipeline name
  59551. */
  59552. readonly name: string;
  59553. /**
  59554. * Initializes a PostProcessRenderPipeline
  59555. * @param engine engine to add the pipeline to
  59556. * @param name name of the pipeline
  59557. */
  59558. constructor(engine: Engine, name: string);
  59559. /**
  59560. * Gets the class name
  59561. * @returns "PostProcessRenderPipeline"
  59562. */
  59563. getClassName(): string;
  59564. /**
  59565. * If all the render effects in the pipeline are supported
  59566. */
  59567. readonly isSupported: boolean;
  59568. /**
  59569. * Adds an effect to the pipeline
  59570. * @param renderEffect the effect to add
  59571. */
  59572. addEffect(renderEffect: PostProcessRenderEffect): void;
  59573. /** @hidden */ private _rebuild(): void;
  59574. /** @hidden */ private _enableEffect(renderEffectName: string, cameras: Camera): void;
  59575. /** @hidden */ private _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  59576. /** @hidden */ private _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  59577. /** @hidden */ private _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  59578. /** @hidden */ private _attachCameras(cameras: Camera, unique: boolean): void;
  59579. /** @hidden */ private _attachCameras(cameras: Camera[], unique: boolean): void;
  59580. /** @hidden */ private _detachCameras(cameras: Camera): void;
  59581. /** @hidden */ private _detachCameras(cameras: Nullable<Camera[]>): void;
  59582. /** @hidden */ private _update(): void;
  59583. /** @hidden */ private _reset(): void;
  59584. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  59585. /**
  59586. * Disposes of the pipeline
  59587. */
  59588. dispose(): void;
  59589. }
  59590. }
  59591. declare module BABYLON {
  59592. /**
  59593. * PostProcessRenderPipelineManager class
  59594. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59595. */
  59596. export class PostProcessRenderPipelineManager {
  59597. private _renderPipelines;
  59598. /**
  59599. * Initializes a PostProcessRenderPipelineManager
  59600. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59601. */
  59602. constructor();
  59603. /**
  59604. * Gets the list of supported render pipelines
  59605. */
  59606. readonly supportedPipelines: PostProcessRenderPipeline[];
  59607. /**
  59608. * Adds a pipeline to the manager
  59609. * @param renderPipeline The pipeline to add
  59610. */
  59611. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  59612. /**
  59613. * Attaches a camera to the pipeline
  59614. * @param renderPipelineName The name of the pipeline to attach to
  59615. * @param cameras the camera to attach
  59616. * @param unique if the camera can be attached multiple times to the pipeline
  59617. */
  59618. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  59619. /**
  59620. * Detaches a camera from the pipeline
  59621. * @param renderPipelineName The name of the pipeline to detach from
  59622. * @param cameras the camera to detach
  59623. */
  59624. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  59625. /**
  59626. * Enables an effect by name on a pipeline
  59627. * @param renderPipelineName the name of the pipeline to enable the effect in
  59628. * @param renderEffectName the name of the effect to enable
  59629. * @param cameras the cameras that the effect should be enabled on
  59630. */
  59631. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59632. /**
  59633. * Disables an effect by name on a pipeline
  59634. * @param renderPipelineName the name of the pipeline to disable the effect in
  59635. * @param renderEffectName the name of the effect to disable
  59636. * @param cameras the cameras that the effect should be disabled on
  59637. */
  59638. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59639. /**
  59640. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  59641. */
  59642. update(): void;
  59643. /** @hidden */ private _rebuild(): void;
  59644. /**
  59645. * Disposes of the manager and pipelines
  59646. */
  59647. dispose(): void;
  59648. }
  59649. }
  59650. declare module BABYLON {
  59651. interface Scene {
  59652. /** @hidden (Backing field) */ private _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59653. /**
  59654. * Gets the postprocess render pipeline manager
  59655. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59656. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59657. */
  59658. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59659. }
  59660. /**
  59661. * Defines the Render Pipeline scene component responsible to rendering pipelines
  59662. */
  59663. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  59664. /**
  59665. * The component name helpfull to identify the component in the list of scene components.
  59666. */
  59667. readonly name: string;
  59668. /**
  59669. * The scene the component belongs to.
  59670. */
  59671. scene: Scene;
  59672. /**
  59673. * Creates a new instance of the component for the given scene
  59674. * @param scene Defines the scene to register the component in
  59675. */
  59676. constructor(scene: Scene);
  59677. /**
  59678. * Registers the component in a given scene
  59679. */
  59680. register(): void;
  59681. /**
  59682. * Rebuilds the elements related to this component in case of
  59683. * context lost for instance.
  59684. */
  59685. rebuild(): void;
  59686. /**
  59687. * Disposes the component and the associated ressources
  59688. */
  59689. dispose(): void;
  59690. private _gatherRenderTargets;
  59691. }
  59692. }
  59693. declare module BABYLON {
  59694. /**
  59695. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  59696. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59697. */
  59698. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59699. private _scene;
  59700. private _camerasToBeAttached;
  59701. /**
  59702. * ID of the sharpen post process,
  59703. */
  59704. private readonly SharpenPostProcessId;
  59705. /**
  59706. * @ignore
  59707. * ID of the image processing post process;
  59708. */
  59709. readonly ImageProcessingPostProcessId: string;
  59710. /**
  59711. * @ignore
  59712. * ID of the Fast Approximate Anti-Aliasing post process;
  59713. */
  59714. readonly FxaaPostProcessId: string;
  59715. /**
  59716. * ID of the chromatic aberration post process,
  59717. */
  59718. private readonly ChromaticAberrationPostProcessId;
  59719. /**
  59720. * ID of the grain post process
  59721. */
  59722. private readonly GrainPostProcessId;
  59723. /**
  59724. * Sharpen post process which will apply a sharpen convolution to enhance edges
  59725. */
  59726. sharpen: SharpenPostProcess;
  59727. private _sharpenEffect;
  59728. private bloom;
  59729. /**
  59730. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  59731. */
  59732. depthOfField: DepthOfFieldEffect;
  59733. /**
  59734. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59735. */
  59736. fxaa: FxaaPostProcess;
  59737. /**
  59738. * Image post processing pass used to perform operations such as tone mapping or color grading.
  59739. */
  59740. imageProcessing: ImageProcessingPostProcess;
  59741. /**
  59742. * Chromatic aberration post process which will shift rgb colors in the image
  59743. */
  59744. chromaticAberration: ChromaticAberrationPostProcess;
  59745. private _chromaticAberrationEffect;
  59746. /**
  59747. * Grain post process which add noise to the image
  59748. */
  59749. grain: GrainPostProcess;
  59750. private _grainEffect;
  59751. /**
  59752. * Glow post process which adds a glow to emissive areas of the image
  59753. */
  59754. private _glowLayer;
  59755. /**
  59756. * Animations which can be used to tweak settings over a period of time
  59757. */
  59758. animations: Animation[];
  59759. private _imageProcessingConfigurationObserver;
  59760. private _sharpenEnabled;
  59761. private _bloomEnabled;
  59762. private _depthOfFieldEnabled;
  59763. private _depthOfFieldBlurLevel;
  59764. private _fxaaEnabled;
  59765. private _imageProcessingEnabled;
  59766. private _defaultPipelineTextureType;
  59767. private _bloomScale;
  59768. private _chromaticAberrationEnabled;
  59769. private _grainEnabled;
  59770. private _buildAllowed;
  59771. /**
  59772. * Gets active scene
  59773. */
  59774. readonly scene: Scene;
  59775. /**
  59776. * Enable or disable the sharpen process from the pipeline
  59777. */
  59778. sharpenEnabled: boolean;
  59779. private _resizeObserver;
  59780. private _hardwareScaleLevel;
  59781. private _bloomKernel;
  59782. /**
  59783. * Specifies the size of the bloom blur kernel, relative to the final output size
  59784. */
  59785. bloomKernel: number;
  59786. /**
  59787. * Specifies the weight of the bloom in the final rendering
  59788. */
  59789. private _bloomWeight;
  59790. /**
  59791. * Specifies the luma threshold for the area that will be blurred by the bloom
  59792. */
  59793. private _bloomThreshold;
  59794. private _hdr;
  59795. /**
  59796. * The strength of the bloom.
  59797. */
  59798. bloomWeight: number;
  59799. /**
  59800. * The strength of the bloom.
  59801. */
  59802. bloomThreshold: number;
  59803. /**
  59804. * The scale of the bloom, lower value will provide better performance.
  59805. */
  59806. bloomScale: number;
  59807. /**
  59808. * Enable or disable the bloom from the pipeline
  59809. */
  59810. bloomEnabled: boolean;
  59811. private _rebuildBloom;
  59812. /**
  59813. * If the depth of field is enabled.
  59814. */
  59815. depthOfFieldEnabled: boolean;
  59816. /**
  59817. * Blur level of the depth of field effect. (Higher blur will effect performance)
  59818. */
  59819. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  59820. /**
  59821. * If the anti aliasing is enabled.
  59822. */
  59823. fxaaEnabled: boolean;
  59824. private _samples;
  59825. /**
  59826. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59827. */
  59828. samples: number;
  59829. /**
  59830. * If image processing is enabled.
  59831. */
  59832. imageProcessingEnabled: boolean;
  59833. /**
  59834. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  59835. */
  59836. glowLayerEnabled: boolean;
  59837. /**
  59838. * Gets the glow layer (or null if not defined)
  59839. */
  59840. readonly glowLayer: Nullable<GlowLayer>;
  59841. /**
  59842. * Enable or disable the chromaticAberration process from the pipeline
  59843. */
  59844. chromaticAberrationEnabled: boolean;
  59845. /**
  59846. * Enable or disable the grain process from the pipeline
  59847. */
  59848. grainEnabled: boolean;
  59849. /**
  59850. * @constructor
  59851. * @param name - The rendering pipeline name (default: "")
  59852. * @param hdr - If high dynamic range textures should be used (default: true)
  59853. * @param scene - The scene linked to this pipeline (default: the last created scene)
  59854. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  59855. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  59856. */
  59857. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  59858. /**
  59859. * Get the class name
  59860. * @returns "DefaultRenderingPipeline"
  59861. */
  59862. getClassName(): string;
  59863. /**
  59864. * Force the compilation of the entire pipeline.
  59865. */
  59866. prepare(): void;
  59867. private _hasCleared;
  59868. private _prevPostProcess;
  59869. private _prevPrevPostProcess;
  59870. private _setAutoClearAndTextureSharing;
  59871. private _depthOfFieldSceneObserver;
  59872. private _buildPipeline;
  59873. private _disposePostProcesses;
  59874. /**
  59875. * Adds a camera to the pipeline
  59876. * @param camera the camera to be added
  59877. */
  59878. addCamera(camera: Camera): void;
  59879. /**
  59880. * Removes a camera from the pipeline
  59881. * @param camera the camera to remove
  59882. */
  59883. removeCamera(camera: Camera): void;
  59884. /**
  59885. * Dispose of the pipeline and stop all post processes
  59886. */
  59887. dispose(): void;
  59888. /**
  59889. * Serialize the rendering pipeline (Used when exporting)
  59890. * @returns the serialized object
  59891. */
  59892. serialize(): any;
  59893. /**
  59894. * Parse the serialized pipeline
  59895. * @param source Source pipeline.
  59896. * @param scene The scene to load the pipeline to.
  59897. * @param rootUrl The URL of the serialized pipeline.
  59898. * @returns An instantiated pipeline from the serialized object.
  59899. */
  59900. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  59901. }
  59902. }
  59903. declare module BABYLON {
  59904. /** @hidden */
  59905. export var lensHighlightsPixelShader: {
  59906. name: string;
  59907. shader: string;
  59908. };
  59909. }
  59910. declare module BABYLON {
  59911. /** @hidden */
  59912. export var depthOfFieldPixelShader: {
  59913. name: string;
  59914. shader: string;
  59915. };
  59916. }
  59917. declare module BABYLON {
  59918. /**
  59919. * BABYLON.JS Chromatic Aberration GLSL Shader
  59920. * Author: Olivier Guyot
  59921. * Separates very slightly R, G and B colors on the edges of the screen
  59922. * Inspired by Francois Tarlier & Martins Upitis
  59923. */
  59924. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  59925. /**
  59926. * @ignore
  59927. * The chromatic aberration PostProcess id in the pipeline
  59928. */
  59929. LensChromaticAberrationEffect: string;
  59930. /**
  59931. * @ignore
  59932. * The highlights enhancing PostProcess id in the pipeline
  59933. */
  59934. HighlightsEnhancingEffect: string;
  59935. /**
  59936. * @ignore
  59937. * The depth-of-field PostProcess id in the pipeline
  59938. */
  59939. LensDepthOfFieldEffect: string;
  59940. private _scene;
  59941. private _depthTexture;
  59942. private _grainTexture;
  59943. private _chromaticAberrationPostProcess;
  59944. private _highlightsPostProcess;
  59945. private _depthOfFieldPostProcess;
  59946. private _edgeBlur;
  59947. private _grainAmount;
  59948. private _chromaticAberration;
  59949. private _distortion;
  59950. private _highlightsGain;
  59951. private _highlightsThreshold;
  59952. private _dofDistance;
  59953. private _dofAperture;
  59954. private _dofDarken;
  59955. private _dofPentagon;
  59956. private _blurNoise;
  59957. /**
  59958. * @constructor
  59959. *
  59960. * Effect parameters are as follow:
  59961. * {
  59962. * chromatic_aberration: number; // from 0 to x (1 for realism)
  59963. * edge_blur: number; // from 0 to x (1 for realism)
  59964. * distortion: number; // from 0 to x (1 for realism)
  59965. * grain_amount: number; // from 0 to 1
  59966. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  59967. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  59968. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  59969. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  59970. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  59971. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  59972. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  59973. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  59974. * }
  59975. * Note: if an effect parameter is unset, effect is disabled
  59976. *
  59977. * @param name The rendering pipeline name
  59978. * @param parameters - An object containing all parameters (see above)
  59979. * @param scene The scene linked to this pipeline
  59980. * @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)
  59981. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59982. */
  59983. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  59984. /**
  59985. * Get the class name
  59986. * @returns "LensRenderingPipeline"
  59987. */
  59988. getClassName(): string;
  59989. /**
  59990. * Gets associated scene
  59991. */
  59992. readonly scene: Scene;
  59993. /**
  59994. * Gets or sets the edge blur
  59995. */
  59996. edgeBlur: number;
  59997. /**
  59998. * Gets or sets the grain amount
  59999. */
  60000. grainAmount: number;
  60001. /**
  60002. * Gets or sets the chromatic aberration amount
  60003. */
  60004. chromaticAberration: number;
  60005. /**
  60006. * Gets or sets the depth of field aperture
  60007. */
  60008. dofAperture: number;
  60009. /**
  60010. * Gets or sets the edge distortion
  60011. */
  60012. edgeDistortion: number;
  60013. /**
  60014. * Gets or sets the depth of field distortion
  60015. */
  60016. dofDistortion: number;
  60017. /**
  60018. * Gets or sets the darken out of focus amount
  60019. */
  60020. darkenOutOfFocus: number;
  60021. /**
  60022. * Gets or sets a boolean indicating if blur noise is enabled
  60023. */
  60024. blurNoise: boolean;
  60025. /**
  60026. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  60027. */
  60028. pentagonBokeh: boolean;
  60029. /**
  60030. * Gets or sets the highlight grain amount
  60031. */
  60032. highlightsGain: number;
  60033. /**
  60034. * Gets or sets the highlight threshold
  60035. */
  60036. highlightsThreshold: number;
  60037. /**
  60038. * Sets the amount of blur at the edges
  60039. * @param amount blur amount
  60040. */
  60041. setEdgeBlur(amount: number): void;
  60042. /**
  60043. * Sets edge blur to 0
  60044. */
  60045. disableEdgeBlur(): void;
  60046. /**
  60047. * Sets the amout of grain
  60048. * @param amount Amount of grain
  60049. */
  60050. setGrainAmount(amount: number): void;
  60051. /**
  60052. * Set grain amount to 0
  60053. */
  60054. disableGrain(): void;
  60055. /**
  60056. * Sets the chromatic aberration amount
  60057. * @param amount amount of chromatic aberration
  60058. */
  60059. setChromaticAberration(amount: number): void;
  60060. /**
  60061. * Sets chromatic aberration amount to 0
  60062. */
  60063. disableChromaticAberration(): void;
  60064. /**
  60065. * Sets the EdgeDistortion amount
  60066. * @param amount amount of EdgeDistortion
  60067. */
  60068. setEdgeDistortion(amount: number): void;
  60069. /**
  60070. * Sets edge distortion to 0
  60071. */
  60072. disableEdgeDistortion(): void;
  60073. /**
  60074. * Sets the FocusDistance amount
  60075. * @param amount amount of FocusDistance
  60076. */
  60077. setFocusDistance(amount: number): void;
  60078. /**
  60079. * Disables depth of field
  60080. */
  60081. disableDepthOfField(): void;
  60082. /**
  60083. * Sets the Aperture amount
  60084. * @param amount amount of Aperture
  60085. */
  60086. setAperture(amount: number): void;
  60087. /**
  60088. * Sets the DarkenOutOfFocus amount
  60089. * @param amount amount of DarkenOutOfFocus
  60090. */
  60091. setDarkenOutOfFocus(amount: number): void;
  60092. private _pentagonBokehIsEnabled;
  60093. /**
  60094. * Creates a pentagon bokeh effect
  60095. */
  60096. enablePentagonBokeh(): void;
  60097. /**
  60098. * Disables the pentagon bokeh effect
  60099. */
  60100. disablePentagonBokeh(): void;
  60101. /**
  60102. * Enables noise blur
  60103. */
  60104. enableNoiseBlur(): void;
  60105. /**
  60106. * Disables noise blur
  60107. */
  60108. disableNoiseBlur(): void;
  60109. /**
  60110. * Sets the HighlightsGain amount
  60111. * @param amount amount of HighlightsGain
  60112. */
  60113. setHighlightsGain(amount: number): void;
  60114. /**
  60115. * Sets the HighlightsThreshold amount
  60116. * @param amount amount of HighlightsThreshold
  60117. */
  60118. setHighlightsThreshold(amount: number): void;
  60119. /**
  60120. * Disables highlights
  60121. */
  60122. disableHighlights(): void;
  60123. /**
  60124. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  60125. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  60126. */
  60127. dispose(disableDepthRender?: boolean): void;
  60128. private _createChromaticAberrationPostProcess;
  60129. private _createHighlightsPostProcess;
  60130. private _createDepthOfFieldPostProcess;
  60131. private _createGrainTexture;
  60132. }
  60133. }
  60134. declare module BABYLON {
  60135. /** @hidden */
  60136. export var ssao2PixelShader: {
  60137. name: string;
  60138. shader: string;
  60139. };
  60140. }
  60141. declare module BABYLON {
  60142. /** @hidden */
  60143. export var ssaoCombinePixelShader: {
  60144. name: string;
  60145. shader: string;
  60146. };
  60147. }
  60148. declare module BABYLON {
  60149. /**
  60150. * Render pipeline to produce ssao effect
  60151. */
  60152. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  60153. /**
  60154. * @ignore
  60155. * The PassPostProcess id in the pipeline that contains the original scene color
  60156. */
  60157. SSAOOriginalSceneColorEffect: string;
  60158. /**
  60159. * @ignore
  60160. * The SSAO PostProcess id in the pipeline
  60161. */
  60162. SSAORenderEffect: string;
  60163. /**
  60164. * @ignore
  60165. * The horizontal blur PostProcess id in the pipeline
  60166. */
  60167. SSAOBlurHRenderEffect: string;
  60168. /**
  60169. * @ignore
  60170. * The vertical blur PostProcess id in the pipeline
  60171. */
  60172. SSAOBlurVRenderEffect: string;
  60173. /**
  60174. * @ignore
  60175. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  60176. */
  60177. SSAOCombineRenderEffect: string;
  60178. /**
  60179. * The output strength of the SSAO post-process. Default value is 1.0.
  60180. */
  60181. totalStrength: number;
  60182. /**
  60183. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  60184. */
  60185. maxZ: number;
  60186. /**
  60187. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  60188. */
  60189. minZAspect: number;
  60190. private _samples;
  60191. /**
  60192. * Number of samples used for the SSAO calculations. Default value is 8
  60193. */
  60194. samples: number;
  60195. private _textureSamples;
  60196. /**
  60197. * Number of samples to use for antialiasing
  60198. */
  60199. textureSamples: number;
  60200. /**
  60201. * Ratio object used for SSAO ratio and blur ratio
  60202. */
  60203. private _ratio;
  60204. /**
  60205. * Dynamically generated sphere sampler.
  60206. */
  60207. private _sampleSphere;
  60208. /**
  60209. * Blur filter offsets
  60210. */
  60211. private _samplerOffsets;
  60212. private _expensiveBlur;
  60213. /**
  60214. * If bilateral blur should be used
  60215. */
  60216. expensiveBlur: boolean;
  60217. /**
  60218. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  60219. */
  60220. radius: number;
  60221. /**
  60222. * The base color of the SSAO post-process
  60223. * The final result is "base + ssao" between [0, 1]
  60224. */
  60225. base: number;
  60226. /**
  60227. * Support test.
  60228. */
  60229. static readonly IsSupported: boolean;
  60230. private _scene;
  60231. private _depthTexture;
  60232. private _normalTexture;
  60233. private _randomTexture;
  60234. private _originalColorPostProcess;
  60235. private _ssaoPostProcess;
  60236. private _blurHPostProcess;
  60237. private _blurVPostProcess;
  60238. private _ssaoCombinePostProcess;
  60239. private _firstUpdate;
  60240. /**
  60241. * Gets active scene
  60242. */
  60243. readonly scene: Scene;
  60244. /**
  60245. * @constructor
  60246. * @param name The rendering pipeline name
  60247. * @param scene The scene linked to this pipeline
  60248. * @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 }
  60249. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60250. */
  60251. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  60252. /**
  60253. * Get the class name
  60254. * @returns "SSAO2RenderingPipeline"
  60255. */
  60256. getClassName(): string;
  60257. /**
  60258. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  60259. */
  60260. dispose(disableGeometryBufferRenderer?: boolean): void;
  60261. private _createBlurPostProcess;
  60262. /** @hidden */ private _rebuild(): void;
  60263. private _bits;
  60264. private _radicalInverse_VdC;
  60265. private _hammersley;
  60266. private _hemisphereSample_uniform;
  60267. private _generateHemisphere;
  60268. private _createSSAOPostProcess;
  60269. private _createSSAOCombinePostProcess;
  60270. private _createRandomTexture;
  60271. /**
  60272. * Serialize the rendering pipeline (Used when exporting)
  60273. * @returns the serialized object
  60274. */
  60275. serialize(): any;
  60276. /**
  60277. * Parse the serialized pipeline
  60278. * @param source Source pipeline.
  60279. * @param scene The scene to load the pipeline to.
  60280. * @param rootUrl The URL of the serialized pipeline.
  60281. * @returns An instantiated pipeline from the serialized object.
  60282. */
  60283. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  60284. }
  60285. }
  60286. declare module BABYLON {
  60287. /** @hidden */
  60288. export var ssaoPixelShader: {
  60289. name: string;
  60290. shader: string;
  60291. };
  60292. }
  60293. declare module BABYLON {
  60294. /**
  60295. * Render pipeline to produce ssao effect
  60296. */
  60297. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  60298. /**
  60299. * @ignore
  60300. * The PassPostProcess id in the pipeline that contains the original scene color
  60301. */
  60302. SSAOOriginalSceneColorEffect: string;
  60303. /**
  60304. * @ignore
  60305. * The SSAO PostProcess id in the pipeline
  60306. */
  60307. SSAORenderEffect: string;
  60308. /**
  60309. * @ignore
  60310. * The horizontal blur PostProcess id in the pipeline
  60311. */
  60312. SSAOBlurHRenderEffect: string;
  60313. /**
  60314. * @ignore
  60315. * The vertical blur PostProcess id in the pipeline
  60316. */
  60317. SSAOBlurVRenderEffect: string;
  60318. /**
  60319. * @ignore
  60320. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  60321. */
  60322. SSAOCombineRenderEffect: string;
  60323. /**
  60324. * The output strength of the SSAO post-process. Default value is 1.0.
  60325. */
  60326. totalStrength: number;
  60327. /**
  60328. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  60329. */
  60330. radius: number;
  60331. /**
  60332. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  60333. * Must not be equal to fallOff and superior to fallOff.
  60334. * Default value is 0.0075
  60335. */
  60336. area: number;
  60337. /**
  60338. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  60339. * Must not be equal to area and inferior to area.
  60340. * Default value is 0.000001
  60341. */
  60342. fallOff: number;
  60343. /**
  60344. * The base color of the SSAO post-process
  60345. * The final result is "base + ssao" between [0, 1]
  60346. */
  60347. base: number;
  60348. private _scene;
  60349. private _depthTexture;
  60350. private _randomTexture;
  60351. private _originalColorPostProcess;
  60352. private _ssaoPostProcess;
  60353. private _blurHPostProcess;
  60354. private _blurVPostProcess;
  60355. private _ssaoCombinePostProcess;
  60356. private _firstUpdate;
  60357. /**
  60358. * Gets active scene
  60359. */
  60360. readonly scene: Scene;
  60361. /**
  60362. * @constructor
  60363. * @param name - The rendering pipeline name
  60364. * @param scene - The scene linked to this pipeline
  60365. * @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 }
  60366. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  60367. */
  60368. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  60369. /**
  60370. * Get the class name
  60371. * @returns "SSAORenderingPipeline"
  60372. */
  60373. getClassName(): string;
  60374. /**
  60375. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  60376. */
  60377. dispose(disableDepthRender?: boolean): void;
  60378. private _createBlurPostProcess;
  60379. /** @hidden */ private _rebuild(): void;
  60380. private _createSSAOPostProcess;
  60381. private _createSSAOCombinePostProcess;
  60382. private _createRandomTexture;
  60383. }
  60384. }
  60385. declare module BABYLON {
  60386. /** @hidden */
  60387. export var standardPixelShader: {
  60388. name: string;
  60389. shader: string;
  60390. };
  60391. }
  60392. declare module BABYLON {
  60393. /**
  60394. * Standard rendering pipeline
  60395. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  60396. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  60397. */
  60398. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  60399. /**
  60400. * Public members
  60401. */
  60402. /**
  60403. * Post-process which contains the original scene color before the pipeline applies all the effects
  60404. */
  60405. originalPostProcess: Nullable<PostProcess>;
  60406. /**
  60407. * Post-process used to down scale an image x4
  60408. */
  60409. downSampleX4PostProcess: Nullable<PostProcess>;
  60410. /**
  60411. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  60412. */
  60413. brightPassPostProcess: Nullable<PostProcess>;
  60414. /**
  60415. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  60416. */
  60417. blurHPostProcesses: PostProcess[];
  60418. /**
  60419. * Post-process array storing all the vertical blur post-processes used by the pipeline
  60420. */
  60421. blurVPostProcesses: PostProcess[];
  60422. /**
  60423. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  60424. */
  60425. textureAdderPostProcess: Nullable<PostProcess>;
  60426. /**
  60427. * Post-process used to create volumetric lighting effect
  60428. */
  60429. volumetricLightPostProcess: Nullable<PostProcess>;
  60430. /**
  60431. * Post-process used to smooth the previous volumetric light post-process on the X axis
  60432. */
  60433. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  60434. /**
  60435. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  60436. */
  60437. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  60438. /**
  60439. * Post-process used to merge the volumetric light effect and the real scene color
  60440. */
  60441. volumetricLightMergePostProces: Nullable<PostProcess>;
  60442. /**
  60443. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  60444. */
  60445. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  60446. /**
  60447. * Base post-process used to calculate the average luminance of the final image for HDR
  60448. */
  60449. luminancePostProcess: Nullable<PostProcess>;
  60450. /**
  60451. * Post-processes used to create down sample post-processes in order to get
  60452. * the average luminance of the final image for HDR
  60453. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  60454. */
  60455. luminanceDownSamplePostProcesses: PostProcess[];
  60456. /**
  60457. * Post-process used to create a HDR effect (light adaptation)
  60458. */
  60459. hdrPostProcess: Nullable<PostProcess>;
  60460. /**
  60461. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  60462. */
  60463. textureAdderFinalPostProcess: Nullable<PostProcess>;
  60464. /**
  60465. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  60466. */
  60467. lensFlareFinalPostProcess: Nullable<PostProcess>;
  60468. /**
  60469. * Post-process used to merge the final HDR post-process and the real scene color
  60470. */
  60471. hdrFinalPostProcess: Nullable<PostProcess>;
  60472. /**
  60473. * Post-process used to create a lens flare effect
  60474. */
  60475. lensFlarePostProcess: Nullable<PostProcess>;
  60476. /**
  60477. * Post-process that merges the result of the lens flare post-process and the real scene color
  60478. */
  60479. lensFlareComposePostProcess: Nullable<PostProcess>;
  60480. /**
  60481. * Post-process used to create a motion blur effect
  60482. */
  60483. motionBlurPostProcess: Nullable<PostProcess>;
  60484. /**
  60485. * Post-process used to create a depth of field effect
  60486. */
  60487. depthOfFieldPostProcess: Nullable<PostProcess>;
  60488. /**
  60489. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  60490. */
  60491. fxaaPostProcess: Nullable<FxaaPostProcess>;
  60492. /**
  60493. * Represents the brightness threshold in order to configure the illuminated surfaces
  60494. */
  60495. brightThreshold: number;
  60496. /**
  60497. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  60498. */
  60499. blurWidth: number;
  60500. /**
  60501. * Sets if the blur for highlighted surfaces must be only horizontal
  60502. */
  60503. horizontalBlur: boolean;
  60504. /**
  60505. * Gets the overall exposure used by the pipeline
  60506. */
  60507. /**
  60508. * Sets the overall exposure used by the pipeline
  60509. */
  60510. exposure: number;
  60511. /**
  60512. * Texture used typically to simulate "dirty" on camera lens
  60513. */
  60514. lensTexture: Nullable<Texture>;
  60515. /**
  60516. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  60517. */
  60518. volumetricLightCoefficient: number;
  60519. /**
  60520. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  60521. */
  60522. volumetricLightPower: number;
  60523. /**
  60524. * Used the set the blur intensity to smooth the volumetric lights
  60525. */
  60526. volumetricLightBlurScale: number;
  60527. /**
  60528. * Light (spot or directional) used to generate the volumetric lights rays
  60529. * The source light must have a shadow generate so the pipeline can get its
  60530. * depth map
  60531. */
  60532. sourceLight: Nullable<SpotLight | DirectionalLight>;
  60533. /**
  60534. * For eye adaptation, represents the minimum luminance the eye can see
  60535. */
  60536. hdrMinimumLuminance: number;
  60537. /**
  60538. * For eye adaptation, represents the decrease luminance speed
  60539. */
  60540. hdrDecreaseRate: number;
  60541. /**
  60542. * For eye adaptation, represents the increase luminance speed
  60543. */
  60544. hdrIncreaseRate: number;
  60545. /**
  60546. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  60547. */
  60548. /**
  60549. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  60550. */
  60551. hdrAutoExposure: boolean;
  60552. /**
  60553. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  60554. */
  60555. lensColorTexture: Nullable<Texture>;
  60556. /**
  60557. * The overall strengh for the lens flare effect
  60558. */
  60559. lensFlareStrength: number;
  60560. /**
  60561. * Dispersion coefficient for lens flare ghosts
  60562. */
  60563. lensFlareGhostDispersal: number;
  60564. /**
  60565. * Main lens flare halo width
  60566. */
  60567. lensFlareHaloWidth: number;
  60568. /**
  60569. * Based on the lens distortion effect, defines how much the lens flare result
  60570. * is distorted
  60571. */
  60572. lensFlareDistortionStrength: number;
  60573. /**
  60574. * Configures the blur intensity used for for lens flare (halo)
  60575. */
  60576. lensFlareBlurWidth: number;
  60577. /**
  60578. * Lens star texture must be used to simulate rays on the flares and is available
  60579. * in the documentation
  60580. */
  60581. lensStarTexture: Nullable<Texture>;
  60582. /**
  60583. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  60584. * flare effect by taking account of the dirt texture
  60585. */
  60586. lensFlareDirtTexture: Nullable<Texture>;
  60587. /**
  60588. * Represents the focal length for the depth of field effect
  60589. */
  60590. depthOfFieldDistance: number;
  60591. /**
  60592. * Represents the blur intensity for the blurred part of the depth of field effect
  60593. */
  60594. depthOfFieldBlurWidth: number;
  60595. /**
  60596. * Gets how much the image is blurred by the movement while using the motion blur post-process
  60597. */
  60598. /**
  60599. * Sets how much the image is blurred by the movement while using the motion blur post-process
  60600. */
  60601. motionStrength: number;
  60602. /**
  60603. * Gets wether or not the motion blur post-process is object based or screen based.
  60604. */
  60605. /**
  60606. * Sets wether or not the motion blur post-process should be object based or screen based
  60607. */
  60608. objectBasedMotionBlur: boolean;
  60609. /**
  60610. * List of animations for the pipeline (IAnimatable implementation)
  60611. */
  60612. animations: Animation[];
  60613. /**
  60614. * Private members
  60615. */
  60616. private _scene;
  60617. private _currentDepthOfFieldSource;
  60618. private _basePostProcess;
  60619. private _fixedExposure;
  60620. private _currentExposure;
  60621. private _hdrAutoExposure;
  60622. private _hdrCurrentLuminance;
  60623. private _motionStrength;
  60624. private _isObjectBasedMotionBlur;
  60625. private _floatTextureType;
  60626. private _camerasToBeAttached;
  60627. private _ratio;
  60628. private _bloomEnabled;
  60629. private _depthOfFieldEnabled;
  60630. private _vlsEnabled;
  60631. private _lensFlareEnabled;
  60632. private _hdrEnabled;
  60633. private _motionBlurEnabled;
  60634. private _fxaaEnabled;
  60635. private _motionBlurSamples;
  60636. private _volumetricLightStepsCount;
  60637. private _samples;
  60638. /**
  60639. * @ignore
  60640. * Specifies if the bloom pipeline is enabled
  60641. */
  60642. BloomEnabled: boolean;
  60643. /**
  60644. * @ignore
  60645. * Specifies if the depth of field pipeline is enabed
  60646. */
  60647. DepthOfFieldEnabled: boolean;
  60648. /**
  60649. * @ignore
  60650. * Specifies if the lens flare pipeline is enabed
  60651. */
  60652. LensFlareEnabled: boolean;
  60653. /**
  60654. * @ignore
  60655. * Specifies if the HDR pipeline is enabled
  60656. */
  60657. HDREnabled: boolean;
  60658. /**
  60659. * @ignore
  60660. * Specifies if the volumetric lights scattering effect is enabled
  60661. */
  60662. VLSEnabled: boolean;
  60663. /**
  60664. * @ignore
  60665. * Specifies if the motion blur effect is enabled
  60666. */
  60667. MotionBlurEnabled: boolean;
  60668. /**
  60669. * Specifies if anti-aliasing is enabled
  60670. */
  60671. fxaaEnabled: boolean;
  60672. /**
  60673. * Specifies the number of steps used to calculate the volumetric lights
  60674. * Typically in interval [50, 200]
  60675. */
  60676. volumetricLightStepsCount: number;
  60677. /**
  60678. * Specifies the number of samples used for the motion blur effect
  60679. * Typically in interval [16, 64]
  60680. */
  60681. motionBlurSamples: number;
  60682. /**
  60683. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60684. */
  60685. samples: number;
  60686. /**
  60687. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  60688. * @constructor
  60689. * @param name The rendering pipeline name
  60690. * @param scene The scene linked to this pipeline
  60691. * @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)
  60692. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  60693. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60694. */
  60695. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  60696. private _buildPipeline;
  60697. private _createDownSampleX4PostProcess;
  60698. private _createBrightPassPostProcess;
  60699. private _createBlurPostProcesses;
  60700. private _createTextureAdderPostProcess;
  60701. private _createVolumetricLightPostProcess;
  60702. private _createLuminancePostProcesses;
  60703. private _createHdrPostProcess;
  60704. private _createLensFlarePostProcess;
  60705. private _createDepthOfFieldPostProcess;
  60706. private _createMotionBlurPostProcess;
  60707. private _getDepthTexture;
  60708. private _disposePostProcesses;
  60709. /**
  60710. * Dispose of the pipeline and stop all post processes
  60711. */
  60712. dispose(): void;
  60713. /**
  60714. * Serialize the rendering pipeline (Used when exporting)
  60715. * @returns the serialized object
  60716. */
  60717. serialize(): any;
  60718. /**
  60719. * Parse the serialized pipeline
  60720. * @param source Source pipeline.
  60721. * @param scene The scene to load the pipeline to.
  60722. * @param rootUrl The URL of the serialized pipeline.
  60723. * @returns An instantiated pipeline from the serialized object.
  60724. */
  60725. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  60726. /**
  60727. * Luminance steps
  60728. */
  60729. static LuminanceSteps: number;
  60730. }
  60731. }
  60732. declare module BABYLON {
  60733. /** @hidden */
  60734. export var tonemapPixelShader: {
  60735. name: string;
  60736. shader: string;
  60737. };
  60738. }
  60739. declare module BABYLON {
  60740. /** Defines operator used for tonemapping */
  60741. export enum TonemappingOperator {
  60742. /** Hable */
  60743. Hable = 0,
  60744. /** Reinhard */
  60745. Reinhard = 1,
  60746. /** HejiDawson */
  60747. HejiDawson = 2,
  60748. /** Photographic */
  60749. Photographic = 3
  60750. }
  60751. /**
  60752. * Defines a post process to apply tone mapping
  60753. */
  60754. export class TonemapPostProcess extends PostProcess {
  60755. private _operator;
  60756. /** Defines the required exposure adjustement */
  60757. exposureAdjustment: number;
  60758. /**
  60759. * Creates a new TonemapPostProcess
  60760. * @param name defines the name of the postprocess
  60761. * @param _operator defines the operator to use
  60762. * @param exposureAdjustment defines the required exposure adjustement
  60763. * @param camera defines the camera to use (can be null)
  60764. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  60765. * @param engine defines the hosting engine (can be ignore if camera is set)
  60766. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60767. */
  60768. constructor(name: string, _operator: TonemappingOperator,
  60769. /** Defines the required exposure adjustement */
  60770. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  60771. }
  60772. }
  60773. declare module BABYLON {
  60774. /** @hidden */
  60775. export var depthVertexShader: {
  60776. name: string;
  60777. shader: string;
  60778. };
  60779. }
  60780. declare module BABYLON {
  60781. /** @hidden */
  60782. export var volumetricLightScatteringPixelShader: {
  60783. name: string;
  60784. shader: string;
  60785. };
  60786. }
  60787. declare module BABYLON {
  60788. /** @hidden */
  60789. export var volumetricLightScatteringPassVertexShader: {
  60790. name: string;
  60791. shader: string;
  60792. };
  60793. }
  60794. declare module BABYLON {
  60795. /** @hidden */
  60796. export var volumetricLightScatteringPassPixelShader: {
  60797. name: string;
  60798. shader: string;
  60799. };
  60800. }
  60801. declare module BABYLON {
  60802. /**
  60803. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  60804. */
  60805. export class VolumetricLightScatteringPostProcess extends PostProcess {
  60806. private _volumetricLightScatteringPass;
  60807. private _volumetricLightScatteringRTT;
  60808. private _viewPort;
  60809. private _screenCoordinates;
  60810. private _cachedDefines;
  60811. /**
  60812. * If not undefined, the mesh position is computed from the attached node position
  60813. */
  60814. attachedNode: {
  60815. position: Vector3;
  60816. };
  60817. /**
  60818. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  60819. */
  60820. customMeshPosition: Vector3;
  60821. /**
  60822. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  60823. */
  60824. useCustomMeshPosition: boolean;
  60825. /**
  60826. * If the post-process should inverse the light scattering direction
  60827. */
  60828. invert: boolean;
  60829. /**
  60830. * The internal mesh used by the post-process
  60831. */
  60832. mesh: Mesh;
  60833. /**
  60834. * @hidden
  60835. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  60836. */
  60837. useDiffuseColor: boolean;
  60838. /**
  60839. * Array containing the excluded meshes not rendered in the internal pass
  60840. */
  60841. excludedMeshes: AbstractMesh[];
  60842. /**
  60843. * Controls the overall intensity of the post-process
  60844. */
  60845. exposure: number;
  60846. /**
  60847. * Dissipates each sample's contribution in range [0, 1]
  60848. */
  60849. decay: number;
  60850. /**
  60851. * Controls the overall intensity of each sample
  60852. */
  60853. weight: number;
  60854. /**
  60855. * Controls the density of each sample
  60856. */
  60857. density: number;
  60858. /**
  60859. * @constructor
  60860. * @param name The post-process name
  60861. * @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)
  60862. * @param camera The camera that the post-process will be attached to
  60863. * @param mesh The mesh used to create the light scattering
  60864. * @param samples The post-process quality, default 100
  60865. * @param samplingModeThe post-process filtering mode
  60866. * @param engine The babylon engine
  60867. * @param reusable If the post-process is reusable
  60868. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  60869. */
  60870. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  60871. /**
  60872. * Returns the string "VolumetricLightScatteringPostProcess"
  60873. * @returns "VolumetricLightScatteringPostProcess"
  60874. */
  60875. getClassName(): string;
  60876. private _isReady;
  60877. /**
  60878. * Sets the new light position for light scattering effect
  60879. * @param position The new custom light position
  60880. */
  60881. setCustomMeshPosition(position: Vector3): void;
  60882. /**
  60883. * Returns the light position for light scattering effect
  60884. * @return Vector3 The custom light position
  60885. */
  60886. getCustomMeshPosition(): Vector3;
  60887. /**
  60888. * Disposes the internal assets and detaches the post-process from the camera
  60889. */
  60890. dispose(camera: Camera): void;
  60891. /**
  60892. * Returns the render target texture used by the post-process
  60893. * @return the render target texture used by the post-process
  60894. */
  60895. getPass(): RenderTargetTexture;
  60896. private _meshExcluded;
  60897. private _createPass;
  60898. private _updateMeshScreenCoordinates;
  60899. /**
  60900. * Creates a default mesh for the Volumeric Light Scattering post-process
  60901. * @param name The mesh name
  60902. * @param scene The scene where to create the mesh
  60903. * @return the default mesh
  60904. */
  60905. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  60906. }
  60907. }
  60908. declare module BABYLON {
  60909. interface Scene {
  60910. /** @hidden (Backing field) */ private _boundingBoxRenderer: BoundingBoxRenderer;
  60911. /** @hidden (Backing field) */ private _forceShowBoundingBoxes: boolean;
  60912. /**
  60913. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  60914. */
  60915. forceShowBoundingBoxes: boolean;
  60916. /**
  60917. * Gets the bounding box renderer associated with the scene
  60918. * @returns a BoundingBoxRenderer
  60919. */
  60920. getBoundingBoxRenderer(): BoundingBoxRenderer;
  60921. }
  60922. interface AbstractMesh {
  60923. /** @hidden (Backing field) */ private _showBoundingBox: boolean;
  60924. /**
  60925. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  60926. */
  60927. showBoundingBox: boolean;
  60928. }
  60929. /**
  60930. * Component responsible of rendering the bounding box of the meshes in a scene.
  60931. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  60932. */
  60933. export class BoundingBoxRenderer implements ISceneComponent {
  60934. /**
  60935. * The component name helpfull to identify the component in the list of scene components.
  60936. */
  60937. readonly name: string;
  60938. /**
  60939. * The scene the component belongs to.
  60940. */
  60941. scene: Scene;
  60942. /**
  60943. * Color of the bounding box lines placed in front of an object
  60944. */
  60945. frontColor: Color3;
  60946. /**
  60947. * Color of the bounding box lines placed behind an object
  60948. */
  60949. backColor: Color3;
  60950. /**
  60951. * Defines if the renderer should show the back lines or not
  60952. */
  60953. showBackLines: boolean;
  60954. /**
  60955. * @hidden
  60956. */
  60957. renderList: SmartArray<BoundingBox>;
  60958. private _colorShader;
  60959. private _vertexBuffers;
  60960. private _indexBuffer;
  60961. private _fillIndexBuffer;
  60962. private _fillIndexData;
  60963. /**
  60964. * Instantiates a new bounding box renderer in a scene.
  60965. * @param scene the scene the renderer renders in
  60966. */
  60967. constructor(scene: Scene);
  60968. /**
  60969. * Registers the component in a given scene
  60970. */
  60971. register(): void;
  60972. private _evaluateSubMesh;
  60973. private _activeMesh;
  60974. private _prepareRessources;
  60975. private _createIndexBuffer;
  60976. /**
  60977. * Rebuilds the elements related to this component in case of
  60978. * context lost for instance.
  60979. */
  60980. rebuild(): void;
  60981. /**
  60982. * @hidden
  60983. */
  60984. reset(): void;
  60985. /**
  60986. * Render the bounding boxes of a specific rendering group
  60987. * @param renderingGroupId defines the rendering group to render
  60988. */
  60989. render(renderingGroupId: number): void;
  60990. /**
  60991. * In case of occlusion queries, we can render the occlusion bounding box through this method
  60992. * @param mesh Define the mesh to render the occlusion bounding box for
  60993. */
  60994. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  60995. /**
  60996. * Dispose and release the resources attached to this renderer.
  60997. */
  60998. dispose(): void;
  60999. }
  61000. }
  61001. declare module BABYLON {
  61002. /** @hidden */
  61003. export var depthPixelShader: {
  61004. name: string;
  61005. shader: string;
  61006. };
  61007. }
  61008. declare module BABYLON {
  61009. /**
  61010. * This represents a depth renderer in Babylon.
  61011. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  61012. */
  61013. export class DepthRenderer {
  61014. private _scene;
  61015. private _depthMap;
  61016. private _effect;
  61017. private readonly _storeNonLinearDepth;
  61018. private readonly _clearColor;
  61019. /** Get if the depth renderer is using packed depth or not */
  61020. readonly isPacked: boolean;
  61021. private _cachedDefines;
  61022. private _camera;
  61023. /**
  61024. * Specifiess that the depth renderer will only be used within
  61025. * the camera it is created for.
  61026. * This can help forcing its rendering during the camera processing.
  61027. */
  61028. useOnlyInActiveCamera: boolean;
  61029. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  61030. /**
  61031. * Instantiates a depth renderer
  61032. * @param scene The scene the renderer belongs to
  61033. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61034. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61035. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61036. */
  61037. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61038. /**
  61039. * Creates the depth rendering effect and checks if the effect is ready.
  61040. * @param subMesh The submesh to be used to render the depth map of
  61041. * @param useInstances If multiple world instances should be used
  61042. * @returns if the depth renderer is ready to render the depth map
  61043. */
  61044. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61045. /**
  61046. * Gets the texture which the depth map will be written to.
  61047. * @returns The depth map texture
  61048. */
  61049. getDepthMap(): RenderTargetTexture;
  61050. /**
  61051. * Disposes of the depth renderer.
  61052. */
  61053. dispose(): void;
  61054. }
  61055. }
  61056. declare module BABYLON {
  61057. interface Scene {
  61058. /** @hidden (Backing field) */ private _depthRenderer: {
  61059. [id: string]: DepthRenderer;
  61060. };
  61061. /**
  61062. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  61063. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  61064. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61065. * @returns the created depth renderer
  61066. */
  61067. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  61068. /**
  61069. * Disables a depth renderer for a given camera
  61070. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  61071. */
  61072. disableDepthRenderer(camera?: Nullable<Camera>): void;
  61073. }
  61074. /**
  61075. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  61076. * in several rendering techniques.
  61077. */
  61078. export class DepthRendererSceneComponent implements ISceneComponent {
  61079. /**
  61080. * The component name helpfull to identify the component in the list of scene components.
  61081. */
  61082. readonly name: string;
  61083. /**
  61084. * The scene the component belongs to.
  61085. */
  61086. scene: Scene;
  61087. /**
  61088. * Creates a new instance of the component for the given scene
  61089. * @param scene Defines the scene to register the component in
  61090. */
  61091. constructor(scene: Scene);
  61092. /**
  61093. * Registers the component in a given scene
  61094. */
  61095. register(): void;
  61096. /**
  61097. * Rebuilds the elements related to this component in case of
  61098. * context lost for instance.
  61099. */
  61100. rebuild(): void;
  61101. /**
  61102. * Disposes the component and the associated ressources
  61103. */
  61104. dispose(): void;
  61105. private _gatherRenderTargets;
  61106. private _gatherActiveCameraRenderTargets;
  61107. }
  61108. }
  61109. declare module BABYLON {
  61110. /** @hidden */
  61111. export var outlinePixelShader: {
  61112. name: string;
  61113. shader: string;
  61114. };
  61115. }
  61116. declare module BABYLON {
  61117. /** @hidden */
  61118. export var outlineVertexShader: {
  61119. name: string;
  61120. shader: string;
  61121. };
  61122. }
  61123. declare module BABYLON {
  61124. interface Scene {
  61125. /** @hidden */ private _outlineRenderer: OutlineRenderer;
  61126. /**
  61127. * Gets the outline renderer associated with the scene
  61128. * @returns a OutlineRenderer
  61129. */
  61130. getOutlineRenderer(): OutlineRenderer;
  61131. }
  61132. interface AbstractMesh {
  61133. /** @hidden (Backing field) */ private _renderOutline: boolean;
  61134. /**
  61135. * Gets or sets a boolean indicating if the outline must be rendered as well
  61136. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  61137. */
  61138. renderOutline: boolean;
  61139. /** @hidden (Backing field) */ private _renderOverlay: boolean;
  61140. /**
  61141. * Gets or sets a boolean indicating if the overlay must be rendered as well
  61142. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  61143. */
  61144. renderOverlay: boolean;
  61145. }
  61146. /**
  61147. * This class is responsible to draw bothe outline/overlay of meshes.
  61148. * It should not be used directly but through the available method on mesh.
  61149. */
  61150. export class OutlineRenderer implements ISceneComponent {
  61151. /**
  61152. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  61153. */
  61154. private static _StencilReference;
  61155. /**
  61156. * The name of the component. Each component must have a unique name.
  61157. */
  61158. name: string;
  61159. /**
  61160. * The scene the component belongs to.
  61161. */
  61162. scene: Scene;
  61163. /**
  61164. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  61165. */
  61166. zOffset: number;
  61167. private _engine;
  61168. private _effect;
  61169. private _cachedDefines;
  61170. private _savedDepthWrite;
  61171. /**
  61172. * Instantiates a new outline renderer. (There could be only one per scene).
  61173. * @param scene Defines the scene it belongs to
  61174. */
  61175. constructor(scene: Scene);
  61176. /**
  61177. * Register the component to one instance of a scene.
  61178. */
  61179. register(): void;
  61180. /**
  61181. * Rebuilds the elements related to this component in case of
  61182. * context lost for instance.
  61183. */
  61184. rebuild(): void;
  61185. /**
  61186. * Disposes the component and the associated ressources.
  61187. */
  61188. dispose(): void;
  61189. /**
  61190. * Renders the outline in the canvas.
  61191. * @param subMesh Defines the sumesh to render
  61192. * @param batch Defines the batch of meshes in case of instances
  61193. * @param useOverlay Defines if the rendering is for the overlay or the outline
  61194. */
  61195. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  61196. /**
  61197. * Returns whether or not the outline renderer is ready for a given submesh.
  61198. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  61199. * @param subMesh Defines the submesh to check readyness for
  61200. * @param useInstances Defines wheter wee are trying to render instances or not
  61201. * @returns true if ready otherwise false
  61202. */
  61203. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61204. private _beforeRenderingMesh;
  61205. private _afterRenderingMesh;
  61206. }
  61207. }
  61208. declare module BABYLON {
  61209. /**
  61210. * Class used to manage multiple sprites of different sizes on the same spritesheet
  61211. * @see http://doc.babylonjs.com/babylon101/sprites
  61212. */
  61213. export class SpritePackedManager extends SpriteManager {
  61214. /** defines the packed manager's name */
  61215. name: string;
  61216. /**
  61217. * Creates a new sprite manager from a packed sprite sheet
  61218. * @param name defines the manager's name
  61219. * @param imgUrl defines the sprite sheet url
  61220. * @param capacity defines the maximum allowed number of sprites
  61221. * @param scene defines the hosting scene
  61222. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  61223. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  61224. * @param samplingMode defines the smapling mode to use with spritesheet
  61225. * @param fromPacked set to true; do not alter
  61226. */
  61227. constructor(
  61228. /** defines the packed manager's name */
  61229. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  61230. }
  61231. }
  61232. declare module BABYLON {
  61233. /**
  61234. * Defines the list of states available for a task inside a AssetsManager
  61235. */
  61236. export enum AssetTaskState {
  61237. /**
  61238. * Initialization
  61239. */
  61240. INIT = 0,
  61241. /**
  61242. * Running
  61243. */
  61244. RUNNING = 1,
  61245. /**
  61246. * Done
  61247. */
  61248. DONE = 2,
  61249. /**
  61250. * Error
  61251. */
  61252. ERROR = 3
  61253. }
  61254. /**
  61255. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  61256. */
  61257. export abstract class AbstractAssetTask {
  61258. /**
  61259. * Task name
  61260. */ name: string;
  61261. /**
  61262. * Callback called when the task is successful
  61263. */
  61264. onSuccess: (task: any) => void;
  61265. /**
  61266. * Callback called when the task is not successful
  61267. */
  61268. onError: (task: any, message?: string, exception?: any) => void;
  61269. /**
  61270. * Creates a new AssetsManager
  61271. * @param name defines the name of the task
  61272. */
  61273. constructor(
  61274. /**
  61275. * Task name
  61276. */ name: string);
  61277. private _isCompleted;
  61278. private _taskState;
  61279. private _errorObject;
  61280. /**
  61281. * Get if the task is completed
  61282. */
  61283. readonly isCompleted: boolean;
  61284. /**
  61285. * Gets the current state of the task
  61286. */
  61287. readonly taskState: AssetTaskState;
  61288. /**
  61289. * Gets the current error object (if task is in error)
  61290. */
  61291. readonly errorObject: {
  61292. message?: string;
  61293. exception?: any;
  61294. };
  61295. /**
  61296. * Internal only
  61297. * @hidden
  61298. */ private _setErrorObject(message?: string, exception?: any): void;
  61299. /**
  61300. * Execute the current task
  61301. * @param scene defines the scene where you want your assets to be loaded
  61302. * @param onSuccess is a callback called when the task is successfully executed
  61303. * @param onError is a callback called if an error occurs
  61304. */
  61305. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61306. /**
  61307. * Execute the current task
  61308. * @param scene defines the scene where you want your assets to be loaded
  61309. * @param onSuccess is a callback called when the task is successfully executed
  61310. * @param onError is a callback called if an error occurs
  61311. */
  61312. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61313. /**
  61314. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  61315. * This can be used with failed tasks that have the reason for failure fixed.
  61316. */
  61317. reset(): void;
  61318. private onErrorCallback;
  61319. private onDoneCallback;
  61320. }
  61321. /**
  61322. * Define the interface used by progress events raised during assets loading
  61323. */
  61324. export interface IAssetsProgressEvent {
  61325. /**
  61326. * Defines the number of remaining tasks to process
  61327. */
  61328. remainingCount: number;
  61329. /**
  61330. * Defines the total number of tasks
  61331. */
  61332. totalCount: number;
  61333. /**
  61334. * Defines the task that was just processed
  61335. */
  61336. task: AbstractAssetTask;
  61337. }
  61338. /**
  61339. * Class used to share progress information about assets loading
  61340. */
  61341. export class AssetsProgressEvent implements IAssetsProgressEvent {
  61342. /**
  61343. * Defines the number of remaining tasks to process
  61344. */
  61345. remainingCount: number;
  61346. /**
  61347. * Defines the total number of tasks
  61348. */
  61349. totalCount: number;
  61350. /**
  61351. * Defines the task that was just processed
  61352. */
  61353. task: AbstractAssetTask;
  61354. /**
  61355. * Creates a AssetsProgressEvent
  61356. * @param remainingCount defines the number of remaining tasks to process
  61357. * @param totalCount defines the total number of tasks
  61358. * @param task defines the task that was just processed
  61359. */
  61360. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  61361. }
  61362. /**
  61363. * Define a task used by AssetsManager to load meshes
  61364. */
  61365. export class MeshAssetTask extends AbstractAssetTask {
  61366. /**
  61367. * Defines the name of the task
  61368. */
  61369. name: string;
  61370. /**
  61371. * Defines the list of mesh's names you want to load
  61372. */
  61373. meshesNames: any;
  61374. /**
  61375. * Defines the root url to use as a base to load your meshes and associated resources
  61376. */
  61377. rootUrl: string;
  61378. /**
  61379. * Defines the filename of the scene to load from
  61380. */
  61381. sceneFilename: string;
  61382. /**
  61383. * Gets the list of loaded meshes
  61384. */
  61385. loadedMeshes: Array<AbstractMesh>;
  61386. /**
  61387. * Gets the list of loaded particle systems
  61388. */
  61389. loadedParticleSystems: Array<IParticleSystem>;
  61390. /**
  61391. * Gets the list of loaded skeletons
  61392. */
  61393. loadedSkeletons: Array<Skeleton>;
  61394. /**
  61395. * Gets the list of loaded animation groups
  61396. */
  61397. loadedAnimationGroups: Array<AnimationGroup>;
  61398. /**
  61399. * Callback called when the task is successful
  61400. */
  61401. onSuccess: (task: MeshAssetTask) => void;
  61402. /**
  61403. * Callback called when the task is successful
  61404. */
  61405. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  61406. /**
  61407. * Creates a new MeshAssetTask
  61408. * @param name defines the name of the task
  61409. * @param meshesNames defines the list of mesh's names you want to load
  61410. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  61411. * @param sceneFilename defines the filename of the scene to load from
  61412. */
  61413. constructor(
  61414. /**
  61415. * Defines the name of the task
  61416. */
  61417. name: string,
  61418. /**
  61419. * Defines the list of mesh's names you want to load
  61420. */
  61421. meshesNames: any,
  61422. /**
  61423. * Defines the root url to use as a base to load your meshes and associated resources
  61424. */
  61425. rootUrl: string,
  61426. /**
  61427. * Defines the filename of the scene to load from
  61428. */
  61429. sceneFilename: string);
  61430. /**
  61431. * Execute the current task
  61432. * @param scene defines the scene where you want your assets to be loaded
  61433. * @param onSuccess is a callback called when the task is successfully executed
  61434. * @param onError is a callback called if an error occurs
  61435. */
  61436. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61437. }
  61438. /**
  61439. * Define a task used by AssetsManager to load text content
  61440. */
  61441. export class TextFileAssetTask extends AbstractAssetTask {
  61442. /**
  61443. * Defines the name of the task
  61444. */
  61445. name: string;
  61446. /**
  61447. * Defines the location of the file to load
  61448. */
  61449. url: string;
  61450. /**
  61451. * Gets the loaded text string
  61452. */
  61453. text: string;
  61454. /**
  61455. * Callback called when the task is successful
  61456. */
  61457. onSuccess: (task: TextFileAssetTask) => void;
  61458. /**
  61459. * Callback called when the task is successful
  61460. */
  61461. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  61462. /**
  61463. * Creates a new TextFileAssetTask object
  61464. * @param name defines the name of the task
  61465. * @param url defines the location of the file to load
  61466. */
  61467. constructor(
  61468. /**
  61469. * Defines the name of the task
  61470. */
  61471. name: string,
  61472. /**
  61473. * Defines the location of the file to load
  61474. */
  61475. url: string);
  61476. /**
  61477. * Execute the current task
  61478. * @param scene defines the scene where you want your assets to be loaded
  61479. * @param onSuccess is a callback called when the task is successfully executed
  61480. * @param onError is a callback called if an error occurs
  61481. */
  61482. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61483. }
  61484. /**
  61485. * Define a task used by AssetsManager to load binary data
  61486. */
  61487. export class BinaryFileAssetTask extends AbstractAssetTask {
  61488. /**
  61489. * Defines the name of the task
  61490. */
  61491. name: string;
  61492. /**
  61493. * Defines the location of the file to load
  61494. */
  61495. url: string;
  61496. /**
  61497. * Gets the lodaded data (as an array buffer)
  61498. */
  61499. data: ArrayBuffer;
  61500. /**
  61501. * Callback called when the task is successful
  61502. */
  61503. onSuccess: (task: BinaryFileAssetTask) => void;
  61504. /**
  61505. * Callback called when the task is successful
  61506. */
  61507. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  61508. /**
  61509. * Creates a new BinaryFileAssetTask object
  61510. * @param name defines the name of the new task
  61511. * @param url defines the location of the file to load
  61512. */
  61513. constructor(
  61514. /**
  61515. * Defines the name of the task
  61516. */
  61517. name: string,
  61518. /**
  61519. * Defines the location of the file to load
  61520. */
  61521. url: string);
  61522. /**
  61523. * Execute the current task
  61524. * @param scene defines the scene where you want your assets to be loaded
  61525. * @param onSuccess is a callback called when the task is successfully executed
  61526. * @param onError is a callback called if an error occurs
  61527. */
  61528. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61529. }
  61530. /**
  61531. * Define a task used by AssetsManager to load images
  61532. */
  61533. export class ImageAssetTask extends AbstractAssetTask {
  61534. /**
  61535. * Defines the name of the task
  61536. */
  61537. name: string;
  61538. /**
  61539. * Defines the location of the image to load
  61540. */
  61541. url: string;
  61542. /**
  61543. * Gets the loaded images
  61544. */
  61545. image: HTMLImageElement;
  61546. /**
  61547. * Callback called when the task is successful
  61548. */
  61549. onSuccess: (task: ImageAssetTask) => void;
  61550. /**
  61551. * Callback called when the task is successful
  61552. */
  61553. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  61554. /**
  61555. * Creates a new ImageAssetTask
  61556. * @param name defines the name of the task
  61557. * @param url defines the location of the image to load
  61558. */
  61559. constructor(
  61560. /**
  61561. * Defines the name of the task
  61562. */
  61563. name: string,
  61564. /**
  61565. * Defines the location of the image to load
  61566. */
  61567. url: string);
  61568. /**
  61569. * Execute the current task
  61570. * @param scene defines the scene where you want your assets to be loaded
  61571. * @param onSuccess is a callback called when the task is successfully executed
  61572. * @param onError is a callback called if an error occurs
  61573. */
  61574. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61575. }
  61576. /**
  61577. * Defines the interface used by texture loading tasks
  61578. */
  61579. export interface ITextureAssetTask<TEX extends BaseTexture> {
  61580. /**
  61581. * Gets the loaded texture
  61582. */
  61583. texture: TEX;
  61584. }
  61585. /**
  61586. * Define a task used by AssetsManager to load 2D textures
  61587. */
  61588. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  61589. /**
  61590. * Defines the name of the task
  61591. */
  61592. name: string;
  61593. /**
  61594. * Defines the location of the file to load
  61595. */
  61596. url: string;
  61597. /**
  61598. * Defines if mipmap should not be generated (default is false)
  61599. */
  61600. noMipmap?: boolean | undefined;
  61601. /**
  61602. * Defines if texture must be inverted on Y axis (default is false)
  61603. */
  61604. invertY?: boolean | undefined;
  61605. /**
  61606. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61607. */
  61608. samplingMode: number;
  61609. /**
  61610. * Gets the loaded texture
  61611. */
  61612. texture: Texture;
  61613. /**
  61614. * Callback called when the task is successful
  61615. */
  61616. onSuccess: (task: TextureAssetTask) => void;
  61617. /**
  61618. * Callback called when the task is successful
  61619. */
  61620. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  61621. /**
  61622. * Creates a new TextureAssetTask object
  61623. * @param name defines the name of the task
  61624. * @param url defines the location of the file to load
  61625. * @param noMipmap defines if mipmap should not be generated (default is false)
  61626. * @param invertY defines if texture must be inverted on Y axis (default is false)
  61627. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61628. */
  61629. constructor(
  61630. /**
  61631. * Defines the name of the task
  61632. */
  61633. name: string,
  61634. /**
  61635. * Defines the location of the file to load
  61636. */
  61637. url: string,
  61638. /**
  61639. * Defines if mipmap should not be generated (default is false)
  61640. */
  61641. noMipmap?: boolean | undefined,
  61642. /**
  61643. * Defines if texture must be inverted on Y axis (default is false)
  61644. */
  61645. invertY?: boolean | undefined,
  61646. /**
  61647. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61648. */
  61649. samplingMode?: number);
  61650. /**
  61651. * Execute the current task
  61652. * @param scene defines the scene where you want your assets to be loaded
  61653. * @param onSuccess is a callback called when the task is successfully executed
  61654. * @param onError is a callback called if an error occurs
  61655. */
  61656. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61657. }
  61658. /**
  61659. * Define a task used by AssetsManager to load cube textures
  61660. */
  61661. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  61662. /**
  61663. * Defines the name of the task
  61664. */
  61665. name: string;
  61666. /**
  61667. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61668. */
  61669. url: string;
  61670. /**
  61671. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61672. */
  61673. extensions?: string[] | undefined;
  61674. /**
  61675. * Defines if mipmaps should not be generated (default is false)
  61676. */
  61677. noMipmap?: boolean | undefined;
  61678. /**
  61679. * Defines the explicit list of files (undefined by default)
  61680. */
  61681. files?: string[] | undefined;
  61682. /**
  61683. * Gets the loaded texture
  61684. */
  61685. texture: CubeTexture;
  61686. /**
  61687. * Callback called when the task is successful
  61688. */
  61689. onSuccess: (task: CubeTextureAssetTask) => void;
  61690. /**
  61691. * Callback called when the task is successful
  61692. */
  61693. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  61694. /**
  61695. * Creates a new CubeTextureAssetTask
  61696. * @param name defines the name of the task
  61697. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61698. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61699. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61700. * @param files defines the explicit list of files (undefined by default)
  61701. */
  61702. constructor(
  61703. /**
  61704. * Defines the name of the task
  61705. */
  61706. name: string,
  61707. /**
  61708. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61709. */
  61710. url: string,
  61711. /**
  61712. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61713. */
  61714. extensions?: string[] | undefined,
  61715. /**
  61716. * Defines if mipmaps should not be generated (default is false)
  61717. */
  61718. noMipmap?: boolean | undefined,
  61719. /**
  61720. * Defines the explicit list of files (undefined by default)
  61721. */
  61722. files?: string[] | undefined);
  61723. /**
  61724. * Execute the current task
  61725. * @param scene defines the scene where you want your assets to be loaded
  61726. * @param onSuccess is a callback called when the task is successfully executed
  61727. * @param onError is a callback called if an error occurs
  61728. */
  61729. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61730. }
  61731. /**
  61732. * Define a task used by AssetsManager to load HDR cube textures
  61733. */
  61734. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  61735. /**
  61736. * Defines the name of the task
  61737. */
  61738. name: string;
  61739. /**
  61740. * Defines the location of the file to load
  61741. */
  61742. url: string;
  61743. /**
  61744. * Defines the desired size (the more it increases the longer the generation will be)
  61745. */
  61746. size: number;
  61747. /**
  61748. * Defines if mipmaps should not be generated (default is false)
  61749. */
  61750. noMipmap: boolean;
  61751. /**
  61752. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61753. */
  61754. generateHarmonics: boolean;
  61755. /**
  61756. * 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)
  61757. */
  61758. gammaSpace: boolean;
  61759. /**
  61760. * Internal Use Only
  61761. */
  61762. reserved: boolean;
  61763. /**
  61764. * Gets the loaded texture
  61765. */
  61766. texture: HDRCubeTexture;
  61767. /**
  61768. * Callback called when the task is successful
  61769. */
  61770. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  61771. /**
  61772. * Callback called when the task is successful
  61773. */
  61774. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  61775. /**
  61776. * Creates a new HDRCubeTextureAssetTask object
  61777. * @param name defines the name of the task
  61778. * @param url defines the location of the file to load
  61779. * @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.
  61780. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61781. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61782. * @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)
  61783. * @param reserved Internal use only
  61784. */
  61785. constructor(
  61786. /**
  61787. * Defines the name of the task
  61788. */
  61789. name: string,
  61790. /**
  61791. * Defines the location of the file to load
  61792. */
  61793. url: string,
  61794. /**
  61795. * Defines the desired size (the more it increases the longer the generation will be)
  61796. */
  61797. size: number,
  61798. /**
  61799. * Defines if mipmaps should not be generated (default is false)
  61800. */
  61801. noMipmap?: boolean,
  61802. /**
  61803. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61804. */
  61805. generateHarmonics?: boolean,
  61806. /**
  61807. * 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)
  61808. */
  61809. gammaSpace?: boolean,
  61810. /**
  61811. * Internal Use Only
  61812. */
  61813. reserved?: boolean);
  61814. /**
  61815. * Execute the current task
  61816. * @param scene defines the scene where you want your assets to be loaded
  61817. * @param onSuccess is a callback called when the task is successfully executed
  61818. * @param onError is a callback called if an error occurs
  61819. */
  61820. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61821. }
  61822. /**
  61823. * Define a task used by AssetsManager to load Equirectangular cube textures
  61824. */
  61825. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  61826. /**
  61827. * Defines the name of the task
  61828. */
  61829. name: string;
  61830. /**
  61831. * Defines the location of the file to load
  61832. */
  61833. url: string;
  61834. /**
  61835. * Defines the desired size (the more it increases the longer the generation will be)
  61836. */
  61837. size: number;
  61838. /**
  61839. * Defines if mipmaps should not be generated (default is false)
  61840. */
  61841. noMipmap: boolean;
  61842. /**
  61843. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61844. * but the standard material would require them in Gamma space) (default is true)
  61845. */
  61846. gammaSpace: boolean;
  61847. /**
  61848. * Gets the loaded texture
  61849. */
  61850. texture: EquiRectangularCubeTexture;
  61851. /**
  61852. * Callback called when the task is successful
  61853. */
  61854. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  61855. /**
  61856. * Callback called when the task is successful
  61857. */
  61858. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  61859. /**
  61860. * Creates a new EquiRectangularCubeTextureAssetTask object
  61861. * @param name defines the name of the task
  61862. * @param url defines the location of the file to load
  61863. * @param size defines the desired size (the more it increases the longer the generation will be)
  61864. * If the size is omitted this implies you are using a preprocessed cubemap.
  61865. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61866. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  61867. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  61868. * (default is true)
  61869. */
  61870. constructor(
  61871. /**
  61872. * Defines the name of the task
  61873. */
  61874. name: string,
  61875. /**
  61876. * Defines the location of the file to load
  61877. */
  61878. url: string,
  61879. /**
  61880. * Defines the desired size (the more it increases the longer the generation will be)
  61881. */
  61882. size: number,
  61883. /**
  61884. * Defines if mipmaps should not be generated (default is false)
  61885. */
  61886. noMipmap?: boolean,
  61887. /**
  61888. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61889. * but the standard material would require them in Gamma space) (default is true)
  61890. */
  61891. gammaSpace?: boolean);
  61892. /**
  61893. * Execute the current task
  61894. * @param scene defines the scene where you want your assets to be loaded
  61895. * @param onSuccess is a callback called when the task is successfully executed
  61896. * @param onError is a callback called if an error occurs
  61897. */
  61898. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61899. }
  61900. /**
  61901. * This class can be used to easily import assets into a scene
  61902. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  61903. */
  61904. export class AssetsManager {
  61905. private _scene;
  61906. private _isLoading;
  61907. protected _tasks: AbstractAssetTask[];
  61908. protected _waitingTasksCount: number;
  61909. protected _totalTasksCount: number;
  61910. /**
  61911. * Callback called when all tasks are processed
  61912. */
  61913. onFinish: (tasks: AbstractAssetTask[]) => void;
  61914. /**
  61915. * Callback called when a task is successful
  61916. */
  61917. onTaskSuccess: (task: AbstractAssetTask) => void;
  61918. /**
  61919. * Callback called when a task had an error
  61920. */
  61921. onTaskError: (task: AbstractAssetTask) => void;
  61922. /**
  61923. * Callback called when a task is done (whatever the result is)
  61924. */
  61925. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  61926. /**
  61927. * Observable called when all tasks are processed
  61928. */
  61929. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  61930. /**
  61931. * Observable called when a task had an error
  61932. */
  61933. onTaskErrorObservable: Observable<AbstractAssetTask>;
  61934. /**
  61935. * Observable called when all tasks were executed
  61936. */
  61937. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  61938. /**
  61939. * Observable called when a task is done (whatever the result is)
  61940. */
  61941. onProgressObservable: Observable<IAssetsProgressEvent>;
  61942. /**
  61943. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  61944. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  61945. */
  61946. useDefaultLoadingScreen: boolean;
  61947. /**
  61948. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  61949. * when all assets have been downloaded.
  61950. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  61951. */
  61952. autoHideLoadingUI: boolean;
  61953. /**
  61954. * Creates a new AssetsManager
  61955. * @param scene defines the scene to work on
  61956. */
  61957. constructor(scene: Scene);
  61958. /**
  61959. * Add a MeshAssetTask to the list of active tasks
  61960. * @param taskName defines the name of the new task
  61961. * @param meshesNames defines the name of meshes to load
  61962. * @param rootUrl defines the root url to use to locate files
  61963. * @param sceneFilename defines the filename of the scene file
  61964. * @returns a new MeshAssetTask object
  61965. */
  61966. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  61967. /**
  61968. * Add a TextFileAssetTask to the list of active tasks
  61969. * @param taskName defines the name of the new task
  61970. * @param url defines the url of the file to load
  61971. * @returns a new TextFileAssetTask object
  61972. */
  61973. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  61974. /**
  61975. * Add a BinaryFileAssetTask to the list of active tasks
  61976. * @param taskName defines the name of the new task
  61977. * @param url defines the url of the file to load
  61978. * @returns a new BinaryFileAssetTask object
  61979. */
  61980. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  61981. /**
  61982. * Add a ImageAssetTask to the list of active tasks
  61983. * @param taskName defines the name of the new task
  61984. * @param url defines the url of the file to load
  61985. * @returns a new ImageAssetTask object
  61986. */
  61987. addImageTask(taskName: string, url: string): ImageAssetTask;
  61988. /**
  61989. * Add a TextureAssetTask to the list of active tasks
  61990. * @param taskName defines the name of the new task
  61991. * @param url defines the url of the file to load
  61992. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61993. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  61994. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61995. * @returns a new TextureAssetTask object
  61996. */
  61997. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  61998. /**
  61999. * Add a CubeTextureAssetTask to the list of active tasks
  62000. * @param taskName defines the name of the new task
  62001. * @param url defines the url of the file to load
  62002. * @param extensions defines the extension to use to load the cube map (can be null)
  62003. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62004. * @param files defines the list of files to load (can be null)
  62005. * @returns a new CubeTextureAssetTask object
  62006. */
  62007. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  62008. /**
  62009. *
  62010. * Add a HDRCubeTextureAssetTask to the list of active tasks
  62011. * @param taskName defines the name of the new task
  62012. * @param url defines the url of the file to load
  62013. * @param size defines the size you want for the cubemap (can be null)
  62014. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62015. * @param generateHarmonics defines if you want to automatically generate (true by default)
  62016. * @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)
  62017. * @param reserved Internal use only
  62018. * @returns a new HDRCubeTextureAssetTask object
  62019. */
  62020. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  62021. /**
  62022. *
  62023. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  62024. * @param taskName defines the name of the new task
  62025. * @param url defines the url of the file to load
  62026. * @param size defines the size you want for the cubemap (can be null)
  62027. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62028. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62029. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62030. * @returns a new EquiRectangularCubeTextureAssetTask object
  62031. */
  62032. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  62033. /**
  62034. * Remove a task from the assets manager.
  62035. * @param task the task to remove
  62036. */
  62037. removeTask(task: AbstractAssetTask): void;
  62038. private _decreaseWaitingTasksCount;
  62039. private _runTask;
  62040. /**
  62041. * Reset the AssetsManager and remove all tasks
  62042. * @return the current instance of the AssetsManager
  62043. */
  62044. reset(): AssetsManager;
  62045. /**
  62046. * Start the loading process
  62047. * @return the current instance of the AssetsManager
  62048. */
  62049. load(): AssetsManager;
  62050. /**
  62051. * Start the loading process as an async operation
  62052. * @return a promise returning the list of failed tasks
  62053. */
  62054. loadAsync(): Promise<void>;
  62055. }
  62056. }
  62057. declare module BABYLON {
  62058. /**
  62059. * Wrapper class for promise with external resolve and reject.
  62060. */
  62061. export class Deferred<T> {
  62062. /**
  62063. * The promise associated with this deferred object.
  62064. */
  62065. readonly promise: Promise<T>;
  62066. private _resolve;
  62067. private _reject;
  62068. /**
  62069. * The resolve method of the promise associated with this deferred object.
  62070. */
  62071. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  62072. /**
  62073. * The reject method of the promise associated with this deferred object.
  62074. */
  62075. readonly reject: (reason?: any) => void;
  62076. /**
  62077. * Constructor for this deferred object.
  62078. */
  62079. constructor();
  62080. }
  62081. }
  62082. declare module BABYLON {
  62083. /**
  62084. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  62085. */
  62086. export class MeshExploder {
  62087. private _centerMesh;
  62088. private _meshes;
  62089. private _meshesOrigins;
  62090. private _toCenterVectors;
  62091. private _scaledDirection;
  62092. private _newPosition;
  62093. private _centerPosition;
  62094. /**
  62095. * Explodes meshes from a center mesh.
  62096. * @param meshes The meshes to explode.
  62097. * @param centerMesh The mesh to be center of explosion.
  62098. */
  62099. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  62100. private _setCenterMesh;
  62101. /**
  62102. * Get class name
  62103. * @returns "MeshExploder"
  62104. */
  62105. getClassName(): string;
  62106. /**
  62107. * "Exploded meshes"
  62108. * @returns Array of meshes with the centerMesh at index 0.
  62109. */
  62110. getMeshes(): Array<Mesh>;
  62111. /**
  62112. * Explodes meshes giving a specific direction
  62113. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  62114. */
  62115. explode(direction?: number): void;
  62116. }
  62117. }
  62118. declare module BABYLON {
  62119. /**
  62120. * Class used to help managing file picking and drag'n'drop
  62121. */
  62122. export class FilesInput {
  62123. /**
  62124. * List of files ready to be loaded
  62125. */
  62126. static readonly FilesToLoad: {
  62127. [key: string]: File;
  62128. };
  62129. /**
  62130. * Callback called when a file is processed
  62131. */
  62132. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  62133. private _engine;
  62134. private _currentScene;
  62135. private _sceneLoadedCallback;
  62136. private _progressCallback;
  62137. private _additionalRenderLoopLogicCallback;
  62138. private _textureLoadingCallback;
  62139. private _startingProcessingFilesCallback;
  62140. private _onReloadCallback;
  62141. private _errorCallback;
  62142. private _elementToMonitor;
  62143. private _sceneFileToLoad;
  62144. private _filesToLoad;
  62145. /**
  62146. * Creates a new FilesInput
  62147. * @param engine defines the rendering engine
  62148. * @param scene defines the hosting scene
  62149. * @param sceneLoadedCallback callback called when scene is loaded
  62150. * @param progressCallback callback called to track progress
  62151. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  62152. * @param textureLoadingCallback callback called when a texture is loading
  62153. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  62154. * @param onReloadCallback callback called when a reload is requested
  62155. * @param errorCallback callback call if an error occurs
  62156. */
  62157. 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);
  62158. private _dragEnterHandler;
  62159. private _dragOverHandler;
  62160. private _dropHandler;
  62161. /**
  62162. * Calls this function to listen to drag'n'drop events on a specific DOM element
  62163. * @param elementToMonitor defines the DOM element to track
  62164. */
  62165. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  62166. /**
  62167. * Release all associated resources
  62168. */
  62169. dispose(): void;
  62170. private renderFunction;
  62171. private drag;
  62172. private drop;
  62173. private _traverseFolder;
  62174. private _processFiles;
  62175. /**
  62176. * Load files from a drop event
  62177. * @param event defines the drop event to use as source
  62178. */
  62179. loadFiles(event: any): void;
  62180. private _processReload;
  62181. /**
  62182. * Reload the current scene from the loaded files
  62183. */
  62184. reload(): void;
  62185. }
  62186. }
  62187. declare module BABYLON {
  62188. /**
  62189. * Defines the root class used to create scene optimization to use with SceneOptimizer
  62190. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62191. */
  62192. export class SceneOptimization {
  62193. /**
  62194. * Defines the priority of this optimization (0 by default which means first in the list)
  62195. */
  62196. priority: number;
  62197. /**
  62198. * Gets a string describing the action executed by the current optimization
  62199. * @returns description string
  62200. */
  62201. getDescription(): string;
  62202. /**
  62203. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62204. * @param scene defines the current scene where to apply this optimization
  62205. * @param optimizer defines the current optimizer
  62206. * @returns true if everything that can be done was applied
  62207. */
  62208. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62209. /**
  62210. * Creates the SceneOptimization object
  62211. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62212. * @param desc defines the description associated with the optimization
  62213. */
  62214. constructor(
  62215. /**
  62216. * Defines the priority of this optimization (0 by default which means first in the list)
  62217. */
  62218. priority?: number);
  62219. }
  62220. /**
  62221. * Defines an optimization used to reduce the size of render target textures
  62222. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62223. */
  62224. export class TextureOptimization extends SceneOptimization {
  62225. /**
  62226. * Defines the priority of this optimization (0 by default which means first in the list)
  62227. */
  62228. priority: number;
  62229. /**
  62230. * 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
  62231. */
  62232. maximumSize: number;
  62233. /**
  62234. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  62235. */
  62236. step: number;
  62237. /**
  62238. * Gets a string describing the action executed by the current optimization
  62239. * @returns description string
  62240. */
  62241. getDescription(): string;
  62242. /**
  62243. * Creates the TextureOptimization object
  62244. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62245. * @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
  62246. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  62247. */
  62248. constructor(
  62249. /**
  62250. * Defines the priority of this optimization (0 by default which means first in the list)
  62251. */
  62252. priority?: number,
  62253. /**
  62254. * 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
  62255. */
  62256. maximumSize?: number,
  62257. /**
  62258. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  62259. */
  62260. step?: number);
  62261. /**
  62262. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62263. * @param scene defines the current scene where to apply this optimization
  62264. * @param optimizer defines the current optimizer
  62265. * @returns true if everything that can be done was applied
  62266. */
  62267. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62268. }
  62269. /**
  62270. * Defines an optimization used to increase or decrease the rendering resolution
  62271. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62272. */
  62273. export class HardwareScalingOptimization extends SceneOptimization {
  62274. /**
  62275. * Defines the priority of this optimization (0 by default which means first in the list)
  62276. */
  62277. priority: number;
  62278. /**
  62279. * Defines the maximum scale to use (2 by default)
  62280. */
  62281. maximumScale: number;
  62282. /**
  62283. * Defines the step to use between two passes (0.5 by default)
  62284. */
  62285. step: number;
  62286. private _currentScale;
  62287. private _directionOffset;
  62288. /**
  62289. * Gets a string describing the action executed by the current optimization
  62290. * @return description string
  62291. */
  62292. getDescription(): string;
  62293. /**
  62294. * Creates the HardwareScalingOptimization object
  62295. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62296. * @param maximumScale defines the maximum scale to use (2 by default)
  62297. * @param step defines the step to use between two passes (0.5 by default)
  62298. */
  62299. constructor(
  62300. /**
  62301. * Defines the priority of this optimization (0 by default which means first in the list)
  62302. */
  62303. priority?: number,
  62304. /**
  62305. * Defines the maximum scale to use (2 by default)
  62306. */
  62307. maximumScale?: number,
  62308. /**
  62309. * Defines the step to use between two passes (0.5 by default)
  62310. */
  62311. step?: number);
  62312. /**
  62313. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62314. * @param scene defines the current scene where to apply this optimization
  62315. * @param optimizer defines the current optimizer
  62316. * @returns true if everything that can be done was applied
  62317. */
  62318. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62319. }
  62320. /**
  62321. * Defines an optimization used to remove shadows
  62322. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62323. */
  62324. export class ShadowsOptimization extends SceneOptimization {
  62325. /**
  62326. * Gets a string describing the action executed by the current optimization
  62327. * @return description string
  62328. */
  62329. getDescription(): string;
  62330. /**
  62331. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62332. * @param scene defines the current scene where to apply this optimization
  62333. * @param optimizer defines the current optimizer
  62334. * @returns true if everything that can be done was applied
  62335. */
  62336. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62337. }
  62338. /**
  62339. * Defines an optimization used to turn post-processes off
  62340. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62341. */
  62342. export class PostProcessesOptimization extends SceneOptimization {
  62343. /**
  62344. * Gets a string describing the action executed by the current optimization
  62345. * @return description string
  62346. */
  62347. getDescription(): string;
  62348. /**
  62349. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62350. * @param scene defines the current scene where to apply this optimization
  62351. * @param optimizer defines the current optimizer
  62352. * @returns true if everything that can be done was applied
  62353. */
  62354. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62355. }
  62356. /**
  62357. * Defines an optimization used to turn lens flares off
  62358. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62359. */
  62360. export class LensFlaresOptimization extends SceneOptimization {
  62361. /**
  62362. * Gets a string describing the action executed by the current optimization
  62363. * @return description string
  62364. */
  62365. getDescription(): string;
  62366. /**
  62367. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62368. * @param scene defines the current scene where to apply this optimization
  62369. * @param optimizer defines the current optimizer
  62370. * @returns true if everything that can be done was applied
  62371. */
  62372. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62373. }
  62374. /**
  62375. * Defines an optimization based on user defined callback.
  62376. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62377. */
  62378. export class CustomOptimization extends SceneOptimization {
  62379. /**
  62380. * Callback called to apply the custom optimization.
  62381. */
  62382. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  62383. /**
  62384. * Callback called to get custom description
  62385. */
  62386. onGetDescription: () => string;
  62387. /**
  62388. * Gets a string describing the action executed by the current optimization
  62389. * @returns description string
  62390. */
  62391. getDescription(): string;
  62392. /**
  62393. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62394. * @param scene defines the current scene where to apply this optimization
  62395. * @param optimizer defines the current optimizer
  62396. * @returns true if everything that can be done was applied
  62397. */
  62398. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62399. }
  62400. /**
  62401. * Defines an optimization used to turn particles off
  62402. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62403. */
  62404. export class ParticlesOptimization extends SceneOptimization {
  62405. /**
  62406. * Gets a string describing the action executed by the current optimization
  62407. * @return description string
  62408. */
  62409. getDescription(): string;
  62410. /**
  62411. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62412. * @param scene defines the current scene where to apply this optimization
  62413. * @param optimizer defines the current optimizer
  62414. * @returns true if everything that can be done was applied
  62415. */
  62416. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62417. }
  62418. /**
  62419. * Defines an optimization used to turn render targets off
  62420. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62421. */
  62422. export class RenderTargetsOptimization extends SceneOptimization {
  62423. /**
  62424. * Gets a string describing the action executed by the current optimization
  62425. * @return description string
  62426. */
  62427. getDescription(): string;
  62428. /**
  62429. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62430. * @param scene defines the current scene where to apply this optimization
  62431. * @param optimizer defines the current optimizer
  62432. * @returns true if everything that can be done was applied
  62433. */
  62434. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62435. }
  62436. /**
  62437. * Defines an optimization used to merge meshes with compatible materials
  62438. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62439. */
  62440. export class MergeMeshesOptimization extends SceneOptimization {
  62441. private static _UpdateSelectionTree;
  62442. /**
  62443. * Gets or sets a boolean which defines if optimization octree has to be updated
  62444. */
  62445. /**
  62446. * Gets or sets a boolean which defines if optimization octree has to be updated
  62447. */
  62448. static UpdateSelectionTree: boolean;
  62449. /**
  62450. * Gets a string describing the action executed by the current optimization
  62451. * @return description string
  62452. */
  62453. getDescription(): string;
  62454. private _canBeMerged;
  62455. /**
  62456. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62457. * @param scene defines the current scene where to apply this optimization
  62458. * @param optimizer defines the current optimizer
  62459. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  62460. * @returns true if everything that can be done was applied
  62461. */
  62462. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  62463. }
  62464. /**
  62465. * Defines a list of options used by SceneOptimizer
  62466. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62467. */
  62468. export class SceneOptimizerOptions {
  62469. /**
  62470. * Defines the target frame rate to reach (60 by default)
  62471. */
  62472. targetFrameRate: number;
  62473. /**
  62474. * Defines the interval between two checkes (2000ms by default)
  62475. */
  62476. trackerDuration: number;
  62477. /**
  62478. * Gets the list of optimizations to apply
  62479. */
  62480. optimizations: SceneOptimization[];
  62481. /**
  62482. * Creates a new list of options used by SceneOptimizer
  62483. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  62484. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  62485. */
  62486. constructor(
  62487. /**
  62488. * Defines the target frame rate to reach (60 by default)
  62489. */
  62490. targetFrameRate?: number,
  62491. /**
  62492. * Defines the interval between two checkes (2000ms by default)
  62493. */
  62494. trackerDuration?: number);
  62495. /**
  62496. * Add a new optimization
  62497. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  62498. * @returns the current SceneOptimizerOptions
  62499. */
  62500. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  62501. /**
  62502. * Add a new custom optimization
  62503. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  62504. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  62505. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62506. * @returns the current SceneOptimizerOptions
  62507. */
  62508. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  62509. /**
  62510. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  62511. * @param targetFrameRate defines the target frame rate (60 by default)
  62512. * @returns a SceneOptimizerOptions object
  62513. */
  62514. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62515. /**
  62516. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  62517. * @param targetFrameRate defines the target frame rate (60 by default)
  62518. * @returns a SceneOptimizerOptions object
  62519. */
  62520. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62521. /**
  62522. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  62523. * @param targetFrameRate defines the target frame rate (60 by default)
  62524. * @returns a SceneOptimizerOptions object
  62525. */
  62526. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62527. }
  62528. /**
  62529. * Class used to run optimizations in order to reach a target frame rate
  62530. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62531. */
  62532. export class SceneOptimizer implements IDisposable {
  62533. private _isRunning;
  62534. private _options;
  62535. private _scene;
  62536. private _currentPriorityLevel;
  62537. private _targetFrameRate;
  62538. private _trackerDuration;
  62539. private _currentFrameRate;
  62540. private _sceneDisposeObserver;
  62541. private _improvementMode;
  62542. /**
  62543. * Defines an observable called when the optimizer reaches the target frame rate
  62544. */
  62545. onSuccessObservable: Observable<SceneOptimizer>;
  62546. /**
  62547. * Defines an observable called when the optimizer enables an optimization
  62548. */
  62549. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  62550. /**
  62551. * Defines an observable called when the optimizer is not able to reach the target frame rate
  62552. */
  62553. onFailureObservable: Observable<SceneOptimizer>;
  62554. /**
  62555. * Gets a boolean indicating if the optimizer is in improvement mode
  62556. */
  62557. readonly isInImprovementMode: boolean;
  62558. /**
  62559. * Gets the current priority level (0 at start)
  62560. */
  62561. readonly currentPriorityLevel: number;
  62562. /**
  62563. * Gets the current frame rate checked by the SceneOptimizer
  62564. */
  62565. readonly currentFrameRate: number;
  62566. /**
  62567. * Gets or sets the current target frame rate (60 by default)
  62568. */
  62569. /**
  62570. * Gets or sets the current target frame rate (60 by default)
  62571. */
  62572. targetFrameRate: number;
  62573. /**
  62574. * Gets or sets the current interval between two checks (every 2000ms by default)
  62575. */
  62576. /**
  62577. * Gets or sets the current interval between two checks (every 2000ms by default)
  62578. */
  62579. trackerDuration: number;
  62580. /**
  62581. * Gets the list of active optimizations
  62582. */
  62583. readonly optimizations: SceneOptimization[];
  62584. /**
  62585. * Creates a new SceneOptimizer
  62586. * @param scene defines the scene to work on
  62587. * @param options defines the options to use with the SceneOptimizer
  62588. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  62589. * @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)
  62590. */
  62591. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  62592. /**
  62593. * Stops the current optimizer
  62594. */
  62595. stop(): void;
  62596. /**
  62597. * Reset the optimizer to initial step (current priority level = 0)
  62598. */
  62599. reset(): void;
  62600. /**
  62601. * Start the optimizer. By default it will try to reach a specific framerate
  62602. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  62603. */
  62604. start(): void;
  62605. private _checkCurrentState;
  62606. /**
  62607. * Release all resources
  62608. */
  62609. dispose(): void;
  62610. /**
  62611. * Helper function to create a SceneOptimizer with one single line of code
  62612. * @param scene defines the scene to work on
  62613. * @param options defines the options to use with the SceneOptimizer
  62614. * @param onSuccess defines a callback to call on success
  62615. * @param onFailure defines a callback to call on failure
  62616. * @returns the new SceneOptimizer object
  62617. */
  62618. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  62619. }
  62620. }
  62621. declare module BABYLON {
  62622. /**
  62623. * Class used to serialize a scene into a string
  62624. */
  62625. export class SceneSerializer {
  62626. /**
  62627. * Clear cache used by a previous serialization
  62628. */
  62629. static ClearCache(): void;
  62630. /**
  62631. * Serialize a scene into a JSON compatible object
  62632. * @param scene defines the scene to serialize
  62633. * @returns a JSON compatible object
  62634. */
  62635. static Serialize(scene: Scene): any;
  62636. /**
  62637. * Serialize a mesh into a JSON compatible object
  62638. * @param toSerialize defines the mesh to serialize
  62639. * @param withParents defines if parents must be serialized as well
  62640. * @param withChildren defines if children must be serialized as well
  62641. * @returns a JSON compatible object
  62642. */
  62643. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  62644. }
  62645. }
  62646. declare module BABYLON {
  62647. /**
  62648. * Class used to host texture specific utilities
  62649. */
  62650. export class TextureTools {
  62651. /**
  62652. * Uses the GPU to create a copy texture rescaled at a given size
  62653. * @param texture Texture to copy from
  62654. * @param width defines the desired width
  62655. * @param height defines the desired height
  62656. * @param useBilinearMode defines if bilinear mode has to be used
  62657. * @return the generated texture
  62658. */
  62659. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  62660. }
  62661. }
  62662. declare module BABYLON {
  62663. /**
  62664. * This represents the different options available for the video capture.
  62665. */
  62666. export interface VideoRecorderOptions {
  62667. /** Defines the mime type of the video. */
  62668. mimeType: string;
  62669. /** Defines the FPS the video should be recorded at. */
  62670. fps: number;
  62671. /** Defines the chunk size for the recording data. */
  62672. recordChunckSize: number;
  62673. /** The audio tracks to attach to the recording. */
  62674. audioTracks?: MediaStreamTrack[];
  62675. }
  62676. /**
  62677. * This can help with recording videos from BabylonJS.
  62678. * This is based on the available WebRTC functionalities of the browser.
  62679. *
  62680. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  62681. */
  62682. export class VideoRecorder {
  62683. private static readonly _defaultOptions;
  62684. /**
  62685. * Returns whether or not the VideoRecorder is available in your browser.
  62686. * @param engine Defines the Babylon Engine.
  62687. * @returns true if supported otherwise false.
  62688. */
  62689. static IsSupported(engine: Engine): boolean;
  62690. private readonly _options;
  62691. private _canvas;
  62692. private _mediaRecorder;
  62693. private _recordedChunks;
  62694. private _fileName;
  62695. private _resolve;
  62696. private _reject;
  62697. /**
  62698. * True when a recording is already in progress.
  62699. */
  62700. readonly isRecording: boolean;
  62701. /**
  62702. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  62703. * @param engine Defines the BabylonJS Engine you wish to record.
  62704. * @param options Defines options that can be used to customize the capture.
  62705. */
  62706. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  62707. /**
  62708. * Stops the current recording before the default capture timeout passed in the startRecording function.
  62709. */
  62710. stopRecording(): void;
  62711. /**
  62712. * Starts recording the canvas for a max duration specified in parameters.
  62713. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  62714. * If null no automatic download will start and you can rely on the promise to get the data back.
  62715. * @param maxDuration Defines the maximum recording time in seconds.
  62716. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  62717. * @return A promise callback at the end of the recording with the video data in Blob.
  62718. */
  62719. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  62720. /**
  62721. * Releases internal resources used during the recording.
  62722. */
  62723. dispose(): void;
  62724. private _handleDataAvailable;
  62725. private _handleError;
  62726. private _handleStop;
  62727. }
  62728. }
  62729. declare module BABYLON {
  62730. /**
  62731. * Class containing a set of static utilities functions for screenshots
  62732. */
  62733. export class ScreenshotTools {
  62734. /**
  62735. * Captures a screenshot of the current rendering
  62736. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62737. * @param engine defines the rendering engine
  62738. * @param camera defines the source camera
  62739. * @param size This parameter can be set to a single number or to an object with the
  62740. * following (optional) properties: precision, width, height. If a single number is passed,
  62741. * it will be used for both width and height. If an object is passed, the screenshot size
  62742. * will be derived from the parameters. The precision property is a multiplier allowing
  62743. * rendering at a higher or lower resolution
  62744. * @param successCallback defines the callback receives a single parameter which contains the
  62745. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62746. * src parameter of an <img> to display it
  62747. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  62748. * Check your browser for supported MIME types
  62749. */
  62750. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  62751. /**
  62752. * Captures a screenshot of the current rendering
  62753. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62754. * @param engine defines the rendering engine
  62755. * @param camera defines the source camera
  62756. * @param size This parameter can be set to a single number or to an object with the
  62757. * following (optional) properties: precision, width, height. If a single number is passed,
  62758. * it will be used for both width and height. If an object is passed, the screenshot size
  62759. * will be derived from the parameters. The precision property is a multiplier allowing
  62760. * rendering at a higher or lower resolution
  62761. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  62762. * Check your browser for supported MIME types
  62763. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  62764. * to the src parameter of an <img> to display it
  62765. */
  62766. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  62767. /**
  62768. * Generates an image screenshot from the specified camera.
  62769. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62770. * @param engine The engine to use for rendering
  62771. * @param camera The camera to use for rendering
  62772. * @param size This parameter can be set to a single number or to an object with the
  62773. * following (optional) properties: precision, width, height. If a single number is passed,
  62774. * it will be used for both width and height. If an object is passed, the screenshot size
  62775. * will be derived from the parameters. The precision property is a multiplier allowing
  62776. * rendering at a higher or lower resolution
  62777. * @param successCallback The callback receives a single parameter which contains the
  62778. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62779. * src parameter of an <img> to display it
  62780. * @param mimeType The MIME type of the screenshot image (default: image/png).
  62781. * Check your browser for supported MIME types
  62782. * @param samples Texture samples (default: 1)
  62783. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  62784. * @param fileName A name for for the downloaded file.
  62785. */
  62786. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  62787. /**
  62788. * Generates an image screenshot from the specified camera.
  62789. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62790. * @param engine The engine to use for rendering
  62791. * @param camera The camera to use for rendering
  62792. * @param size This parameter can be set to a single number or to an object with the
  62793. * following (optional) properties: precision, width, height. If a single number is passed,
  62794. * it will be used for both width and height. If an object is passed, the screenshot size
  62795. * will be derived from the parameters. The precision property is a multiplier allowing
  62796. * rendering at a higher or lower resolution
  62797. * @param mimeType The MIME type of the screenshot image (default: image/png).
  62798. * Check your browser for supported MIME types
  62799. * @param samples Texture samples (default: 1)
  62800. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  62801. * @param fileName A name for for the downloaded file.
  62802. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  62803. * to the src parameter of an <img> to display it
  62804. */
  62805. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  62806. /**
  62807. * Gets height and width for screenshot size
  62808. * @private
  62809. */
  62810. private static _getScreenshotSize;
  62811. }
  62812. }
  62813. declare module BABYLON {
  62814. /**
  62815. * A cursor which tracks a point on a path
  62816. */
  62817. export class PathCursor {
  62818. private path;
  62819. /**
  62820. * Stores path cursor callbacks for when an onchange event is triggered
  62821. */
  62822. private _onchange;
  62823. /**
  62824. * The value of the path cursor
  62825. */
  62826. value: number;
  62827. /**
  62828. * The animation array of the path cursor
  62829. */
  62830. animations: Animation[];
  62831. /**
  62832. * Initializes the path cursor
  62833. * @param path The path to track
  62834. */
  62835. constructor(path: Path2);
  62836. /**
  62837. * Gets the cursor point on the path
  62838. * @returns A point on the path cursor at the cursor location
  62839. */
  62840. getPoint(): Vector3;
  62841. /**
  62842. * Moves the cursor ahead by the step amount
  62843. * @param step The amount to move the cursor forward
  62844. * @returns This path cursor
  62845. */
  62846. moveAhead(step?: number): PathCursor;
  62847. /**
  62848. * Moves the cursor behind by the step amount
  62849. * @param step The amount to move the cursor back
  62850. * @returns This path cursor
  62851. */
  62852. moveBack(step?: number): PathCursor;
  62853. /**
  62854. * Moves the cursor by the step amount
  62855. * If the step amount is greater than one, an exception is thrown
  62856. * @param step The amount to move the cursor
  62857. * @returns This path cursor
  62858. */
  62859. move(step: number): PathCursor;
  62860. /**
  62861. * Ensures that the value is limited between zero and one
  62862. * @returns This path cursor
  62863. */
  62864. private ensureLimits;
  62865. /**
  62866. * Runs onchange callbacks on change (used by the animation engine)
  62867. * @returns This path cursor
  62868. */
  62869. private raiseOnChange;
  62870. /**
  62871. * Executes a function on change
  62872. * @param f A path cursor onchange callback
  62873. * @returns This path cursor
  62874. */
  62875. onchange(f: (cursor: PathCursor) => void): PathCursor;
  62876. }
  62877. }
  62878. declare module BABYLON {
  62879. /** @hidden */
  62880. export var blurPixelShader: {
  62881. name: string;
  62882. shader: string;
  62883. };
  62884. }
  62885. declare module BABYLON {
  62886. /** @hidden */
  62887. export var pointCloudVertexDeclaration: {
  62888. name: string;
  62889. shader: string;
  62890. };
  62891. }
  62892. // Mixins
  62893. interface Window {
  62894. mozIndexedDB: IDBFactory;
  62895. webkitIndexedDB: IDBFactory;
  62896. msIndexedDB: IDBFactory;
  62897. webkitURL: typeof URL;
  62898. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  62899. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  62900. WebGLRenderingContext: WebGLRenderingContext;
  62901. MSGesture: MSGesture;
  62902. CANNON: any;
  62903. AudioContext: AudioContext;
  62904. webkitAudioContext: AudioContext;
  62905. PointerEvent: any;
  62906. Math: Math;
  62907. Uint8Array: Uint8ArrayConstructor;
  62908. Float32Array: Float32ArrayConstructor;
  62909. mozURL: typeof URL;
  62910. msURL: typeof URL;
  62911. VRFrameData: any; // WebVR, from specs 1.1
  62912. DracoDecoderModule: any;
  62913. setImmediate(handler: (...args: any[]) => void): number;
  62914. }
  62915. interface HTMLCanvasElement {
  62916. requestPointerLock(): void;
  62917. msRequestPointerLock?(): void;
  62918. mozRequestPointerLock?(): void;
  62919. webkitRequestPointerLock?(): void;
  62920. /** Track wether a record is in progress */
  62921. isRecording: boolean;
  62922. /** Capture Stream method defined by some browsers */
  62923. captureStream(fps?: number): MediaStream;
  62924. }
  62925. interface CanvasRenderingContext2D {
  62926. msImageSmoothingEnabled: boolean;
  62927. }
  62928. interface MouseEvent {
  62929. mozMovementX: number;
  62930. mozMovementY: number;
  62931. webkitMovementX: number;
  62932. webkitMovementY: number;
  62933. msMovementX: number;
  62934. msMovementY: number;
  62935. }
  62936. interface Navigator {
  62937. mozGetVRDevices: (any: any) => any;
  62938. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62939. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62940. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62941. webkitGetGamepads(): Gamepad[];
  62942. msGetGamepads(): Gamepad[];
  62943. webkitGamepads(): Gamepad[];
  62944. }
  62945. interface HTMLVideoElement {
  62946. mozSrcObject: any;
  62947. }
  62948. interface Math {
  62949. fround(x: number): number;
  62950. imul(a: number, b: number): number;
  62951. }
  62952. interface WebGLRenderingContext {
  62953. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  62954. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  62955. vertexAttribDivisor(index: number, divisor: number): void;
  62956. createVertexArray(): any;
  62957. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  62958. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  62959. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  62960. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  62961. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  62962. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  62963. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  62964. // Queries
  62965. createQuery(): WebGLQuery;
  62966. deleteQuery(query: WebGLQuery): void;
  62967. beginQuery(target: number, query: WebGLQuery): void;
  62968. endQuery(target: number): void;
  62969. getQueryParameter(query: WebGLQuery, pname: number): any;
  62970. getQuery(target: number, pname: number): any;
  62971. MAX_SAMPLES: number;
  62972. RGBA8: number;
  62973. READ_FRAMEBUFFER: number;
  62974. DRAW_FRAMEBUFFER: number;
  62975. UNIFORM_BUFFER: number;
  62976. HALF_FLOAT_OES: number;
  62977. RGBA16F: number;
  62978. RGBA32F: number;
  62979. R32F: number;
  62980. RG32F: number;
  62981. RGB32F: number;
  62982. R16F: number;
  62983. RG16F: number;
  62984. RGB16F: number;
  62985. RED: number;
  62986. RG: number;
  62987. R8: number;
  62988. RG8: number;
  62989. UNSIGNED_INT_24_8: number;
  62990. DEPTH24_STENCIL8: number;
  62991. MIN: number;
  62992. MAX: number;
  62993. /* Multiple Render Targets */
  62994. drawBuffers(buffers: number[]): void;
  62995. readBuffer(src: number): void;
  62996. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  62997. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  62998. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  62999. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  63000. // Occlusion Query
  63001. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  63002. ANY_SAMPLES_PASSED: number;
  63003. QUERY_RESULT_AVAILABLE: number;
  63004. QUERY_RESULT: number;
  63005. }
  63006. interface WebGLProgram { private __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  63007. }
  63008. interface EXT_disjoint_timer_query {
  63009. QUERY_COUNTER_BITS_EXT: number;
  63010. TIME_ELAPSED_EXT: number;
  63011. TIMESTAMP_EXT: number;
  63012. GPU_DISJOINT_EXT: number;
  63013. QUERY_RESULT_EXT: number;
  63014. QUERY_RESULT_AVAILABLE_EXT: number;
  63015. queryCounterEXT(query: WebGLQuery, target: number): void;
  63016. createQueryEXT(): WebGLQuery;
  63017. beginQueryEXT(target: number, query: WebGLQuery): void;
  63018. endQueryEXT(target: number): void;
  63019. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  63020. deleteQueryEXT(query: WebGLQuery): void;
  63021. }
  63022. interface WebGLUniformLocation { private _currentState: any;
  63023. }
  63024. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  63025. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  63026. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  63027. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  63028. interface WebGLRenderingContext {
  63029. readonly RASTERIZER_DISCARD: number;
  63030. readonly DEPTH_COMPONENT24: number;
  63031. readonly TEXTURE_3D: number;
  63032. readonly TEXTURE_2D_ARRAY: number;
  63033. readonly TEXTURE_COMPARE_FUNC: number;
  63034. readonly TEXTURE_COMPARE_MODE: number;
  63035. readonly COMPARE_REF_TO_TEXTURE: number;
  63036. readonly TEXTURE_WRAP_R: number;
  63037. readonly HALF_FLOAT: number;
  63038. readonly RGB8: number;
  63039. readonly RED_INTEGER: number;
  63040. readonly RG_INTEGER: number;
  63041. readonly RGB_INTEGER: number;
  63042. readonly RGBA_INTEGER: number;
  63043. readonly R8_SNORM: number;
  63044. readonly RG8_SNORM: number;
  63045. readonly RGB8_SNORM: number;
  63046. readonly RGBA8_SNORM: number;
  63047. readonly R8I: number;
  63048. readonly RG8I: number;
  63049. readonly RGB8I: number;
  63050. readonly RGBA8I: number;
  63051. readonly R8UI: number;
  63052. readonly RG8UI: number;
  63053. readonly RGB8UI: number;
  63054. readonly RGBA8UI: number;
  63055. readonly R16I: number;
  63056. readonly RG16I: number;
  63057. readonly RGB16I: number;
  63058. readonly RGBA16I: number;
  63059. readonly R16UI: number;
  63060. readonly RG16UI: number;
  63061. readonly RGB16UI: number;
  63062. readonly RGBA16UI: number;
  63063. readonly R32I: number;
  63064. readonly RG32I: number;
  63065. readonly RGB32I: number;
  63066. readonly RGBA32I: number;
  63067. readonly R32UI: number;
  63068. readonly RG32UI: number;
  63069. readonly RGB32UI: number;
  63070. readonly RGBA32UI: number;
  63071. readonly RGB10_A2UI: number;
  63072. readonly R11F_G11F_B10F: number;
  63073. readonly RGB9_E5: number;
  63074. readonly RGB10_A2: number;
  63075. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  63076. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  63077. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  63078. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  63079. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  63080. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  63081. 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;
  63082. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  63083. readonly TRANSFORM_FEEDBACK: number;
  63084. readonly INTERLEAVED_ATTRIBS: number;
  63085. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  63086. createTransformFeedback(): WebGLTransformFeedback;
  63087. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  63088. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  63089. beginTransformFeedback(primitiveMode: number): void;
  63090. endTransformFeedback(): void;
  63091. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  63092. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  63093. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  63094. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  63095. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  63096. }
  63097. interface ImageBitmap {
  63098. readonly width: number;
  63099. readonly height: number;
  63100. close(): void;
  63101. }
  63102. interface WebGLQuery extends WebGLObject {
  63103. }
  63104. declare var WebGLQuery: {
  63105. prototype: WebGLQuery;
  63106. new(): WebGLQuery;
  63107. };
  63108. interface WebGLSampler extends WebGLObject {
  63109. }
  63110. declare var WebGLSampler: {
  63111. prototype: WebGLSampler;
  63112. new(): WebGLSampler;
  63113. };
  63114. interface WebGLSync extends WebGLObject {
  63115. }
  63116. declare var WebGLSync: {
  63117. prototype: WebGLSync;
  63118. new(): WebGLSync;
  63119. };
  63120. interface WebGLTransformFeedback extends WebGLObject {
  63121. }
  63122. declare var WebGLTransformFeedback: {
  63123. prototype: WebGLTransformFeedback;
  63124. new(): WebGLTransformFeedback;
  63125. };
  63126. interface WebGLVertexArrayObject extends WebGLObject {
  63127. }
  63128. declare var WebGLVertexArrayObject: {
  63129. prototype: WebGLVertexArrayObject;
  63130. new(): WebGLVertexArrayObject;
  63131. };
  63132. // Type definitions for WebVR API
  63133. // Project: https://w3c.github.io/webvr/
  63134. // Definitions by: six a <https://github.com/lostfictions>
  63135. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  63136. interface VRDisplay extends EventTarget {
  63137. /**
  63138. * Dictionary of capabilities describing the VRDisplay.
  63139. */
  63140. readonly capabilities: VRDisplayCapabilities;
  63141. /**
  63142. * z-depth defining the far plane of the eye view frustum
  63143. * enables mapping of values in the render target depth
  63144. * attachment to scene coordinates. Initially set to 10000.0.
  63145. */
  63146. depthFar: number;
  63147. /**
  63148. * z-depth defining the near plane of the eye view frustum
  63149. * enables mapping of values in the render target depth
  63150. * attachment to scene coordinates. Initially set to 0.01.
  63151. */
  63152. depthNear: number;
  63153. /**
  63154. * An identifier for this distinct VRDisplay. Used as an
  63155. * association point in the Gamepad API.
  63156. */
  63157. readonly displayId: number;
  63158. /**
  63159. * A display name, a user-readable name identifying it.
  63160. */
  63161. readonly displayName: string;
  63162. readonly isConnected: boolean;
  63163. readonly isPresenting: boolean;
  63164. /**
  63165. * If this VRDisplay supports room-scale experiences, the optional
  63166. * stage attribute contains details on the room-scale parameters.
  63167. */
  63168. readonly stageParameters: VRStageParameters | null;
  63169. /**
  63170. * Passing the value returned by `requestAnimationFrame` to
  63171. * `cancelAnimationFrame` will unregister the callback.
  63172. * @param handle Define the hanle of the request to cancel
  63173. */
  63174. cancelAnimationFrame(handle: number): void;
  63175. /**
  63176. * Stops presenting to the VRDisplay.
  63177. * @returns a promise to know when it stopped
  63178. */
  63179. exitPresent(): Promise<void>;
  63180. /**
  63181. * Return the current VREyeParameters for the given eye.
  63182. * @param whichEye Define the eye we want the parameter for
  63183. * @returns the eye parameters
  63184. */
  63185. getEyeParameters(whichEye: string): VREyeParameters;
  63186. /**
  63187. * Populates the passed VRFrameData with the information required to render
  63188. * the current frame.
  63189. * @param frameData Define the data structure to populate
  63190. * @returns true if ok otherwise false
  63191. */
  63192. getFrameData(frameData: VRFrameData): boolean;
  63193. /**
  63194. * Get the layers currently being presented.
  63195. * @returns the list of VR layers
  63196. */
  63197. getLayers(): VRLayer[];
  63198. /**
  63199. * Return a VRPose containing the future predicted pose of the VRDisplay
  63200. * when the current frame will be presented. The value returned will not
  63201. * change until JavaScript has returned control to the browser.
  63202. *
  63203. * The VRPose will contain the position, orientation, velocity,
  63204. * and acceleration of each of these properties.
  63205. * @returns the pose object
  63206. */
  63207. getPose(): VRPose;
  63208. /**
  63209. * Return the current instantaneous pose of the VRDisplay, with no
  63210. * prediction applied.
  63211. * @returns the current instantaneous pose
  63212. */
  63213. getImmediatePose(): VRPose;
  63214. /**
  63215. * The callback passed to `requestAnimationFrame` will be called
  63216. * any time a new frame should be rendered. When the VRDisplay is
  63217. * presenting the callback will be called at the native refresh
  63218. * rate of the HMD. When not presenting this function acts
  63219. * identically to how window.requestAnimationFrame acts. Content should
  63220. * make no assumptions of frame rate or vsync behavior as the HMD runs
  63221. * asynchronously from other displays and at differing refresh rates.
  63222. * @param callback Define the eaction to run next frame
  63223. * @returns the request handle it
  63224. */
  63225. requestAnimationFrame(callback: FrameRequestCallback): number;
  63226. /**
  63227. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  63228. * Repeat calls while already presenting will update the VRLayers being displayed.
  63229. * @param layers Define the list of layer to present
  63230. * @returns a promise to know when the request has been fulfilled
  63231. */
  63232. requestPresent(layers: VRLayer[]): Promise<void>;
  63233. /**
  63234. * Reset the pose for this display, treating its current position and
  63235. * orientation as the "origin/zero" values. VRPose.position,
  63236. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  63237. * updated when calling resetPose(). This should be called in only
  63238. * sitting-space experiences.
  63239. */
  63240. resetPose(): void;
  63241. /**
  63242. * The VRLayer provided to the VRDisplay will be captured and presented
  63243. * in the HMD. Calling this function has the same effect on the source
  63244. * canvas as any other operation that uses its source image, and canvases
  63245. * created without preserveDrawingBuffer set to true will be cleared.
  63246. * @param pose Define the pose to submit
  63247. */
  63248. submitFrame(pose?: VRPose): void;
  63249. }
  63250. declare var VRDisplay: {
  63251. prototype: VRDisplay;
  63252. new(): VRDisplay;
  63253. };
  63254. interface VRLayer {
  63255. leftBounds?: number[] | Float32Array | null;
  63256. rightBounds?: number[] | Float32Array | null;
  63257. source?: HTMLCanvasElement | null;
  63258. }
  63259. interface VRDisplayCapabilities {
  63260. readonly canPresent: boolean;
  63261. readonly hasExternalDisplay: boolean;
  63262. readonly hasOrientation: boolean;
  63263. readonly hasPosition: boolean;
  63264. readonly maxLayers: number;
  63265. }
  63266. interface VREyeParameters {
  63267. /** @deprecated */
  63268. readonly fieldOfView: VRFieldOfView;
  63269. readonly offset: Float32Array;
  63270. readonly renderHeight: number;
  63271. readonly renderWidth: number;
  63272. }
  63273. interface VRFieldOfView {
  63274. readonly downDegrees: number;
  63275. readonly leftDegrees: number;
  63276. readonly rightDegrees: number;
  63277. readonly upDegrees: number;
  63278. }
  63279. interface VRFrameData {
  63280. readonly leftProjectionMatrix: Float32Array;
  63281. readonly leftViewMatrix: Float32Array;
  63282. readonly pose: VRPose;
  63283. readonly rightProjectionMatrix: Float32Array;
  63284. readonly rightViewMatrix: Float32Array;
  63285. readonly timestamp: number;
  63286. }
  63287. interface VRPose {
  63288. readonly angularAcceleration: Float32Array | null;
  63289. readonly angularVelocity: Float32Array | null;
  63290. readonly linearAcceleration: Float32Array | null;
  63291. readonly linearVelocity: Float32Array | null;
  63292. readonly orientation: Float32Array | null;
  63293. readonly position: Float32Array | null;
  63294. readonly timestamp: number;
  63295. }
  63296. interface VRStageParameters {
  63297. sittingToStandingTransform?: Float32Array;
  63298. sizeX?: number;
  63299. sizeY?: number;
  63300. }
  63301. interface Navigator {
  63302. getVRDisplays(): Promise<VRDisplay[]>;
  63303. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  63304. }
  63305. interface Window {
  63306. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  63307. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  63308. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  63309. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  63310. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  63311. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  63312. }
  63313. interface Gamepad {
  63314. readonly displayId: number;
  63315. }
  63316. type XRSessionMode =
  63317. | "inline"
  63318. | "immersive-vr"
  63319. | "immersive-ar";
  63320. type XRReferenceSpaceType =
  63321. | "viewer"
  63322. | "local"
  63323. | "local-floor"
  63324. | "bounded-floor"
  63325. | "unbounded";
  63326. type XREnvironmentBlendMode =
  63327. | "opaque"
  63328. | "additive"
  63329. | "alpha-blend";
  63330. type XRVisibilityState =
  63331. | "visible"
  63332. | "visible-blurred"
  63333. | "hidden";
  63334. type XRHandedness =
  63335. | "none"
  63336. | "left"
  63337. | "right";
  63338. type XRTargetRayMode =
  63339. | "gaze"
  63340. | "tracked-pointer"
  63341. | "screen";
  63342. type XREye =
  63343. | "none"
  63344. | "left"
  63345. | "right";
  63346. interface XRSpace extends EventTarget {
  63347. }
  63348. interface XRRenderState {
  63349. depthNear?: number;
  63350. depthFar?: number;
  63351. inlineVerticalFieldOfView?: number;
  63352. baseLayer?: XRWebGLLayer;
  63353. }
  63354. interface XRInputSource {
  63355. handedness: XRHandedness;
  63356. targetRayMode: XRTargetRayMode;
  63357. targetRaySpace: XRSpace;
  63358. gripSpace: XRSpace | undefined;
  63359. gamepad: Gamepad | undefined;
  63360. profiles: Array<string>;
  63361. }
  63362. interface XRSession {
  63363. addEventListener: Function;
  63364. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  63365. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  63366. requestAnimationFrame: Function;
  63367. end(): Promise<void>;
  63368. renderState: XRRenderState;
  63369. inputSources: Array<XRInputSource>;
  63370. }
  63371. interface XRReferenceSpace extends XRSpace {
  63372. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  63373. onreset: any;
  63374. }
  63375. interface XRFrame {
  63376. session: XRSession;
  63377. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  63378. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  63379. }
  63380. interface XRViewerPose extends XRPose {
  63381. views: Array<XRView>;
  63382. }
  63383. interface XRPose {
  63384. transform: XRRigidTransform;
  63385. emulatedPosition: boolean;
  63386. }
  63387. declare var XRWebGLLayer: {
  63388. prototype: XRWebGLLayer;
  63389. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  63390. };
  63391. interface XRWebGLLayer {
  63392. framebuffer: WebGLFramebuffer;
  63393. framebufferWidth: number;
  63394. framebufferHeight: number;
  63395. getViewport: Function;
  63396. }
  63397. interface XRRigidTransform {
  63398. position: DOMPointReadOnly;
  63399. orientation: DOMPointReadOnly;
  63400. matrix: Float32Array;
  63401. inverse: XRRigidTransform;
  63402. }
  63403. interface XRView {
  63404. eye: XREye;
  63405. projectionMatrix: Float32Array;
  63406. transform: XRRigidTransform;
  63407. }
  63408. interface XRInputSourceChangeEvent {
  63409. session: XRSession;
  63410. removed: Array<XRInputSource>;
  63411. added: Array<XRInputSource>;
  63412. }
  63413. /**
  63414. * @ignore
  63415. */
  63416. declare module BABYLON.GLTF2.Exporter {
  63417. }
  63418. /**
  63419. * @ignore
  63420. */
  63421. declare module BABYLON.GLTF1 {
  63422. }
  63423. declare module BABYLON.GUI {
  63424. /**
  63425. * Class used to specific a value and its associated unit
  63426. */
  63427. export class ValueAndUnit {
  63428. /** defines the unit to store */
  63429. unit: number;
  63430. /** defines a boolean indicating if the value can be negative */
  63431. negativeValueAllowed: boolean;
  63432. private _value;
  63433. private _originalUnit;
  63434. /**
  63435. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  63436. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63437. */
  63438. ignoreAdaptiveScaling: boolean;
  63439. /**
  63440. * Creates a new ValueAndUnit
  63441. * @param value defines the value to store
  63442. * @param unit defines the unit to store
  63443. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  63444. */
  63445. constructor(value: number,
  63446. /** defines the unit to store */
  63447. unit?: number,
  63448. /** defines a boolean indicating if the value can be negative */
  63449. negativeValueAllowed?: boolean);
  63450. /** Gets a boolean indicating if the value is a percentage */
  63451. readonly isPercentage: boolean;
  63452. /** Gets a boolean indicating if the value is store as pixel */
  63453. readonly isPixel: boolean;
  63454. /** Gets direct internal value */
  63455. readonly internalValue: number;
  63456. /**
  63457. * Gets value as pixel
  63458. * @param host defines the root host
  63459. * @param refValue defines the reference value for percentages
  63460. * @returns the value as pixel
  63461. */
  63462. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  63463. /**
  63464. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  63465. * @param value defines the value to store
  63466. * @param unit defines the unit to store
  63467. * @returns the current ValueAndUnit
  63468. */
  63469. updateInPlace(value: number, unit?: number): ValueAndUnit;
  63470. /**
  63471. * Gets the value accordingly to its unit
  63472. * @param host defines the root host
  63473. * @returns the value
  63474. */
  63475. getValue(host: AdvancedDynamicTexture): number;
  63476. /**
  63477. * Gets a string representation of the value
  63478. * @param host defines the root host
  63479. * @param decimals defines an optional number of decimals to display
  63480. * @returns a string
  63481. */
  63482. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  63483. /**
  63484. * Store a value parsed from a string
  63485. * @param source defines the source string
  63486. * @returns true if the value was successfully parsed
  63487. */
  63488. fromString(source: string | number): boolean;
  63489. private static _Regex;
  63490. private static _UNITMODE_PERCENTAGE;
  63491. private static _UNITMODE_PIXEL;
  63492. /** UNITMODE_PERCENTAGE */
  63493. static readonly UNITMODE_PERCENTAGE: number;
  63494. /** UNITMODE_PIXEL */
  63495. static readonly UNITMODE_PIXEL: number;
  63496. }
  63497. }
  63498. declare module BABYLON.GUI {
  63499. /**
  63500. * Define a style used by control to automatically setup properties based on a template.
  63501. * Only support font related properties so far
  63502. */
  63503. export class Style implements BABYLON.IDisposable {
  63504. private _fontFamily;
  63505. private _fontStyle;
  63506. private _fontWeight;
  63507. /** @hidden */ private _host: AdvancedDynamicTexture;
  63508. /** @hidden */ private _fontSize: ValueAndUnit;
  63509. /**
  63510. * BABYLON.Observable raised when the style values are changed
  63511. */
  63512. onChangedObservable: BABYLON.Observable<Style>;
  63513. /**
  63514. * Creates a new style object
  63515. * @param host defines the AdvancedDynamicTexture which hosts this style
  63516. */
  63517. constructor(host: AdvancedDynamicTexture);
  63518. /**
  63519. * Gets or sets the font size
  63520. */
  63521. fontSize: string | number;
  63522. /**
  63523. * Gets or sets the font family
  63524. */
  63525. fontFamily: string;
  63526. /**
  63527. * Gets or sets the font style
  63528. */
  63529. fontStyle: string;
  63530. /** Gets or sets font weight */
  63531. fontWeight: string;
  63532. /** Dispose all associated resources */
  63533. dispose(): void;
  63534. }
  63535. }
  63536. declare module BABYLON.GUI {
  63537. /**
  63538. * Class used to transport BABYLON.Vector2 information for pointer events
  63539. */
  63540. export class Vector2WithInfo extends BABYLON.Vector2 {
  63541. /** defines the current mouse button index */
  63542. buttonIndex: number;
  63543. /**
  63544. * Creates a new Vector2WithInfo
  63545. * @param source defines the vector2 data to transport
  63546. * @param buttonIndex defines the current mouse button index
  63547. */
  63548. constructor(source: BABYLON.Vector2,
  63549. /** defines the current mouse button index */
  63550. buttonIndex?: number);
  63551. }
  63552. /** Class used to provide 2D matrix features */
  63553. export class Matrix2D {
  63554. /** Gets the internal array of 6 floats used to store matrix data */
  63555. m: Float32Array;
  63556. /**
  63557. * Creates a new matrix
  63558. * @param m00 defines value for (0, 0)
  63559. * @param m01 defines value for (0, 1)
  63560. * @param m10 defines value for (1, 0)
  63561. * @param m11 defines value for (1, 1)
  63562. * @param m20 defines value for (2, 0)
  63563. * @param m21 defines value for (2, 1)
  63564. */
  63565. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  63566. /**
  63567. * Fills the matrix from direct values
  63568. * @param m00 defines value for (0, 0)
  63569. * @param m01 defines value for (0, 1)
  63570. * @param m10 defines value for (1, 0)
  63571. * @param m11 defines value for (1, 1)
  63572. * @param m20 defines value for (2, 0)
  63573. * @param m21 defines value for (2, 1)
  63574. * @returns the current modified matrix
  63575. */
  63576. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  63577. /**
  63578. * Gets matrix determinant
  63579. * @returns the determinant
  63580. */
  63581. determinant(): number;
  63582. /**
  63583. * Inverses the matrix and stores it in a target matrix
  63584. * @param result defines the target matrix
  63585. * @returns the current matrix
  63586. */
  63587. invertToRef(result: Matrix2D): Matrix2D;
  63588. /**
  63589. * Multiplies the current matrix with another one
  63590. * @param other defines the second operand
  63591. * @param result defines the target matrix
  63592. * @returns the current matrix
  63593. */
  63594. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  63595. /**
  63596. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  63597. * @param x defines the x coordinate to transform
  63598. * @param y defines the x coordinate to transform
  63599. * @param result defines the target vector2
  63600. * @returns the current matrix
  63601. */
  63602. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  63603. /**
  63604. * Creates an identity matrix
  63605. * @returns a new matrix
  63606. */
  63607. static Identity(): Matrix2D;
  63608. /**
  63609. * Creates a translation matrix and stores it in a target matrix
  63610. * @param x defines the x coordinate of the translation
  63611. * @param y defines the y coordinate of the translation
  63612. * @param result defines the target matrix
  63613. */
  63614. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  63615. /**
  63616. * Creates a scaling matrix and stores it in a target matrix
  63617. * @param x defines the x coordinate of the scaling
  63618. * @param y defines the y coordinate of the scaling
  63619. * @param result defines the target matrix
  63620. */
  63621. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  63622. /**
  63623. * Creates a rotation matrix and stores it in a target matrix
  63624. * @param angle defines the rotation angle
  63625. * @param result defines the target matrix
  63626. */
  63627. static RotationToRef(angle: number, result: Matrix2D): void;
  63628. private static _TempPreTranslationMatrix;
  63629. private static _TempPostTranslationMatrix;
  63630. private static _TempRotationMatrix;
  63631. private static _TempScalingMatrix;
  63632. private static _TempCompose0;
  63633. private static _TempCompose1;
  63634. private static _TempCompose2;
  63635. /**
  63636. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  63637. * @param tx defines the x coordinate of the translation
  63638. * @param ty defines the y coordinate of the translation
  63639. * @param angle defines the rotation angle
  63640. * @param scaleX defines the x coordinate of the scaling
  63641. * @param scaleY defines the y coordinate of the scaling
  63642. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  63643. * @param result defines the target matrix
  63644. */
  63645. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  63646. }
  63647. }
  63648. declare module BABYLON.GUI {
  63649. /**
  63650. * Class used to store 2D control sizes
  63651. */
  63652. export class Measure {
  63653. /** defines left coordinate */
  63654. left: number;
  63655. /** defines top coordinate */
  63656. top: number;
  63657. /** defines width dimension */
  63658. width: number;
  63659. /** defines height dimension */
  63660. height: number;
  63661. /**
  63662. * Creates a new measure
  63663. * @param left defines left coordinate
  63664. * @param top defines top coordinate
  63665. * @param width defines width dimension
  63666. * @param height defines height dimension
  63667. */
  63668. constructor(
  63669. /** defines left coordinate */
  63670. left: number,
  63671. /** defines top coordinate */
  63672. top: number,
  63673. /** defines width dimension */
  63674. width: number,
  63675. /** defines height dimension */
  63676. height: number);
  63677. /**
  63678. * Copy from another measure
  63679. * @param other defines the other measure to copy from
  63680. */
  63681. copyFrom(other: Measure): void;
  63682. /**
  63683. * Copy from a group of 4 floats
  63684. * @param left defines left coordinate
  63685. * @param top defines top coordinate
  63686. * @param width defines width dimension
  63687. * @param height defines height dimension
  63688. */
  63689. copyFromFloats(left: number, top: number, width: number, height: number): void;
  63690. /**
  63691. * Computes the axis aligned bounding box measure for two given measures
  63692. * @param a Input measure
  63693. * @param b Input measure
  63694. * @param result the resulting bounding measure
  63695. */
  63696. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  63697. /**
  63698. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  63699. * @param transform the matrix to transform the measure before computing the AABB
  63700. * @param result the resulting AABB
  63701. */
  63702. transformToRef(transform: Matrix2D, result: Measure): void;
  63703. /**
  63704. * Check equality between this measure and another one
  63705. * @param other defines the other measures
  63706. * @returns true if both measures are equals
  63707. */
  63708. isEqualsTo(other: Measure): boolean;
  63709. /**
  63710. * Creates an empty measure
  63711. * @returns a new measure
  63712. */
  63713. static Empty(): Measure;
  63714. }
  63715. }
  63716. declare module BABYLON.GUI {
  63717. /**
  63718. * Interface used to define a control that can receive focus
  63719. */
  63720. export interface IFocusableControl {
  63721. /**
  63722. * Function called when the control receives the focus
  63723. */
  63724. onFocus(): void;
  63725. /**
  63726. * Function called when the control loses the focus
  63727. */
  63728. onBlur(): void;
  63729. /**
  63730. * Function called to let the control handle keyboard events
  63731. * @param evt defines the current keyboard event
  63732. */
  63733. processKeyboard(evt: KeyboardEvent): void;
  63734. /**
  63735. * Function called to get the list of controls that should not steal the focus from this control
  63736. * @returns an array of controls
  63737. */
  63738. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  63739. }
  63740. /**
  63741. * Class used to create texture to support 2D GUI elements
  63742. * @see http://doc.babylonjs.com/how_to/gui
  63743. */
  63744. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  63745. private _isDirty;
  63746. private _renderObserver;
  63747. private _resizeObserver;
  63748. private _preKeyboardObserver;
  63749. private _pointerMoveObserver;
  63750. private _pointerObserver;
  63751. private _canvasPointerOutObserver;
  63752. private _background;
  63753. /** @hidden */ private _rootContainer: Container;
  63754. /** @hidden */ private _lastPickedControl: Control;
  63755. /** @hidden */ private _lastControlOver: {
  63756. [pointerId: number]: Control;
  63757. };
  63758. /** @hidden */ private _lastControlDown: {
  63759. [pointerId: number]: Control;
  63760. };
  63761. /** @hidden */ private _capturingControl: {
  63762. [pointerId: number]: Control;
  63763. };
  63764. /** @hidden */ private _shouldBlockPointer: boolean;
  63765. /** @hidden */ private _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  63766. /** @hidden */ private _linkedControls: Control[];
  63767. private _isFullscreen;
  63768. private _fullscreenViewport;
  63769. private _idealWidth;
  63770. private _idealHeight;
  63771. private _useSmallestIdeal;
  63772. private _renderAtIdealSize;
  63773. private _focusedControl;
  63774. private _blockNextFocusCheck;
  63775. private _renderScale;
  63776. private _rootCanvas;
  63777. private _cursorChanged;
  63778. /**
  63779. * Define type to string to ensure compatibility across browsers
  63780. * Safari doesn't support DataTransfer constructor
  63781. */
  63782. private _clipboardData;
  63783. /**
  63784. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  63785. */
  63786. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  63787. /**
  63788. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  63789. */
  63790. onControlPickedObservable: BABYLON.Observable<Control>;
  63791. /**
  63792. * BABYLON.Observable event triggered before layout is evaluated
  63793. */
  63794. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63795. /**
  63796. * BABYLON.Observable event triggered after the layout was evaluated
  63797. */
  63798. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63799. /**
  63800. * BABYLON.Observable event triggered before the texture is rendered
  63801. */
  63802. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63803. /**
  63804. * BABYLON.Observable event triggered after the texture was rendered
  63805. */
  63806. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63807. /**
  63808. * Gets or sets a boolean defining if alpha is stored as premultiplied
  63809. */
  63810. premulAlpha: boolean;
  63811. /**
  63812. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  63813. * Useful when you want more antialiasing
  63814. */
  63815. renderScale: number;
  63816. /** Gets or sets the background color */
  63817. background: string;
  63818. /**
  63819. * Gets or sets the ideal width used to design controls.
  63820. * The GUI will then rescale everything accordingly
  63821. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63822. */
  63823. idealWidth: number;
  63824. /**
  63825. * Gets or sets the ideal height used to design controls.
  63826. * The GUI will then rescale everything accordingly
  63827. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63828. */
  63829. idealHeight: number;
  63830. /**
  63831. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  63832. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63833. */
  63834. useSmallestIdeal: boolean;
  63835. /**
  63836. * Gets or sets a boolean indicating if adaptive scaling must be used
  63837. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63838. */
  63839. renderAtIdealSize: boolean;
  63840. /**
  63841. * Gets the underlying layer used to render the texture when in fullscreen mode
  63842. */
  63843. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  63844. /**
  63845. * Gets the root container control
  63846. */
  63847. readonly rootContainer: Container;
  63848. /**
  63849. * Returns an array containing the root container.
  63850. * This is mostly used to let the Inspector introspects the ADT
  63851. * @returns an array containing the rootContainer
  63852. */
  63853. getChildren(): Array<Container>;
  63854. /**
  63855. * Will return all controls that are inside this texture
  63856. * @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
  63857. * @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
  63858. * @return all child controls
  63859. */
  63860. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  63861. /**
  63862. * Gets or sets the current focused control
  63863. */
  63864. focusedControl: BABYLON.Nullable<IFocusableControl>;
  63865. /**
  63866. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  63867. */
  63868. isForeground: boolean;
  63869. /**
  63870. * Gets or set information about clipboardData
  63871. */
  63872. clipboardData: string;
  63873. /**
  63874. * Creates a new AdvancedDynamicTexture
  63875. * @param name defines the name of the texture
  63876. * @param width defines the width of the texture
  63877. * @param height defines the height of the texture
  63878. * @param scene defines the hosting scene
  63879. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  63880. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  63881. */
  63882. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  63883. /**
  63884. * Get the current class name of the texture useful for serialization or dynamic coding.
  63885. * @returns "AdvancedDynamicTexture"
  63886. */
  63887. getClassName(): string;
  63888. /**
  63889. * Function used to execute a function on all controls
  63890. * @param func defines the function to execute
  63891. * @param container defines the container where controls belong. If null the root container will be used
  63892. */
  63893. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  63894. private _useInvalidateRectOptimization;
  63895. /**
  63896. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  63897. */
  63898. useInvalidateRectOptimization: boolean;
  63899. private _invalidatedRectangle;
  63900. /**
  63901. * Invalidates a rectangle area on the gui texture
  63902. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  63903. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  63904. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  63905. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  63906. */
  63907. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  63908. /**
  63909. * Marks the texture as dirty forcing a complete update
  63910. */
  63911. markAsDirty(): void;
  63912. /**
  63913. * Helper function used to create a new style
  63914. * @returns a new style
  63915. * @see http://doc.babylonjs.com/how_to/gui#styles
  63916. */
  63917. createStyle(): Style;
  63918. /**
  63919. * Adds a new control to the root container
  63920. * @param control defines the control to add
  63921. * @returns the current texture
  63922. */
  63923. addControl(control: Control): AdvancedDynamicTexture;
  63924. /**
  63925. * Removes a control from the root container
  63926. * @param control defines the control to remove
  63927. * @returns the current texture
  63928. */
  63929. removeControl(control: Control): AdvancedDynamicTexture;
  63930. /**
  63931. * Release all resources
  63932. */
  63933. dispose(): void;
  63934. private _onResize;
  63935. /** @hidden */ private _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  63936. /**
  63937. * Get screen coordinates for a vector3
  63938. * @param position defines the position to project
  63939. * @param worldMatrix defines the world matrix to use
  63940. * @returns the projected position
  63941. */
  63942. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  63943. private _checkUpdate;
  63944. private _clearMeasure;
  63945. private _render;
  63946. /** @hidden */ private _changeCursor(cursor: string): void;
  63947. /** @hidden */ private _registerLastControlDown(control: Control, pointerId: number): void;
  63948. private _doPicking;
  63949. /** @hidden */ private _cleanControlAfterRemovalFromList(list: {
  63950. [pointerId: number]: Control;
  63951. }, control: Control): void;
  63952. /** @hidden */ private _cleanControlAfterRemoval(control: Control): void;
  63953. /** Attach to all scene events required to support pointer events */
  63954. attach(): void;
  63955. /** @hidden */
  63956. private onClipboardCopy;
  63957. /** @hidden */
  63958. private onClipboardCut;
  63959. /** @hidden */
  63960. private onClipboardPaste;
  63961. /**
  63962. * Register the clipboard Events onto the canvas
  63963. */
  63964. registerClipboardEvents(): void;
  63965. /**
  63966. * Unregister the clipboard Events from the canvas
  63967. */
  63968. unRegisterClipboardEvents(): void;
  63969. /**
  63970. * Connect the texture to a hosting mesh to enable interactions
  63971. * @param mesh defines the mesh to attach to
  63972. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  63973. */
  63974. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  63975. /**
  63976. * Move the focus to a specific control
  63977. * @param control defines the control which will receive the focus
  63978. */
  63979. moveFocusToControl(control: IFocusableControl): void;
  63980. private _manageFocus;
  63981. private _attachToOnPointerOut;
  63982. /**
  63983. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  63984. * @param mesh defines the mesh which will receive the texture
  63985. * @param width defines the texture width (1024 by default)
  63986. * @param height defines the texture height (1024 by default)
  63987. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  63988. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  63989. * @returns a new AdvancedDynamicTexture
  63990. */
  63991. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  63992. /**
  63993. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  63994. * In this mode the texture will rely on a layer for its rendering.
  63995. * This allows it to be treated like any other layer.
  63996. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  63997. * LayerMask is set through advancedTexture.layer.layerMask
  63998. * @param name defines name for the texture
  63999. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  64000. * @param scene defines the hsoting scene
  64001. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  64002. * @returns a new AdvancedDynamicTexture
  64003. */
  64004. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  64005. }
  64006. }
  64007. declare module BABYLON.GUI {
  64008. /**
  64009. * Root class used for all 2D controls
  64010. * @see http://doc.babylonjs.com/how_to/gui#controls
  64011. */
  64012. export class Control {
  64013. /** defines the name of the control */
  64014. name?: string | undefined;
  64015. /**
  64016. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  64017. */
  64018. static AllowAlphaInheritance: boolean;
  64019. private _alpha;
  64020. private _alphaSet;
  64021. private _zIndex;
  64022. /** @hidden */ private _host: AdvancedDynamicTexture;
  64023. /** Gets or sets the control parent */
  64024. parent: BABYLON.Nullable<Container>;
  64025. /** @hidden */ private _currentMeasure: Measure;
  64026. private _fontFamily;
  64027. private _fontStyle;
  64028. private _fontWeight;
  64029. private _fontSize;
  64030. private _font;
  64031. /** @hidden */ private _width: ValueAndUnit;
  64032. /** @hidden */ private _height: ValueAndUnit;
  64033. /** @hidden */
  64034. protected _fontOffset: {
  64035. ascent: number;
  64036. height: number;
  64037. descent: number;
  64038. };
  64039. private _color;
  64040. private _style;
  64041. private _styleObserver;
  64042. /** @hidden */
  64043. protected _horizontalAlignment: number;
  64044. /** @hidden */
  64045. protected _verticalAlignment: number;
  64046. /** @hidden */
  64047. protected _isDirty: boolean;
  64048. /** @hidden */
  64049. protected _wasDirty: boolean;
  64050. /** @hidden */ private _tempParentMeasure: Measure;
  64051. /** @hidden */ private _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  64052. /** @hidden */
  64053. protected _cachedParentMeasure: Measure;
  64054. private _paddingLeft;
  64055. private _paddingRight;
  64056. private _paddingTop;
  64057. private _paddingBottom;
  64058. /** @hidden */ private _left: ValueAndUnit;
  64059. /** @hidden */ private _top: ValueAndUnit;
  64060. private _scaleX;
  64061. private _scaleY;
  64062. private _rotation;
  64063. private _transformCenterX;
  64064. private _transformCenterY;
  64065. /** @hidden */ private _transformMatrix: Matrix2D;
  64066. /** @hidden */
  64067. protected _invertTransformMatrix: Matrix2D;
  64068. /** @hidden */
  64069. protected _transformedPosition: BABYLON.Vector2;
  64070. private _isMatrixDirty;
  64071. private _cachedOffsetX;
  64072. private _cachedOffsetY;
  64073. private _isVisible;
  64074. private _isHighlighted;
  64075. /** @hidden */ private _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64076. private _fontSet;
  64077. private _dummyVector2;
  64078. private _downCount;
  64079. private _enterCount;
  64080. private _doNotRender;
  64081. private _downPointerIds;
  64082. protected _isEnabled: boolean;
  64083. protected _disabledColor: string;
  64084. /** @hidden */
  64085. protected _rebuildLayout: boolean;
  64086. /** @hidden */ private _isClipped: boolean;
  64087. /** @hidden */ private _tag: any;
  64088. /**
  64089. * 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
  64090. */
  64091. uniqueId: number;
  64092. /**
  64093. * Gets or sets an object used to store user defined information for the node
  64094. */
  64095. metadata: any;
  64096. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  64097. isHitTestVisible: boolean;
  64098. /** Gets or sets a boolean indicating if the control can block pointer events */
  64099. isPointerBlocker: boolean;
  64100. /** Gets or sets a boolean indicating if the control can be focusable */
  64101. isFocusInvisible: boolean;
  64102. /**
  64103. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  64104. * 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
  64105. */
  64106. clipChildren: boolean;
  64107. /**
  64108. * Gets or sets a boolean indicating that control content must be clipped
  64109. * 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
  64110. */
  64111. clipContent: boolean;
  64112. /**
  64113. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  64114. */
  64115. useBitmapCache: boolean;
  64116. private _cacheData;
  64117. private _shadowOffsetX;
  64118. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  64119. shadowOffsetX: number;
  64120. private _shadowOffsetY;
  64121. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  64122. shadowOffsetY: number;
  64123. private _shadowBlur;
  64124. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  64125. shadowBlur: number;
  64126. private _shadowColor;
  64127. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  64128. shadowColor: string;
  64129. /** Gets or sets the cursor to use when the control is hovered */
  64130. hoverCursor: string;
  64131. /** @hidden */
  64132. protected _linkOffsetX: ValueAndUnit;
  64133. /** @hidden */
  64134. protected _linkOffsetY: ValueAndUnit;
  64135. /** Gets the control type name */
  64136. readonly typeName: string;
  64137. /**
  64138. * Get the current class name of the control.
  64139. * @returns current class name
  64140. */
  64141. getClassName(): string;
  64142. /**
  64143. * An event triggered when the pointer move over the control.
  64144. */
  64145. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  64146. /**
  64147. * An event triggered when the pointer move out of the control.
  64148. */
  64149. onPointerOutObservable: BABYLON.Observable<Control>;
  64150. /**
  64151. * An event triggered when the pointer taps the control
  64152. */
  64153. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  64154. /**
  64155. * An event triggered when pointer up
  64156. */
  64157. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  64158. /**
  64159. * An event triggered when a control is clicked on
  64160. */
  64161. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  64162. /**
  64163. * An event triggered when pointer enters the control
  64164. */
  64165. onPointerEnterObservable: BABYLON.Observable<Control>;
  64166. /**
  64167. * An event triggered when the control is marked as dirty
  64168. */
  64169. onDirtyObservable: BABYLON.Observable<Control>;
  64170. /**
  64171. * An event triggered before drawing the control
  64172. */
  64173. onBeforeDrawObservable: BABYLON.Observable<Control>;
  64174. /**
  64175. * An event triggered after the control was drawn
  64176. */
  64177. onAfterDrawObservable: BABYLON.Observable<Control>;
  64178. /**
  64179. * Get the hosting AdvancedDynamicTexture
  64180. */
  64181. readonly host: AdvancedDynamicTexture;
  64182. /** Gets or set information about font offsets (used to render and align text) */
  64183. fontOffset: {
  64184. ascent: number;
  64185. height: number;
  64186. descent: number;
  64187. };
  64188. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  64189. alpha: number;
  64190. /**
  64191. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  64192. */
  64193. isHighlighted: boolean;
  64194. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  64195. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64196. */
  64197. scaleX: number;
  64198. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  64199. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64200. */
  64201. scaleY: number;
  64202. /** Gets or sets the rotation angle (0 by default)
  64203. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64204. */
  64205. rotation: number;
  64206. /** Gets or sets the transformation center on Y axis (0 by default)
  64207. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64208. */
  64209. transformCenterY: number;
  64210. /** Gets or sets the transformation center on X axis (0 by default)
  64211. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64212. */
  64213. transformCenterX: number;
  64214. /**
  64215. * Gets or sets the horizontal alignment
  64216. * @see http://doc.babylonjs.com/how_to/gui#alignments
  64217. */
  64218. horizontalAlignment: number;
  64219. /**
  64220. * Gets or sets the vertical alignment
  64221. * @see http://doc.babylonjs.com/how_to/gui#alignments
  64222. */
  64223. verticalAlignment: number;
  64224. /**
  64225. * Gets or sets control width
  64226. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64227. */
  64228. width: string | number;
  64229. /**
  64230. * Gets or sets the control width in pixel
  64231. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64232. */
  64233. widthInPixels: number;
  64234. /**
  64235. * Gets or sets control height
  64236. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64237. */
  64238. height: string | number;
  64239. /**
  64240. * Gets or sets control height in pixel
  64241. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64242. */
  64243. heightInPixels: number;
  64244. /** Gets or set font family */
  64245. fontFamily: string;
  64246. /** Gets or sets font style */
  64247. fontStyle: string;
  64248. /** Gets or sets font weight */
  64249. fontWeight: string;
  64250. /**
  64251. * Gets or sets style
  64252. * @see http://doc.babylonjs.com/how_to/gui#styles
  64253. */
  64254. style: BABYLON.Nullable<Style>;
  64255. /** @hidden */ protected readonly _isFontSizeInPercentage: boolean;
  64256. /** Gets or sets font size in pixels */
  64257. fontSizeInPixels: number;
  64258. /** Gets or sets font size */
  64259. fontSize: string | number;
  64260. /** Gets or sets foreground color */
  64261. color: string;
  64262. /** Gets or sets z index which is used to reorder controls on the z axis */
  64263. zIndex: number;
  64264. /** Gets or sets a boolean indicating if the control can be rendered */
  64265. notRenderable: boolean;
  64266. /** Gets or sets a boolean indicating if the control is visible */
  64267. isVisible: boolean;
  64268. /** Gets a boolean indicating that the control needs to update its rendering */
  64269. readonly isDirty: boolean;
  64270. /**
  64271. * Gets the current linked mesh (or null if none)
  64272. */
  64273. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64274. /**
  64275. * Gets or sets a value indicating the padding to use on the left of the control
  64276. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64277. */
  64278. paddingLeft: string | number;
  64279. /**
  64280. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  64281. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64282. */
  64283. paddingLeftInPixels: number;
  64284. /**
  64285. * Gets or sets a value indicating the padding to use on the right of the control
  64286. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64287. */
  64288. paddingRight: string | number;
  64289. /**
  64290. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  64291. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64292. */
  64293. paddingRightInPixels: number;
  64294. /**
  64295. * Gets or sets a value indicating the padding to use on the top of the control
  64296. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64297. */
  64298. paddingTop: string | number;
  64299. /**
  64300. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  64301. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64302. */
  64303. paddingTopInPixels: number;
  64304. /**
  64305. * Gets or sets a value indicating the padding to use on the bottom of the control
  64306. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64307. */
  64308. paddingBottom: string | number;
  64309. /**
  64310. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  64311. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64312. */
  64313. paddingBottomInPixels: number;
  64314. /**
  64315. * Gets or sets a value indicating the left coordinate of the control
  64316. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64317. */
  64318. left: string | number;
  64319. /**
  64320. * Gets or sets a value indicating the left coordinate in pixels of the control
  64321. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64322. */
  64323. leftInPixels: number;
  64324. /**
  64325. * Gets or sets a value indicating the top coordinate of the control
  64326. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64327. */
  64328. top: string | number;
  64329. /**
  64330. * Gets or sets a value indicating the top coordinate in pixels of the control
  64331. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64332. */
  64333. topInPixels: number;
  64334. /**
  64335. * Gets or sets a value indicating the offset on X axis to the linked mesh
  64336. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64337. */
  64338. linkOffsetX: string | number;
  64339. /**
  64340. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  64341. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64342. */
  64343. linkOffsetXInPixels: number;
  64344. /**
  64345. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  64346. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64347. */
  64348. linkOffsetY: string | number;
  64349. /**
  64350. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  64351. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64352. */
  64353. linkOffsetYInPixels: number;
  64354. /** Gets the center coordinate on X axis */
  64355. readonly centerX: number;
  64356. /** Gets the center coordinate on Y axis */
  64357. readonly centerY: number;
  64358. /** Gets or sets if control is Enabled*/
  64359. isEnabled: boolean;
  64360. /** Gets or sets background color of control if it's disabled*/
  64361. disabledColor: string;
  64362. /**
  64363. * Creates a new control
  64364. * @param name defines the name of the control
  64365. */
  64366. constructor(
  64367. /** defines the name of the control */
  64368. name?: string | undefined);
  64369. /** @hidden */
  64370. protected _getTypeName(): string;
  64371. /**
  64372. * Gets the first ascendant in the hierarchy of the given type
  64373. * @param className defines the required type
  64374. * @returns the ascendant or null if not found
  64375. */
  64376. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  64377. /** @hidden */ private _resetFontCache(): void;
  64378. /**
  64379. * Determines if a container is an ascendant of the current control
  64380. * @param container defines the container to look for
  64381. * @returns true if the container is one of the ascendant of the control
  64382. */
  64383. isAscendant(container: Control): boolean;
  64384. /**
  64385. * Gets coordinates in local control space
  64386. * @param globalCoordinates defines the coordinates to transform
  64387. * @returns the new coordinates in local space
  64388. */
  64389. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  64390. /**
  64391. * Gets coordinates in local control space
  64392. * @param globalCoordinates defines the coordinates to transform
  64393. * @param result defines the target vector2 where to store the result
  64394. * @returns the current control
  64395. */
  64396. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  64397. /**
  64398. * Gets coordinates in parent local control space
  64399. * @param globalCoordinates defines the coordinates to transform
  64400. * @returns the new coordinates in parent local space
  64401. */
  64402. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  64403. /**
  64404. * Move the current control to a vector3 position projected onto the screen.
  64405. * @param position defines the target position
  64406. * @param scene defines the hosting scene
  64407. */
  64408. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  64409. /** @hidden */ private _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  64410. /**
  64411. * Will return all controls that have this control as ascendant
  64412. * @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
  64413. * @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
  64414. * @return all child controls
  64415. */
  64416. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  64417. /**
  64418. * Link current control with a target mesh
  64419. * @param mesh defines the mesh to link with
  64420. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64421. */
  64422. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  64423. /** @hidden */ private _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  64424. /** @hidden */ private _offsetLeft(offset: number): void;
  64425. /** @hidden */ private _offsetTop(offset: number): void;
  64426. /** @hidden */ private _markMatrixAsDirty(): void;
  64427. /** @hidden */ private _flagDescendantsAsMatrixDirty(): void;
  64428. /** @hidden */ private _intersectsRect(rect: Measure): boolean;
  64429. /** @hidden */
  64430. protected invalidateRect(): void;
  64431. /** @hidden */ private _markAsDirty(force?: boolean): void;
  64432. /** @hidden */ private _markAllAsDirty(): void;
  64433. /** @hidden */ private _link(host: AdvancedDynamicTexture): void;
  64434. /** @hidden */
  64435. protected _transform(context?: CanvasRenderingContext2D): void;
  64436. /** @hidden */ private _renderHighlight(context: CanvasRenderingContext2D): void;
  64437. /** @hidden */ private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  64438. /** @hidden */
  64439. protected _applyStates(context: CanvasRenderingContext2D): void;
  64440. /** @hidden */ private _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  64441. /** @hidden */
  64442. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64443. protected _evaluateClippingState(parentMeasure: Measure): void;
  64444. /** @hidden */ private _measure(): void;
  64445. /** @hidden */
  64446. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64447. /** @hidden */
  64448. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64449. /** @hidden */
  64450. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64451. /** @hidden */
  64452. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  64453. private static _ClipMeasure;
  64454. private _tmpMeasureA;
  64455. private _clip;
  64456. /** @hidden */ private _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  64457. /** @hidden */ private _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  64458. /**
  64459. * Tests if a given coordinates belong to the current control
  64460. * @param x defines x coordinate to test
  64461. * @param y defines y coordinate to test
  64462. * @returns true if the coordinates are inside the control
  64463. */
  64464. contains(x: number, y: number): boolean;
  64465. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64466. /** @hidden */ private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  64467. /** @hidden */ private _onPointerEnter(target: Control): boolean;
  64468. /** @hidden */ private _onPointerOut(target: Control, force?: boolean): void;
  64469. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64470. /** @hidden */ private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64471. /** @hidden */ private _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  64472. /** @hidden */ private _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  64473. private _prepareFont;
  64474. /** Releases associated resources */
  64475. dispose(): void;
  64476. private static _HORIZONTAL_ALIGNMENT_LEFT;
  64477. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  64478. private static _HORIZONTAL_ALIGNMENT_CENTER;
  64479. private static _VERTICAL_ALIGNMENT_TOP;
  64480. private static _VERTICAL_ALIGNMENT_BOTTOM;
  64481. private static _VERTICAL_ALIGNMENT_CENTER;
  64482. /** HORIZONTAL_ALIGNMENT_LEFT */
  64483. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  64484. /** HORIZONTAL_ALIGNMENT_RIGHT */
  64485. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  64486. /** HORIZONTAL_ALIGNMENT_CENTER */
  64487. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  64488. /** VERTICAL_ALIGNMENT_TOP */
  64489. static readonly VERTICAL_ALIGNMENT_TOP: number;
  64490. /** VERTICAL_ALIGNMENT_BOTTOM */
  64491. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  64492. /** VERTICAL_ALIGNMENT_CENTER */
  64493. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  64494. private static _FontHeightSizes;
  64495. /** @hidden */ private static _GetFontOffset(font: string): {
  64496. ascent: number;
  64497. height: number;
  64498. descent: number;
  64499. };
  64500. /**
  64501. * Creates a stack panel that can be used to render headers
  64502. * @param control defines the control to associate with the header
  64503. * @param text defines the text of the header
  64504. * @param size defines the size of the header
  64505. * @param options defines options used to configure the header
  64506. * @returns a new StackPanel
  64507. * @ignore
  64508. * @hidden
  64509. */
  64510. static AddHeader: (control: Control, text: string, size: string | number, options: {
  64511. isHorizontal: boolean;
  64512. controlFirst: boolean;
  64513. }) => any;
  64514. /** @hidden */
  64515. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  64516. }
  64517. }
  64518. declare module BABYLON.GUI {
  64519. /**
  64520. * Root class for 2D containers
  64521. * @see http://doc.babylonjs.com/how_to/gui#containers
  64522. */
  64523. export class Container extends Control {
  64524. name?: string | undefined;
  64525. /** @hidden */
  64526. protected _children: Control[];
  64527. /** @hidden */
  64528. protected _measureForChildren: Measure;
  64529. /** @hidden */
  64530. protected _background: string;
  64531. /** @hidden */
  64532. protected _adaptWidthToChildren: boolean;
  64533. /** @hidden */
  64534. protected _adaptHeightToChildren: boolean;
  64535. /**
  64536. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  64537. */
  64538. logLayoutCycleErrors: boolean;
  64539. /**
  64540. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  64541. */
  64542. maxLayoutCycle: number;
  64543. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  64544. adaptHeightToChildren: boolean;
  64545. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  64546. adaptWidthToChildren: boolean;
  64547. /** Gets or sets background color */
  64548. background: string;
  64549. /** Gets the list of children */
  64550. readonly children: Control[];
  64551. /**
  64552. * Creates a new Container
  64553. * @param name defines the name of the container
  64554. */
  64555. constructor(name?: string | undefined);
  64556. protected _getTypeName(): string; private _flagDescendantsAsMatrixDirty(): void;
  64557. /**
  64558. * Gets a child using its name
  64559. * @param name defines the child name to look for
  64560. * @returns the child control if found
  64561. */
  64562. getChildByName(name: string): BABYLON.Nullable<Control>;
  64563. /**
  64564. * Gets a child using its type and its name
  64565. * @param name defines the child name to look for
  64566. * @param type defines the child type to look for
  64567. * @returns the child control if found
  64568. */
  64569. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  64570. /**
  64571. * Search for a specific control in children
  64572. * @param control defines the control to look for
  64573. * @returns true if the control is in child list
  64574. */
  64575. containsControl(control: Control): boolean;
  64576. /**
  64577. * Adds a new control to the current container
  64578. * @param control defines the control to add
  64579. * @returns the current container
  64580. */
  64581. addControl(control: BABYLON.Nullable<Control>): Container;
  64582. /**
  64583. * Removes all controls from the current container
  64584. * @returns the current container
  64585. */
  64586. clearControls(): Container;
  64587. /**
  64588. * Removes a control from the current container
  64589. * @param control defines the control to remove
  64590. * @returns the current container
  64591. */
  64592. removeControl(control: Control): Container;
  64593. /** @hidden */ private _reOrderControl(control: Control): void;
  64594. /** @hidden */ private _offsetLeft(offset: number): void;
  64595. /** @hidden */ private _offsetTop(offset: number): void;
  64596. /** @hidden */ private _markAllAsDirty(): void;
  64597. /** @hidden */
  64598. protected _localDraw(context: CanvasRenderingContext2D): void;
  64599. /** @hidden */ private _link(host: AdvancedDynamicTexture): void;
  64600. /** @hidden */
  64601. protected _beforeLayout(): void;
  64602. /** @hidden */
  64603. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64604. /** @hidden */ private _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  64605. protected _postMeasure(): void;
  64606. /** @hidden */ private _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  64607. /** @hidden */ private _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  64608. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64609. /** @hidden */
  64610. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64611. /** Releases associated resources */
  64612. dispose(): void;
  64613. }
  64614. }
  64615. declare module BABYLON.GUI {
  64616. /** Class used to create rectangle container */
  64617. export class Rectangle extends Container {
  64618. name?: string | undefined;
  64619. private _thickness;
  64620. private _cornerRadius;
  64621. /** Gets or sets border thickness */
  64622. thickness: number;
  64623. /** Gets or sets the corner radius angle */
  64624. cornerRadius: number;
  64625. /**
  64626. * Creates a new Rectangle
  64627. * @param name defines the control name
  64628. */
  64629. constructor(name?: string | undefined);
  64630. protected _getTypeName(): string;
  64631. protected _localDraw(context: CanvasRenderingContext2D): void;
  64632. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64633. private _drawRoundedRect;
  64634. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  64635. }
  64636. }
  64637. declare module BABYLON.GUI {
  64638. /**
  64639. * Enum that determines the text-wrapping mode to use.
  64640. */
  64641. export enum TextWrapping {
  64642. /**
  64643. * Clip the text when it's larger than Control.width; this is the default mode.
  64644. */
  64645. Clip = 0,
  64646. /**
  64647. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  64648. */
  64649. WordWrap = 1,
  64650. /**
  64651. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  64652. */
  64653. Ellipsis = 2
  64654. }
  64655. /**
  64656. * Class used to create text block control
  64657. */
  64658. export class TextBlock extends Control {
  64659. /**
  64660. * Defines the name of the control
  64661. */
  64662. name?: string | undefined;
  64663. private _text;
  64664. private _textWrapping;
  64665. private _textHorizontalAlignment;
  64666. private _textVerticalAlignment;
  64667. private _lines;
  64668. private _resizeToFit;
  64669. private _lineSpacing;
  64670. private _outlineWidth;
  64671. private _outlineColor;
  64672. /**
  64673. * An event triggered after the text is changed
  64674. */
  64675. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  64676. /**
  64677. * An event triggered after the text was broken up into lines
  64678. */
  64679. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  64680. /**
  64681. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  64682. */
  64683. readonly lines: any[];
  64684. /**
  64685. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  64686. */
  64687. /**
  64688. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  64689. */
  64690. resizeToFit: boolean;
  64691. /**
  64692. * Gets or sets a boolean indicating if text must be wrapped
  64693. */
  64694. /**
  64695. * Gets or sets a boolean indicating if text must be wrapped
  64696. */
  64697. textWrapping: TextWrapping | boolean;
  64698. /**
  64699. * Gets or sets text to display
  64700. */
  64701. /**
  64702. * Gets or sets text to display
  64703. */
  64704. text: string;
  64705. /**
  64706. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  64707. */
  64708. /**
  64709. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  64710. */
  64711. textHorizontalAlignment: number;
  64712. /**
  64713. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  64714. */
  64715. /**
  64716. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  64717. */
  64718. textVerticalAlignment: number;
  64719. /**
  64720. * Gets or sets line spacing value
  64721. */
  64722. /**
  64723. * Gets or sets line spacing value
  64724. */
  64725. lineSpacing: string | number;
  64726. /**
  64727. * Gets or sets outlineWidth of the text to display
  64728. */
  64729. /**
  64730. * Gets or sets outlineWidth of the text to display
  64731. */
  64732. outlineWidth: number;
  64733. /**
  64734. * Gets or sets outlineColor of the text to display
  64735. */
  64736. /**
  64737. * Gets or sets outlineColor of the text to display
  64738. */
  64739. outlineColor: string;
  64740. /**
  64741. * Creates a new TextBlock object
  64742. * @param name defines the name of the control
  64743. * @param text defines the text to display (emptry string by default)
  64744. */
  64745. constructor(
  64746. /**
  64747. * Defines the name of the control
  64748. */
  64749. name?: string | undefined, text?: string);
  64750. protected _getTypeName(): string;
  64751. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64752. private _drawText;
  64753. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  64754. protected _applyStates(context: CanvasRenderingContext2D): void;
  64755. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  64756. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  64757. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  64758. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  64759. protected _renderLines(context: CanvasRenderingContext2D): void;
  64760. /**
  64761. * Given a width constraint applied on the text block, find the expected height
  64762. * @returns expected height
  64763. */
  64764. computeExpectedHeight(): number;
  64765. dispose(): void;
  64766. }
  64767. }
  64768. declare module BABYLON.GUI {
  64769. /**
  64770. * Class used to create 2D images
  64771. */
  64772. export class Image extends Control {
  64773. name?: string | undefined;
  64774. private static _WorkingCanvas;
  64775. private _domImage;
  64776. private _imageWidth;
  64777. private _imageHeight;
  64778. private _loaded;
  64779. private _stretch;
  64780. private _source;
  64781. private _autoScale;
  64782. private _sourceLeft;
  64783. private _sourceTop;
  64784. private _sourceWidth;
  64785. private _sourceHeight;
  64786. private _cellWidth;
  64787. private _cellHeight;
  64788. private _cellId;
  64789. private _populateNinePatchSlicesFromImage;
  64790. private _sliceLeft;
  64791. private _sliceRight;
  64792. private _sliceTop;
  64793. private _sliceBottom;
  64794. private _detectPointerOnOpaqueOnly;
  64795. /**
  64796. * BABYLON.Observable notified when the content is loaded
  64797. */
  64798. onImageLoadedObservable: BABYLON.Observable<Image>;
  64799. /**
  64800. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  64801. */
  64802. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  64803. /**
  64804. * Gets a boolean indicating that the content is loaded
  64805. */
  64806. readonly isLoaded: boolean;
  64807. /**
  64808. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  64809. */
  64810. populateNinePatchSlicesFromImage: boolean;
  64811. /**
  64812. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  64813. * Beware using this as this will comsume more memory as the image has to be stored twice
  64814. */
  64815. detectPointerOnOpaqueOnly: boolean;
  64816. /**
  64817. * Gets or sets the left value for slicing (9-patch)
  64818. */
  64819. sliceLeft: number;
  64820. /**
  64821. * Gets or sets the right value for slicing (9-patch)
  64822. */
  64823. sliceRight: number;
  64824. /**
  64825. * Gets or sets the top value for slicing (9-patch)
  64826. */
  64827. sliceTop: number;
  64828. /**
  64829. * Gets or sets the bottom value for slicing (9-patch)
  64830. */
  64831. sliceBottom: number;
  64832. /**
  64833. * Gets or sets the left coordinate in the source image
  64834. */
  64835. sourceLeft: number;
  64836. /**
  64837. * Gets or sets the top coordinate in the source image
  64838. */
  64839. sourceTop: number;
  64840. /**
  64841. * Gets or sets the width to capture in the source image
  64842. */
  64843. sourceWidth: number;
  64844. /**
  64845. * Gets or sets the height to capture in the source image
  64846. */
  64847. sourceHeight: number;
  64848. /**
  64849. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  64850. * @see http://doc.babylonjs.com/how_to/gui#image
  64851. */
  64852. autoScale: boolean;
  64853. /** Gets or sets the streching mode used by the image */
  64854. stretch: number;
  64855. /**
  64856. * Gets or sets the internal DOM image used to render the control
  64857. */
  64858. domImage: HTMLImageElement;
  64859. private _onImageLoaded;
  64860. private _extractNinePatchSliceDataFromImage;
  64861. /**
  64862. * Gets or sets image source url
  64863. */
  64864. source: BABYLON.Nullable<string>;
  64865. /**
  64866. * Checks for svg document with icon id present
  64867. */
  64868. private _svgCheck;
  64869. /**
  64870. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  64871. * given external svg file and icon id
  64872. */
  64873. private _getSVGAttribs;
  64874. /**
  64875. * Gets or sets the cell width to use when animation sheet is enabled
  64876. * @see http://doc.babylonjs.com/how_to/gui#image
  64877. */
  64878. cellWidth: number;
  64879. /**
  64880. * Gets or sets the cell height to use when animation sheet is enabled
  64881. * @see http://doc.babylonjs.com/how_to/gui#image
  64882. */
  64883. cellHeight: number;
  64884. /**
  64885. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  64886. * @see http://doc.babylonjs.com/how_to/gui#image
  64887. */
  64888. cellId: number;
  64889. /**
  64890. * Creates a new Image
  64891. * @param name defines the control name
  64892. * @param url defines the image url
  64893. */
  64894. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  64895. /**
  64896. * Tests if a given coordinates belong to the current control
  64897. * @param x defines x coordinate to test
  64898. * @param y defines y coordinate to test
  64899. * @returns true if the coordinates are inside the control
  64900. */
  64901. contains(x: number, y: number): boolean;
  64902. protected _getTypeName(): string;
  64903. /** Force the control to synchronize with its content */
  64904. synchronizeSizeWithContent(): void;
  64905. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64906. private _prepareWorkingCanvasForOpaqueDetection;
  64907. private _drawImage; private _draw(context: CanvasRenderingContext2D): void;
  64908. private _renderCornerPatch;
  64909. private _renderNinePatch;
  64910. dispose(): void;
  64911. /** STRETCH_NONE */
  64912. static readonly STRETCH_NONE: number;
  64913. /** STRETCH_FILL */
  64914. static readonly STRETCH_FILL: number;
  64915. /** STRETCH_UNIFORM */
  64916. static readonly STRETCH_UNIFORM: number;
  64917. /** STRETCH_EXTEND */
  64918. static readonly STRETCH_EXTEND: number;
  64919. /** NINE_PATCH */
  64920. static readonly STRETCH_NINE_PATCH: number;
  64921. }
  64922. }
  64923. declare module BABYLON.GUI {
  64924. /**
  64925. * Class used to create 2D buttons
  64926. */
  64927. export class Button extends Rectangle {
  64928. name?: string | undefined;
  64929. /**
  64930. * Function called to generate a pointer enter animation
  64931. */
  64932. pointerEnterAnimation: () => void;
  64933. /**
  64934. * Function called to generate a pointer out animation
  64935. */
  64936. pointerOutAnimation: () => void;
  64937. /**
  64938. * Function called to generate a pointer down animation
  64939. */
  64940. pointerDownAnimation: () => void;
  64941. /**
  64942. * Function called to generate a pointer up animation
  64943. */
  64944. pointerUpAnimation: () => void;
  64945. /**
  64946. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  64947. */
  64948. delegatePickingToChildren: boolean;
  64949. private _image;
  64950. /**
  64951. * Returns the image part of the button (if any)
  64952. */
  64953. readonly image: BABYLON.Nullable<Image>;
  64954. private _textBlock;
  64955. /**
  64956. * Returns the image part of the button (if any)
  64957. */
  64958. readonly textBlock: BABYLON.Nullable<TextBlock>;
  64959. /**
  64960. * Creates a new Button
  64961. * @param name defines the name of the button
  64962. */
  64963. constructor(name?: string | undefined);
  64964. protected _getTypeName(): string;
  64965. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64966. /** @hidden */ private _onPointerEnter(target: Control): boolean;
  64967. /** @hidden */ private _onPointerOut(target: Control, force?: boolean): void;
  64968. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64969. /** @hidden */ private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64970. /**
  64971. * Creates a new button made with an image and a text
  64972. * @param name defines the name of the button
  64973. * @param text defines the text of the button
  64974. * @param imageUrl defines the url of the image
  64975. * @returns a new Button
  64976. */
  64977. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  64978. /**
  64979. * Creates a new button made with an image
  64980. * @param name defines the name of the button
  64981. * @param imageUrl defines the url of the image
  64982. * @returns a new Button
  64983. */
  64984. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  64985. /**
  64986. * Creates a new button made with a text
  64987. * @param name defines the name of the button
  64988. * @param text defines the text of the button
  64989. * @returns a new Button
  64990. */
  64991. static CreateSimpleButton(name: string, text: string): Button;
  64992. /**
  64993. * Creates a new button made with an image and a centered text
  64994. * @param name defines the name of the button
  64995. * @param text defines the text of the button
  64996. * @param imageUrl defines the url of the image
  64997. * @returns a new Button
  64998. */
  64999. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  65000. }
  65001. }
  65002. declare module BABYLON.GUI {
  65003. /**
  65004. * Class used to create a 2D stack panel container
  65005. */
  65006. export class StackPanel extends Container {
  65007. name?: string | undefined;
  65008. private _isVertical;
  65009. private _manualWidth;
  65010. private _manualHeight;
  65011. private _doNotTrackManualChanges;
  65012. /**
  65013. * Gets or sets a boolean indicating that layou warnings should be ignored
  65014. */
  65015. ignoreLayoutWarnings: boolean;
  65016. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  65017. isVertical: boolean;
  65018. /**
  65019. * Gets or sets panel width.
  65020. * This value should not be set when in horizontal mode as it will be computed automatically
  65021. */
  65022. width: string | number;
  65023. /**
  65024. * Gets or sets panel height.
  65025. * This value should not be set when in vertical mode as it will be computed automatically
  65026. */
  65027. height: string | number;
  65028. /**
  65029. * Creates a new StackPanel
  65030. * @param name defines control name
  65031. */
  65032. constructor(name?: string | undefined);
  65033. protected _getTypeName(): string;
  65034. /** @hidden */
  65035. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65036. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65037. protected _postMeasure(): void;
  65038. }
  65039. }
  65040. declare module BABYLON.GUI {
  65041. /**
  65042. * Class used to represent a 2D checkbox
  65043. */
  65044. export class Checkbox extends Control {
  65045. name?: string | undefined;
  65046. private _isChecked;
  65047. private _background;
  65048. private _checkSizeRatio;
  65049. private _thickness;
  65050. /** Gets or sets border thickness */
  65051. thickness: number;
  65052. /**
  65053. * BABYLON.Observable raised when isChecked property changes
  65054. */
  65055. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  65056. /** Gets or sets a value indicating the ratio between overall size and check size */
  65057. checkSizeRatio: number;
  65058. /** Gets or sets background color */
  65059. background: string;
  65060. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  65061. isChecked: boolean;
  65062. /**
  65063. * Creates a new CheckBox
  65064. * @param name defines the control name
  65065. */
  65066. constructor(name?: string | undefined);
  65067. protected _getTypeName(): string;
  65068. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  65069. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65070. /**
  65071. * Utility function to easily create a checkbox with a header
  65072. * @param title defines the label to use for the header
  65073. * @param onValueChanged defines the callback to call when value changes
  65074. * @returns a StackPanel containing the checkbox and a textBlock
  65075. */
  65076. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  65077. }
  65078. }
  65079. declare module BABYLON.GUI {
  65080. /**
  65081. * Class used to store key control properties
  65082. */
  65083. export class KeyPropertySet {
  65084. /** Width */
  65085. width?: string;
  65086. /** Height */
  65087. height?: string;
  65088. /** Left padding */
  65089. paddingLeft?: string;
  65090. /** Right padding */
  65091. paddingRight?: string;
  65092. /** Top padding */
  65093. paddingTop?: string;
  65094. /** Bottom padding */
  65095. paddingBottom?: string;
  65096. /** Foreground color */
  65097. color?: string;
  65098. /** Background color */
  65099. background?: string;
  65100. }
  65101. /**
  65102. * Class used to create virtual keyboard
  65103. */
  65104. export class VirtualKeyboard extends StackPanel {
  65105. /** BABYLON.Observable raised when a key is pressed */
  65106. onKeyPressObservable: BABYLON.Observable<string>;
  65107. /** Gets or sets default key button width */
  65108. defaultButtonWidth: string;
  65109. /** Gets or sets default key button height */
  65110. defaultButtonHeight: string;
  65111. /** Gets or sets default key button left padding */
  65112. defaultButtonPaddingLeft: string;
  65113. /** Gets or sets default key button right padding */
  65114. defaultButtonPaddingRight: string;
  65115. /** Gets or sets default key button top padding */
  65116. defaultButtonPaddingTop: string;
  65117. /** Gets or sets default key button bottom padding */
  65118. defaultButtonPaddingBottom: string;
  65119. /** Gets or sets default key button foreground color */
  65120. defaultButtonColor: string;
  65121. /** Gets or sets default key button background color */
  65122. defaultButtonBackground: string;
  65123. /** Gets or sets shift button foreground color */
  65124. shiftButtonColor: string;
  65125. /** Gets or sets shift button thickness*/
  65126. selectedShiftThickness: number;
  65127. /** Gets shift key state */
  65128. shiftState: number;
  65129. protected _getTypeName(): string;
  65130. private _createKey;
  65131. /**
  65132. * Adds a new row of keys
  65133. * @param keys defines the list of keys to add
  65134. * @param propertySets defines the associated property sets
  65135. */
  65136. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  65137. /**
  65138. * Set the shift key to a specific state
  65139. * @param shiftState defines the new shift state
  65140. */
  65141. applyShiftState(shiftState: number): void;
  65142. private _currentlyConnectedInputText;
  65143. private _connectedInputTexts;
  65144. private _onKeyPressObserver;
  65145. /** Gets the input text control currently attached to the keyboard */
  65146. readonly connectedInputText: BABYLON.Nullable<InputText>;
  65147. /**
  65148. * Connects the keyboard with an input text control
  65149. *
  65150. * @param input defines the target control
  65151. */
  65152. connect(input: InputText): void;
  65153. /**
  65154. * Disconnects the keyboard from connected InputText controls
  65155. *
  65156. * @param input optionally defines a target control, otherwise all are disconnected
  65157. */
  65158. disconnect(input?: InputText): void;
  65159. private _removeConnectedInputObservables;
  65160. /**
  65161. * Release all resources
  65162. */
  65163. dispose(): void;
  65164. /**
  65165. * Creates a new keyboard using a default layout
  65166. *
  65167. * @param name defines control name
  65168. * @returns a new VirtualKeyboard
  65169. */
  65170. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  65171. }
  65172. }
  65173. declare module BABYLON.GUI {
  65174. /**
  65175. * Class used to create input text control
  65176. */
  65177. export class InputText extends Control implements IFocusableControl {
  65178. name?: string | undefined;
  65179. private _text;
  65180. private _placeholderText;
  65181. private _background;
  65182. private _focusedBackground;
  65183. private _focusedColor;
  65184. private _placeholderColor;
  65185. private _thickness;
  65186. private _margin;
  65187. private _autoStretchWidth;
  65188. private _maxWidth;
  65189. private _isFocused;
  65190. private _blinkTimeout;
  65191. private _blinkIsEven;
  65192. private _cursorOffset;
  65193. private _scrollLeft;
  65194. private _textWidth;
  65195. private _clickedCoordinate;
  65196. private _deadKey;
  65197. private _addKey;
  65198. private _currentKey;
  65199. private _isTextHighlightOn;
  65200. private _textHighlightColor;
  65201. private _highligherOpacity;
  65202. private _highlightedText;
  65203. private _startHighlightIndex;
  65204. private _endHighlightIndex;
  65205. private _cursorIndex;
  65206. private _onFocusSelectAll;
  65207. private _isPointerDown;
  65208. private _onClipboardObserver;
  65209. private _onPointerDblTapObserver;
  65210. /** @hidden */ private _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  65211. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  65212. promptMessage: string;
  65213. /** Force disable prompt on mobile device */
  65214. disableMobilePrompt: boolean;
  65215. /** BABYLON.Observable raised when the text changes */
  65216. onTextChangedObservable: BABYLON.Observable<InputText>;
  65217. /** BABYLON.Observable raised just before an entered character is to be added */
  65218. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  65219. /** BABYLON.Observable raised when the control gets the focus */
  65220. onFocusObservable: BABYLON.Observable<InputText>;
  65221. /** BABYLON.Observable raised when the control loses the focus */
  65222. onBlurObservable: BABYLON.Observable<InputText>;
  65223. /**Observable raised when the text is highlighted */
  65224. onTextHighlightObservable: BABYLON.Observable<InputText>;
  65225. /**Observable raised when copy event is triggered */
  65226. onTextCopyObservable: BABYLON.Observable<InputText>;
  65227. /** BABYLON.Observable raised when cut event is triggered */
  65228. onTextCutObservable: BABYLON.Observable<InputText>;
  65229. /** BABYLON.Observable raised when paste event is triggered */
  65230. onTextPasteObservable: BABYLON.Observable<InputText>;
  65231. /** BABYLON.Observable raised when a key event was processed */
  65232. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  65233. /** Gets or sets the maximum width allowed by the control */
  65234. maxWidth: string | number;
  65235. /** Gets the maximum width allowed by the control in pixels */
  65236. readonly maxWidthInPixels: number;
  65237. /** Gets or sets the text highlighter transparency; default: 0.4 */
  65238. highligherOpacity: number;
  65239. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  65240. onFocusSelectAll: boolean;
  65241. /** Gets or sets the text hightlight color */
  65242. textHighlightColor: string;
  65243. /** Gets or sets control margin */
  65244. margin: string;
  65245. /** Gets control margin in pixels */
  65246. readonly marginInPixels: number;
  65247. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  65248. autoStretchWidth: boolean;
  65249. /** Gets or sets border thickness */
  65250. thickness: number;
  65251. /** Gets or sets the background color when focused */
  65252. focusedBackground: string;
  65253. /** Gets or sets the background color when focused */
  65254. focusedColor: string;
  65255. /** Gets or sets the background color */
  65256. background: string;
  65257. /** Gets or sets the placeholder color */
  65258. placeholderColor: string;
  65259. /** Gets or sets the text displayed when the control is empty */
  65260. placeholderText: string;
  65261. /** Gets or sets the dead key flag */
  65262. deadKey: boolean;
  65263. /** Gets or sets the highlight text */
  65264. highlightedText: string;
  65265. /** Gets or sets if the current key should be added */
  65266. addKey: boolean;
  65267. /** Gets or sets the value of the current key being entered */
  65268. currentKey: string;
  65269. /** Gets or sets the text displayed in the control */
  65270. text: string;
  65271. /** Gets or sets control width */
  65272. width: string | number;
  65273. /**
  65274. * Creates a new InputText
  65275. * @param name defines the control name
  65276. * @param text defines the text of the control
  65277. */
  65278. constructor(name?: string | undefined, text?: string);
  65279. /** @hidden */
  65280. onBlur(): void;
  65281. /** @hidden */
  65282. onFocus(): void;
  65283. protected _getTypeName(): string;
  65284. /**
  65285. * Function called to get the list of controls that should not steal the focus from this control
  65286. * @returns an array of controls
  65287. */
  65288. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  65289. /** @hidden */
  65290. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  65291. /** @hidden */
  65292. private _updateValueFromCursorIndex;
  65293. /** @hidden */
  65294. private _processDblClick;
  65295. /** @hidden */
  65296. private _selectAllText;
  65297. /**
  65298. * Handles the keyboard event
  65299. * @param evt Defines the KeyboardEvent
  65300. */
  65301. processKeyboard(evt: KeyboardEvent): void;
  65302. /** @hidden */
  65303. private _onCopyText;
  65304. /** @hidden */
  65305. private _onCutText;
  65306. /** @hidden */
  65307. private _onPasteText; private _draw(context: CanvasRenderingContext2D): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void; private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65308. protected _beforeRenderText(text: string): string;
  65309. dispose(): void;
  65310. }
  65311. }
  65312. declare module BABYLON.GUI {
  65313. /**
  65314. * Class used to create a 2D grid container
  65315. */
  65316. export class Grid extends Container {
  65317. name?: string | undefined;
  65318. private _rowDefinitions;
  65319. private _columnDefinitions;
  65320. private _cells;
  65321. private _childControls;
  65322. /**
  65323. * Gets the number of columns
  65324. */
  65325. readonly columnCount: number;
  65326. /**
  65327. * Gets the number of rows
  65328. */
  65329. readonly rowCount: number;
  65330. /** Gets the list of children */
  65331. readonly children: Control[];
  65332. /** Gets the list of cells (e.g. the containers) */
  65333. readonly cells: {
  65334. [key: string]: Container;
  65335. };
  65336. /**
  65337. * Gets the definition of a specific row
  65338. * @param index defines the index of the row
  65339. * @returns the row definition
  65340. */
  65341. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  65342. /**
  65343. * Gets the definition of a specific column
  65344. * @param index defines the index of the column
  65345. * @returns the column definition
  65346. */
  65347. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  65348. /**
  65349. * Adds a new row to the grid
  65350. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  65351. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  65352. * @returns the current grid
  65353. */
  65354. addRowDefinition(height: number, isPixel?: boolean): Grid;
  65355. /**
  65356. * Adds a new column to the grid
  65357. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  65358. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  65359. * @returns the current grid
  65360. */
  65361. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  65362. /**
  65363. * Update a row definition
  65364. * @param index defines the index of the row to update
  65365. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  65366. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  65367. * @returns the current grid
  65368. */
  65369. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  65370. /**
  65371. * Update a column definition
  65372. * @param index defines the index of the column to update
  65373. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  65374. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  65375. * @returns the current grid
  65376. */
  65377. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  65378. /**
  65379. * Gets the list of children stored in a specific cell
  65380. * @param row defines the row to check
  65381. * @param column defines the column to check
  65382. * @returns the list of controls
  65383. */
  65384. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  65385. /**
  65386. * Gets a string representing the child cell info (row x column)
  65387. * @param child defines the control to get info from
  65388. * @returns a string containing the child cell info (row x column)
  65389. */
  65390. getChildCellInfo(child: Control): string;
  65391. private _removeCell;
  65392. private _offsetCell;
  65393. /**
  65394. * Remove a column definition at specified index
  65395. * @param index defines the index of the column to remove
  65396. * @returns the current grid
  65397. */
  65398. removeColumnDefinition(index: number): Grid;
  65399. /**
  65400. * Remove a row definition at specified index
  65401. * @param index defines the index of the row to remove
  65402. * @returns the current grid
  65403. */
  65404. removeRowDefinition(index: number): Grid;
  65405. /**
  65406. * Adds a new control to the current grid
  65407. * @param control defines the control to add
  65408. * @param row defines the row where to add the control (0 by default)
  65409. * @param column defines the column where to add the control (0 by default)
  65410. * @returns the current grid
  65411. */
  65412. addControl(control: Control, row?: number, column?: number): Grid;
  65413. /**
  65414. * Removes a control from the current container
  65415. * @param control defines the control to remove
  65416. * @returns the current container
  65417. */
  65418. removeControl(control: Control): Container;
  65419. /**
  65420. * Creates a new Grid
  65421. * @param name defines control name
  65422. */
  65423. constructor(name?: string | undefined);
  65424. protected _getTypeName(): string;
  65425. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  65426. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; private _flagDescendantsAsMatrixDirty(): void; private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  65427. /** Releases associated resources */
  65428. dispose(): void;
  65429. }
  65430. }
  65431. declare module BABYLON.GUI {
  65432. /** Class used to create color pickers */
  65433. export class ColorPicker extends Control {
  65434. name?: string | undefined;
  65435. private static _Epsilon;
  65436. private _colorWheelCanvas;
  65437. private _value;
  65438. private _tmpColor;
  65439. private _pointerStartedOnSquare;
  65440. private _pointerStartedOnWheel;
  65441. private _squareLeft;
  65442. private _squareTop;
  65443. private _squareSize;
  65444. private _h;
  65445. private _s;
  65446. private _v;
  65447. private _lastPointerDownID;
  65448. /**
  65449. * BABYLON.Observable raised when the value changes
  65450. */
  65451. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  65452. /** Gets or sets the color of the color picker */
  65453. value: BABYLON.Color3;
  65454. /**
  65455. * Gets or sets control width
  65456. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65457. */
  65458. width: string | number;
  65459. /**
  65460. * Gets or sets control height
  65461. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65462. */
  65463. /** Gets or sets control height */
  65464. height: string | number;
  65465. /** Gets or sets control size */
  65466. size: string | number;
  65467. /**
  65468. * Creates a new ColorPicker
  65469. * @param name defines the control name
  65470. */
  65471. constructor(name?: string | undefined);
  65472. protected _getTypeName(): string;
  65473. /** @hidden */
  65474. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65475. private _updateSquareProps;
  65476. private _drawGradientSquare;
  65477. private _drawCircle;
  65478. private _createColorWheelCanvas;
  65479. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  65480. private _pointerIsDown;
  65481. private _updateValueFromPointer;
  65482. private _isPointOnSquare;
  65483. private _isPointOnWheel; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void; private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65484. /**
  65485. * This function expands the color picker by creating a color picker dialog with manual
  65486. * color value input and the ability to save colors into an array to be used later in
  65487. * subsequent launches of the dialogue.
  65488. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  65489. * @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.
  65490. * @returns picked color as a hex string and the saved colors array as hex strings.
  65491. */
  65492. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  65493. pickerWidth?: string;
  65494. pickerHeight?: string;
  65495. headerHeight?: string;
  65496. lastColor?: string;
  65497. swatchLimit?: number;
  65498. numSwatchesPerLine?: number;
  65499. savedColors?: Array<string>;
  65500. }): Promise<{
  65501. savedColors?: string[];
  65502. pickedColor: string;
  65503. }>;
  65504. }
  65505. }
  65506. declare module BABYLON.GUI {
  65507. /** Class used to create 2D ellipse containers */
  65508. export class Ellipse extends Container {
  65509. name?: string | undefined;
  65510. private _thickness;
  65511. /** Gets or sets border thickness */
  65512. thickness: number;
  65513. /**
  65514. * Creates a new Ellipse
  65515. * @param name defines the control name
  65516. */
  65517. constructor(name?: string | undefined);
  65518. protected _getTypeName(): string;
  65519. protected _localDraw(context: CanvasRenderingContext2D): void;
  65520. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65521. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  65522. }
  65523. }
  65524. declare module BABYLON.GUI {
  65525. /**
  65526. * Class used to create a password control
  65527. */
  65528. export class InputPassword extends InputText {
  65529. protected _beforeRenderText(text: string): string;
  65530. }
  65531. }
  65532. declare module BABYLON.GUI {
  65533. /** Class used to render 2D lines */
  65534. export class Line extends Control {
  65535. name?: string | undefined;
  65536. private _lineWidth;
  65537. private _x1;
  65538. private _y1;
  65539. private _x2;
  65540. private _y2;
  65541. private _dash;
  65542. private _connectedControl;
  65543. private _connectedControlDirtyObserver;
  65544. /** Gets or sets the dash pattern */
  65545. dash: Array<number>;
  65546. /** Gets or sets the control connected with the line end */
  65547. connectedControl: Control;
  65548. /** Gets or sets start coordinates on X axis */
  65549. x1: string | number;
  65550. /** Gets or sets start coordinates on Y axis */
  65551. y1: string | number;
  65552. /** Gets or sets end coordinates on X axis */
  65553. x2: string | number;
  65554. /** Gets or sets end coordinates on Y axis */
  65555. y2: string | number;
  65556. /** Gets or sets line width */
  65557. lineWidth: number;
  65558. /** Gets or sets horizontal alignment */
  65559. horizontalAlignment: number;
  65560. /** Gets or sets vertical alignment */
  65561. verticalAlignment: number;
  65562. private readonly _effectiveX2;
  65563. private readonly _effectiveY2;
  65564. /**
  65565. * Creates a new Line
  65566. * @param name defines the control name
  65567. */
  65568. constructor(name?: string | undefined);
  65569. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void; private _measure(): void;
  65570. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65571. /**
  65572. * Move one end of the line given 3D cartesian coordinates.
  65573. * @param position Targeted world position
  65574. * @param scene BABYLON.Scene
  65575. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  65576. */
  65577. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  65578. /**
  65579. * Move one end of the line to a position in screen absolute space.
  65580. * @param projectedPosition Position in screen absolute space (X, Y)
  65581. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  65582. */ private _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  65583. }
  65584. }
  65585. declare module BABYLON.GUI {
  65586. /**
  65587. * Class used to store a point for a MultiLine object.
  65588. * The point can be pure 2D coordinates, a mesh or a control
  65589. */
  65590. export class MultiLinePoint {
  65591. private _multiLine;
  65592. private _x;
  65593. private _y;
  65594. private _control;
  65595. private _mesh;
  65596. private _controlObserver;
  65597. private _meshObserver;
  65598. /** @hidden */ private _point: BABYLON.Vector2;
  65599. /**
  65600. * Creates a new MultiLinePoint
  65601. * @param multiLine defines the source MultiLine object
  65602. */
  65603. constructor(multiLine: MultiLine);
  65604. /** Gets or sets x coordinate */
  65605. x: string | number;
  65606. /** Gets or sets y coordinate */
  65607. y: string | number;
  65608. /** Gets or sets the control associated with this point */
  65609. control: BABYLON.Nullable<Control>;
  65610. /** Gets or sets the mesh associated with this point */
  65611. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65612. /** Resets links */
  65613. resetLinks(): void;
  65614. /**
  65615. * Gets a translation vector
  65616. * @returns the translation vector
  65617. */
  65618. translate(): BABYLON.Vector2;
  65619. private _translatePoint;
  65620. /** Release associated resources */
  65621. dispose(): void;
  65622. }
  65623. }
  65624. declare module BABYLON.GUI {
  65625. /**
  65626. * Class used to create multi line control
  65627. */
  65628. export class MultiLine extends Control {
  65629. name?: string | undefined;
  65630. private _lineWidth;
  65631. private _dash;
  65632. private _points;
  65633. private _minX;
  65634. private _minY;
  65635. private _maxX;
  65636. private _maxY;
  65637. /**
  65638. * Creates a new MultiLine
  65639. * @param name defines the control name
  65640. */
  65641. constructor(name?: string | undefined);
  65642. /** Gets or sets dash pattern */
  65643. dash: Array<number>;
  65644. /**
  65645. * Gets point stored at specified index
  65646. * @param index defines the index to look for
  65647. * @returns the requested point if found
  65648. */
  65649. getAt(index: number): MultiLinePoint;
  65650. /** Function called when a point is updated */
  65651. onPointUpdate: () => void;
  65652. /**
  65653. * Adds new points to the point collection
  65654. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  65655. * @returns the list of created MultiLinePoint
  65656. */
  65657. add(...items: (AbstractMesh | Control | {
  65658. x: string | number;
  65659. y: string | number;
  65660. })[]): MultiLinePoint[];
  65661. /**
  65662. * Adds a new point to the point collection
  65663. * @param item defines the item (mesh, control or 2d coordiantes) to add
  65664. * @returns the created MultiLinePoint
  65665. */
  65666. push(item?: (AbstractMesh | Control | {
  65667. x: string | number;
  65668. y: string | number;
  65669. })): MultiLinePoint;
  65670. /**
  65671. * Remove a specific value or point from the active point collection
  65672. * @param value defines the value or point to remove
  65673. */
  65674. remove(value: number | MultiLinePoint): void;
  65675. /**
  65676. * Resets this object to initial state (no point)
  65677. */
  65678. reset(): void;
  65679. /**
  65680. * Resets all links
  65681. */
  65682. resetLinks(): void;
  65683. /** Gets or sets line width */
  65684. lineWidth: number;
  65685. horizontalAlignment: number;
  65686. verticalAlignment: number;
  65687. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  65688. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; private _measure(): void;
  65689. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65690. dispose(): void;
  65691. }
  65692. }
  65693. declare module BABYLON.GUI {
  65694. /**
  65695. * Class used to create radio button controls
  65696. */
  65697. export class RadioButton extends Control {
  65698. name?: string | undefined;
  65699. private _isChecked;
  65700. private _background;
  65701. private _checkSizeRatio;
  65702. private _thickness;
  65703. /** Gets or sets border thickness */
  65704. thickness: number;
  65705. /** Gets or sets group name */
  65706. group: string;
  65707. /** BABYLON.Observable raised when isChecked is changed */
  65708. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  65709. /** Gets or sets a value indicating the ratio between overall size and check size */
  65710. checkSizeRatio: number;
  65711. /** Gets or sets background color */
  65712. background: string;
  65713. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  65714. isChecked: boolean;
  65715. /**
  65716. * Creates a new RadioButton
  65717. * @param name defines the control name
  65718. */
  65719. constructor(name?: string | undefined);
  65720. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65721. /**
  65722. * Utility function to easily create a radio button with a header
  65723. * @param title defines the label to use for the header
  65724. * @param group defines the group to use for the radio button
  65725. * @param isChecked defines the initial state of the radio button
  65726. * @param onValueChanged defines the callback to call when value changes
  65727. * @returns a StackPanel containing the radio button and a textBlock
  65728. */
  65729. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  65730. }
  65731. }
  65732. declare module BABYLON.GUI {
  65733. /**
  65734. * Class used to create slider controls
  65735. */
  65736. export class BaseSlider extends Control {
  65737. name?: string | undefined;
  65738. protected _thumbWidth: ValueAndUnit;
  65739. private _minimum;
  65740. private _maximum;
  65741. private _value;
  65742. private _isVertical;
  65743. protected _barOffset: ValueAndUnit;
  65744. private _isThumbClamped;
  65745. protected _displayThumb: boolean;
  65746. private _step;
  65747. private _lastPointerDownID;
  65748. protected _effectiveBarOffset: number;
  65749. protected _renderLeft: number;
  65750. protected _renderTop: number;
  65751. protected _renderWidth: number;
  65752. protected _renderHeight: number;
  65753. protected _backgroundBoxLength: number;
  65754. protected _backgroundBoxThickness: number;
  65755. protected _effectiveThumbThickness: number;
  65756. /** BABYLON.Observable raised when the sldier value changes */
  65757. onValueChangedObservable: BABYLON.Observable<number>;
  65758. /** Gets or sets a boolean indicating if the thumb must be rendered */
  65759. displayThumb: boolean;
  65760. /** Gets or sets a step to apply to values (0 by default) */
  65761. step: number;
  65762. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  65763. barOffset: string | number;
  65764. /** Gets main bar offset in pixels*/
  65765. readonly barOffsetInPixels: number;
  65766. /** Gets or sets thumb width */
  65767. thumbWidth: string | number;
  65768. /** Gets thumb width in pixels */
  65769. readonly thumbWidthInPixels: number;
  65770. /** Gets or sets minimum value */
  65771. minimum: number;
  65772. /** Gets or sets maximum value */
  65773. maximum: number;
  65774. /** Gets or sets current value */
  65775. value: number;
  65776. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  65777. isVertical: boolean;
  65778. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  65779. isThumbClamped: boolean;
  65780. /**
  65781. * Creates a new BaseSlider
  65782. * @param name defines the control name
  65783. */
  65784. constructor(name?: string | undefined);
  65785. protected _getTypeName(): string;
  65786. protected _getThumbPosition(): number;
  65787. protected _getThumbThickness(type: string): number;
  65788. protected _prepareRenderingData(type: string): void;
  65789. private _pointerIsDown;
  65790. /** @hidden */
  65791. protected _updateValueFromPointer(x: number, y: number): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void; private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65792. }
  65793. }
  65794. declare module BABYLON.GUI {
  65795. /**
  65796. * Class used to create slider controls
  65797. */
  65798. export class Slider extends BaseSlider {
  65799. name?: string | undefined;
  65800. private _background;
  65801. private _borderColor;
  65802. private _isThumbCircle;
  65803. protected _displayValueBar: boolean;
  65804. /** Gets or sets a boolean indicating if the value bar must be rendered */
  65805. displayValueBar: boolean;
  65806. /** Gets or sets border color */
  65807. borderColor: string;
  65808. /** Gets or sets background color */
  65809. background: string;
  65810. /** Gets or sets a boolean indicating if the thumb should be round or square */
  65811. isThumbCircle: boolean;
  65812. /**
  65813. * Creates a new Slider
  65814. * @param name defines the control name
  65815. */
  65816. constructor(name?: string | undefined);
  65817. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  65818. }
  65819. }
  65820. declare module BABYLON.GUI {
  65821. /** Class used to create a RadioGroup
  65822. * which contains groups of radio buttons
  65823. */
  65824. export class SelectorGroup {
  65825. /** name of SelectorGroup */
  65826. name: string;
  65827. private _groupPanel;
  65828. private _selectors;
  65829. private _groupHeader;
  65830. /**
  65831. * Creates a new SelectorGroup
  65832. * @param name of group, used as a group heading
  65833. */
  65834. constructor(
  65835. /** name of SelectorGroup */
  65836. name: string);
  65837. /** Gets the groupPanel of the SelectorGroup */
  65838. readonly groupPanel: StackPanel;
  65839. /** Gets the selectors array */
  65840. readonly selectors: StackPanel[];
  65841. /** Gets and sets the group header */
  65842. header: string;
  65843. /** @hidden */
  65844. private _addGroupHeader;
  65845. /** @hidden*/ private _getSelector(selectorNb: number): StackPanel | undefined;
  65846. /** Removes the selector at the given position
  65847. * @param selectorNb the position of the selector within the group
  65848. */
  65849. removeSelector(selectorNb: number): void;
  65850. }
  65851. /** Class used to create a CheckboxGroup
  65852. * which contains groups of checkbox buttons
  65853. */
  65854. export class CheckboxGroup extends SelectorGroup {
  65855. /** Adds a checkbox as a control
  65856. * @param text is the label for the selector
  65857. * @param func is the function called when the Selector is checked
  65858. * @param checked is true when Selector is checked
  65859. */
  65860. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  65861. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  65862. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  65863. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  65864. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  65865. }
  65866. /** Class used to create a RadioGroup
  65867. * which contains groups of radio buttons
  65868. */
  65869. export class RadioGroup extends SelectorGroup {
  65870. private _selectNb;
  65871. /** Adds a radio button as a control
  65872. * @param label is the label for the selector
  65873. * @param func is the function called when the Selector is checked
  65874. * @param checked is true when Selector is checked
  65875. */
  65876. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  65877. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  65878. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  65879. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  65880. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  65881. }
  65882. /** Class used to create a SliderGroup
  65883. * which contains groups of slider buttons
  65884. */
  65885. export class SliderGroup extends SelectorGroup {
  65886. /**
  65887. * Adds a slider to the SelectorGroup
  65888. * @param label is the label for the SliderBar
  65889. * @param func is the function called when the Slider moves
  65890. * @param unit is a string describing the units used, eg degrees or metres
  65891. * @param min is the minimum value for the Slider
  65892. * @param max is the maximum value for the Slider
  65893. * @param value is the start value for the Slider between min and max
  65894. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  65895. */
  65896. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  65897. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  65898. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  65899. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  65900. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  65901. }
  65902. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  65903. * @see http://doc.babylonjs.com/how_to/selector
  65904. */
  65905. export class SelectionPanel extends Rectangle {
  65906. /** name of SelectionPanel */
  65907. name: string;
  65908. /** an array of SelectionGroups */
  65909. groups: SelectorGroup[];
  65910. private _panel;
  65911. private _buttonColor;
  65912. private _buttonBackground;
  65913. private _headerColor;
  65914. private _barColor;
  65915. private _barHeight;
  65916. private _spacerHeight;
  65917. private _labelColor;
  65918. private _groups;
  65919. private _bars;
  65920. /**
  65921. * Creates a new SelectionPanel
  65922. * @param name of SelectionPanel
  65923. * @param groups is an array of SelectionGroups
  65924. */
  65925. constructor(
  65926. /** name of SelectionPanel */
  65927. name: string,
  65928. /** an array of SelectionGroups */
  65929. groups?: SelectorGroup[]);
  65930. protected _getTypeName(): string;
  65931. /** Gets or sets the headerColor */
  65932. headerColor: string;
  65933. private _setHeaderColor;
  65934. /** Gets or sets the button color */
  65935. buttonColor: string;
  65936. private _setbuttonColor;
  65937. /** Gets or sets the label color */
  65938. labelColor: string;
  65939. private _setLabelColor;
  65940. /** Gets or sets the button background */
  65941. buttonBackground: string;
  65942. private _setButtonBackground;
  65943. /** Gets or sets the color of separator bar */
  65944. barColor: string;
  65945. private _setBarColor;
  65946. /** Gets or sets the height of separator bar */
  65947. barHeight: string;
  65948. private _setBarHeight;
  65949. /** Gets or sets the height of spacers*/
  65950. spacerHeight: string;
  65951. private _setSpacerHeight;
  65952. /** Adds a bar between groups */
  65953. private _addSpacer;
  65954. /** Add a group to the selection panel
  65955. * @param group is the selector group to add
  65956. */
  65957. addGroup(group: SelectorGroup): void;
  65958. /** Remove the group from the given position
  65959. * @param groupNb is the position of the group in the list
  65960. */
  65961. removeGroup(groupNb: number): void;
  65962. /** Change a group header label
  65963. * @param label is the new group header label
  65964. * @param groupNb is the number of the group to relabel
  65965. * */
  65966. setHeaderName(label: string, groupNb: number): void;
  65967. /** Change selector label to the one given
  65968. * @param label is the new selector label
  65969. * @param groupNb is the number of the groupcontaining the selector
  65970. * @param selectorNb is the number of the selector within a group to relabel
  65971. * */
  65972. relabel(label: string, groupNb: number, selectorNb: number): void;
  65973. /** For a given group position remove the selector at the given position
  65974. * @param groupNb is the number of the group to remove the selector from
  65975. * @param selectorNb is the number of the selector within the group
  65976. */
  65977. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  65978. /** For a given group position of correct type add a checkbox button
  65979. * @param groupNb is the number of the group to remove the selector from
  65980. * @param label is the label for the selector
  65981. * @param func is the function called when the Selector is checked
  65982. * @param checked is true when Selector is checked
  65983. */
  65984. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  65985. /** For a given group position of correct type add a radio button
  65986. * @param groupNb is the number of the group to remove the selector from
  65987. * @param label is the label for the selector
  65988. * @param func is the function called when the Selector is checked
  65989. * @param checked is true when Selector is checked
  65990. */
  65991. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  65992. /**
  65993. * For a given slider group add a slider
  65994. * @param groupNb is the number of the group to add the slider to
  65995. * @param label is the label for the Slider
  65996. * @param func is the function called when the Slider moves
  65997. * @param unit is a string describing the units used, eg degrees or metres
  65998. * @param min is the minimum value for the Slider
  65999. * @param max is the maximum value for the Slider
  66000. * @param value is the start value for the Slider between min and max
  66001. * @param onVal is the function used to format the value displayed, eg radians to degrees
  66002. */
  66003. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  66004. }
  66005. }
  66006. declare module BABYLON.GUI {
  66007. /**
  66008. * Class used to hold a the container for ScrollViewer
  66009. * @hidden
  66010. */
  66011. export class _ScrollViewerWindow extends Container {
  66012. parentClientWidth: number;
  66013. parentClientHeight: number;
  66014. /**
  66015. * Creates a new ScrollViewerWindow
  66016. * @param name of ScrollViewerWindow
  66017. */
  66018. constructor(name?: string);
  66019. protected _getTypeName(): string;
  66020. /** @hidden */
  66021. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66022. protected _postMeasure(): void;
  66023. }
  66024. }
  66025. declare module BABYLON.GUI {
  66026. /**
  66027. * Class used to create slider controls
  66028. */
  66029. export class ScrollBar extends BaseSlider {
  66030. name?: string | undefined;
  66031. private _background;
  66032. private _borderColor;
  66033. private _thumbMeasure;
  66034. /** Gets or sets border color */
  66035. borderColor: string;
  66036. /** Gets or sets background color */
  66037. background: string;
  66038. /**
  66039. * Creates a new Slider
  66040. * @param name defines the control name
  66041. */
  66042. constructor(name?: string | undefined);
  66043. protected _getTypeName(): string;
  66044. protected _getThumbThickness(): number; private _draw(context: CanvasRenderingContext2D): void;
  66045. private _first;
  66046. private _originX;
  66047. private _originY;
  66048. /** @hidden */
  66049. protected _updateValueFromPointer(x: number, y: number): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66050. }
  66051. }
  66052. declare module BABYLON.GUI {
  66053. /**
  66054. * Class used to hold a viewer window and sliders in a grid
  66055. */
  66056. export class ScrollViewer extends Rectangle {
  66057. private _grid;
  66058. private _horizontalBarSpace;
  66059. private _verticalBarSpace;
  66060. private _dragSpace;
  66061. private _horizontalBar;
  66062. private _verticalBar;
  66063. private _barColor;
  66064. private _barBackground;
  66065. private _barSize;
  66066. private _endLeft;
  66067. private _endTop;
  66068. private _window;
  66069. private _pointerIsOver;
  66070. private _wheelPrecision;
  66071. private _onPointerObserver;
  66072. private _clientWidth;
  66073. private _clientHeight;
  66074. /**
  66075. * Gets the horizontal scrollbar
  66076. */
  66077. readonly horizontalBar: ScrollBar;
  66078. /**
  66079. * Gets the vertical scrollbar
  66080. */
  66081. readonly verticalBar: ScrollBar;
  66082. /**
  66083. * Adds a new control to the current container
  66084. * @param control defines the control to add
  66085. * @returns the current container
  66086. */
  66087. addControl(control: BABYLON.Nullable<Control>): Container;
  66088. /**
  66089. * Removes a control from the current container
  66090. * @param control defines the control to remove
  66091. * @returns the current container
  66092. */
  66093. removeControl(control: Control): Container;
  66094. /** Gets the list of children */
  66095. readonly children: Control[]; private _flagDescendantsAsMatrixDirty(): void;
  66096. /**
  66097. * Creates a new ScrollViewer
  66098. * @param name of ScrollViewer
  66099. */
  66100. constructor(name?: string);
  66101. /** Reset the scroll viewer window to initial size */
  66102. resetWindow(): void;
  66103. protected _getTypeName(): string;
  66104. private _buildClientSizes;
  66105. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66106. protected _postMeasure(): void;
  66107. /**
  66108. * Gets or sets the mouse wheel precision
  66109. * from 0 to 1 with a default value of 0.05
  66110. * */
  66111. wheelPrecision: number;
  66112. /** Gets or sets the bar color */
  66113. barColor: string;
  66114. /** Gets or sets the size of the bar */
  66115. barSize: number;
  66116. /** Gets or sets the bar background */
  66117. barBackground: string;
  66118. /** @hidden */
  66119. private _updateScroller; private _link(host: AdvancedDynamicTexture): void;
  66120. /** @hidden */
  66121. private _attachWheel; private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  66122. /** Releases associated resources */
  66123. dispose(): void;
  66124. }
  66125. }
  66126. declare module BABYLON.GUI {
  66127. /** Class used to render a grid */
  66128. export class DisplayGrid extends Control {
  66129. name?: string | undefined;
  66130. private _cellWidth;
  66131. private _cellHeight;
  66132. private _minorLineTickness;
  66133. private _minorLineColor;
  66134. private _majorLineTickness;
  66135. private _majorLineColor;
  66136. private _majorLineFrequency;
  66137. private _background;
  66138. private _displayMajorLines;
  66139. private _displayMinorLines;
  66140. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  66141. displayMinorLines: boolean;
  66142. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  66143. displayMajorLines: boolean;
  66144. /** Gets or sets background color (Black by default) */
  66145. background: string;
  66146. /** Gets or sets the width of each cell (20 by default) */
  66147. cellWidth: number;
  66148. /** Gets or sets the height of each cell (20 by default) */
  66149. cellHeight: number;
  66150. /** Gets or sets the tickness of minor lines (1 by default) */
  66151. minorLineTickness: number;
  66152. /** Gets or sets the color of minor lines (DarkGray by default) */
  66153. minorLineColor: string;
  66154. /** Gets or sets the tickness of major lines (2 by default) */
  66155. majorLineTickness: number;
  66156. /** Gets or sets the color of major lines (White by default) */
  66157. majorLineColor: string;
  66158. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  66159. majorLineFrequency: number;
  66160. /**
  66161. * Creates a new GridDisplayRectangle
  66162. * @param name defines the control name
  66163. */
  66164. constructor(name?: string | undefined); private _draw(context: CanvasRenderingContext2D): void;
  66165. protected _getTypeName(): string;
  66166. }
  66167. }
  66168. declare module BABYLON.GUI {
  66169. /**
  66170. * Class used to create slider controls based on images
  66171. */
  66172. export class ImageBasedSlider extends BaseSlider {
  66173. name?: string | undefined;
  66174. private _backgroundImage;
  66175. private _thumbImage;
  66176. private _valueBarImage;
  66177. private _tempMeasure;
  66178. displayThumb: boolean;
  66179. /**
  66180. * Gets or sets the image used to render the background
  66181. */
  66182. backgroundImage: Image;
  66183. /**
  66184. * Gets or sets the image used to render the value bar
  66185. */
  66186. valueBarImage: Image;
  66187. /**
  66188. * Gets or sets the image used to render the thumb
  66189. */
  66190. thumbImage: Image;
  66191. /**
  66192. * Creates a new ImageBasedSlider
  66193. * @param name defines the control name
  66194. */
  66195. constructor(name?: string | undefined);
  66196. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  66197. }
  66198. }
  66199. declare module BABYLON.GUI {
  66200. /**
  66201. * Forcing an export so that this code will execute
  66202. * @hidden
  66203. */
  66204. const name = "Statics";
  66205. }
  66206. declare module BABYLON.GUI {
  66207. /**
  66208. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  66209. */
  66210. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  66211. /**
  66212. * Define the instrumented AdvancedDynamicTexture.
  66213. */
  66214. texture: AdvancedDynamicTexture;
  66215. private _captureRenderTime;
  66216. private _renderTime;
  66217. private _captureLayoutTime;
  66218. private _layoutTime;
  66219. private _onBeginRenderObserver;
  66220. private _onEndRenderObserver;
  66221. private _onBeginLayoutObserver;
  66222. private _onEndLayoutObserver;
  66223. /**
  66224. * Gets the perf counter used to capture render time
  66225. */
  66226. readonly renderTimeCounter: BABYLON.PerfCounter;
  66227. /**
  66228. * Gets the perf counter used to capture layout time
  66229. */
  66230. readonly layoutTimeCounter: BABYLON.PerfCounter;
  66231. /**
  66232. * Enable or disable the render time capture
  66233. */
  66234. captureRenderTime: boolean;
  66235. /**
  66236. * Enable or disable the layout time capture
  66237. */
  66238. captureLayoutTime: boolean;
  66239. /**
  66240. * Instantiates a new advanced dynamic texture instrumentation.
  66241. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  66242. * @param texture Defines the AdvancedDynamicTexture to instrument
  66243. */
  66244. constructor(
  66245. /**
  66246. * Define the instrumented AdvancedDynamicTexture.
  66247. */
  66248. texture: AdvancedDynamicTexture);
  66249. /**
  66250. * Dispose and release associated resources.
  66251. */
  66252. dispose(): void;
  66253. }
  66254. }
  66255. declare module BABYLON.GUI {
  66256. /**
  66257. * Class used to load GUI via XML.
  66258. */
  66259. export class XmlLoader {
  66260. private _nodes;
  66261. private _nodeTypes;
  66262. private _isLoaded;
  66263. private _objectAttributes;
  66264. private _parentClass;
  66265. /**
  66266. * Create a new xml loader
  66267. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  66268. */
  66269. constructor(parentClass?: null);
  66270. private _getChainElement;
  66271. private _getClassAttribute;
  66272. private _createGuiElement;
  66273. private _parseGrid;
  66274. private _parseElement;
  66275. private _prepareSourceElement;
  66276. private _parseElementsFromSource;
  66277. private _parseXml;
  66278. /**
  66279. * Gets if the loading has finished.
  66280. * @returns whether the loading has finished or not
  66281. */
  66282. isLoaded(): boolean;
  66283. /**
  66284. * Gets a loaded node / control by id.
  66285. * @param id the Controls id set in the xml
  66286. * @returns element of type Control
  66287. */
  66288. getNodeById(id: string): any;
  66289. /**
  66290. * Gets all loaded nodes / controls
  66291. * @returns Array of controls
  66292. */
  66293. getNodes(): any;
  66294. /**
  66295. * Initiates the xml layout loading
  66296. * @param xmlFile defines the xml layout to load
  66297. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  66298. * @param callback defines the callback called on layout load.
  66299. */
  66300. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  66301. }
  66302. }
  66303. declare module BABYLON.GUI {
  66304. /**
  66305. * Class used to create containers for controls
  66306. */
  66307. export class Container3D extends Control3D {
  66308. private _blockLayout;
  66309. /**
  66310. * Gets the list of child controls
  66311. */
  66312. protected _children: Control3D[];
  66313. /**
  66314. * Gets the list of child controls
  66315. */
  66316. readonly children: Array<Control3D>;
  66317. /**
  66318. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  66319. * This is helpful to optimize layout operation when adding multiple children in a row
  66320. */
  66321. blockLayout: boolean;
  66322. /**
  66323. * Creates a new container
  66324. * @param name defines the container name
  66325. */
  66326. constructor(name?: string);
  66327. /**
  66328. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  66329. * @returns the current container
  66330. */
  66331. updateLayout(): Container3D;
  66332. /**
  66333. * Gets a boolean indicating if the given control is in the children of this control
  66334. * @param control defines the control to check
  66335. * @returns true if the control is in the child list
  66336. */
  66337. containsControl(control: Control3D): boolean;
  66338. /**
  66339. * Adds a control to the children of this control
  66340. * @param control defines the control to add
  66341. * @returns the current container
  66342. */
  66343. addControl(control: Control3D): Container3D;
  66344. /**
  66345. * This function will be called everytime a new control is added
  66346. */
  66347. protected _arrangeChildren(): void;
  66348. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  66349. /**
  66350. * Removes a control from the children of this control
  66351. * @param control defines the control to remove
  66352. * @returns the current container
  66353. */
  66354. removeControl(control: Control3D): Container3D;
  66355. protected _getTypeName(): string;
  66356. /**
  66357. * Releases all associated resources
  66358. */
  66359. dispose(): void;
  66360. /** Control rotation will remain unchanged */
  66361. static readonly UNSET_ORIENTATION: number;
  66362. /** Control will rotate to make it look at sphere central axis */
  66363. static readonly FACEORIGIN_ORIENTATION: number;
  66364. /** Control will rotate to make it look back at sphere central axis */
  66365. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  66366. /** Control will rotate to look at z axis (0, 0, 1) */
  66367. static readonly FACEFORWARD_ORIENTATION: number;
  66368. /** Control will rotate to look at negative z axis (0, 0, -1) */
  66369. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  66370. }
  66371. }
  66372. declare module BABYLON.GUI {
  66373. /**
  66374. * Class used to manage 3D user interface
  66375. * @see http://doc.babylonjs.com/how_to/gui3d
  66376. */
  66377. export class GUI3DManager implements BABYLON.IDisposable {
  66378. private _scene;
  66379. private _sceneDisposeObserver;
  66380. private _utilityLayer;
  66381. private _rootContainer;
  66382. private _pointerObserver;
  66383. private _pointerOutObserver;
  66384. /** @hidden */ private _lastPickedControl: Control3D;
  66385. /** @hidden */ private _lastControlOver: {
  66386. [pointerId: number]: Control3D;
  66387. };
  66388. /** @hidden */ private _lastControlDown: {
  66389. [pointerId: number]: Control3D;
  66390. };
  66391. /**
  66392. * BABYLON.Observable raised when the point picked by the pointer events changed
  66393. */
  66394. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  66395. /** @hidden */ private _sharedMaterials: {
  66396. [key: string]: BABYLON.Material;
  66397. };
  66398. /** Gets the hosting scene */
  66399. readonly scene: BABYLON.Scene;
  66400. /** Gets associated utility layer */
  66401. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  66402. /**
  66403. * Creates a new GUI3DManager
  66404. * @param scene
  66405. */
  66406. constructor(scene?: BABYLON.Scene);
  66407. private _handlePointerOut;
  66408. private _doPicking;
  66409. /**
  66410. * Gets the root container
  66411. */
  66412. readonly rootContainer: Container3D;
  66413. /**
  66414. * Gets a boolean indicating if the given control is in the root child list
  66415. * @param control defines the control to check
  66416. * @returns true if the control is in the root child list
  66417. */
  66418. containsControl(control: Control3D): boolean;
  66419. /**
  66420. * Adds a control to the root child list
  66421. * @param control defines the control to add
  66422. * @returns the current manager
  66423. */
  66424. addControl(control: Control3D): GUI3DManager;
  66425. /**
  66426. * Removes a control from the root child list
  66427. * @param control defines the control to remove
  66428. * @returns the current container
  66429. */
  66430. removeControl(control: Control3D): GUI3DManager;
  66431. /**
  66432. * Releases all associated resources
  66433. */
  66434. dispose(): void;
  66435. }
  66436. }
  66437. declare module BABYLON.GUI {
  66438. /**
  66439. * Class used to transport BABYLON.Vector3 information for pointer events
  66440. */
  66441. export class Vector3WithInfo extends BABYLON.Vector3 {
  66442. /** defines the current mouse button index */
  66443. buttonIndex: number;
  66444. /**
  66445. * Creates a new Vector3WithInfo
  66446. * @param source defines the vector3 data to transport
  66447. * @param buttonIndex defines the current mouse button index
  66448. */
  66449. constructor(source: BABYLON.Vector3,
  66450. /** defines the current mouse button index */
  66451. buttonIndex?: number);
  66452. }
  66453. }
  66454. declare module BABYLON.GUI {
  66455. /**
  66456. * Class used as base class for controls
  66457. */
  66458. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  66459. /** Defines the control name */
  66460. name?: string | undefined;
  66461. /** @hidden */ private _host: GUI3DManager;
  66462. private _node;
  66463. private _downCount;
  66464. private _enterCount;
  66465. private _downPointerIds;
  66466. private _isVisible;
  66467. /** Gets or sets the control position in world space */
  66468. position: BABYLON.Vector3;
  66469. /** Gets or sets the control scaling in world space */
  66470. scaling: BABYLON.Vector3;
  66471. /** Callback used to start pointer enter animation */
  66472. pointerEnterAnimation: () => void;
  66473. /** Callback used to start pointer out animation */
  66474. pointerOutAnimation: () => void;
  66475. /** Callback used to start pointer down animation */
  66476. pointerDownAnimation: () => void;
  66477. /** Callback used to start pointer up animation */
  66478. pointerUpAnimation: () => void;
  66479. /**
  66480. * An event triggered when the pointer move over the control
  66481. */
  66482. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  66483. /**
  66484. * An event triggered when the pointer move out of the control
  66485. */
  66486. onPointerOutObservable: BABYLON.Observable<Control3D>;
  66487. /**
  66488. * An event triggered when the pointer taps the control
  66489. */
  66490. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  66491. /**
  66492. * An event triggered when pointer is up
  66493. */
  66494. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  66495. /**
  66496. * An event triggered when a control is clicked on (with a mouse)
  66497. */
  66498. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  66499. /**
  66500. * An event triggered when pointer enters the control
  66501. */
  66502. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  66503. /**
  66504. * Gets or sets the parent container
  66505. */
  66506. parent: BABYLON.Nullable<Container3D>;
  66507. private _behaviors;
  66508. /**
  66509. * Gets the list of attached behaviors
  66510. * @see http://doc.babylonjs.com/features/behaviour
  66511. */
  66512. readonly behaviors: BABYLON.Behavior<Control3D>[];
  66513. /**
  66514. * Attach a behavior to the control
  66515. * @see http://doc.babylonjs.com/features/behaviour
  66516. * @param behavior defines the behavior to attach
  66517. * @returns the current control
  66518. */
  66519. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  66520. /**
  66521. * Remove an attached behavior
  66522. * @see http://doc.babylonjs.com/features/behaviour
  66523. * @param behavior defines the behavior to attach
  66524. * @returns the current control
  66525. */
  66526. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  66527. /**
  66528. * Gets an attached behavior by name
  66529. * @param name defines the name of the behavior to look for
  66530. * @see http://doc.babylonjs.com/features/behaviour
  66531. * @returns null if behavior was not found else the requested behavior
  66532. */
  66533. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  66534. /** Gets or sets a boolean indicating if the control is visible */
  66535. isVisible: boolean;
  66536. /**
  66537. * Creates a new control
  66538. * @param name defines the control name
  66539. */
  66540. constructor(
  66541. /** Defines the control name */
  66542. name?: string | undefined);
  66543. /**
  66544. * Gets a string representing the class name
  66545. */
  66546. readonly typeName: string;
  66547. /**
  66548. * Get the current class name of the control.
  66549. * @returns current class name
  66550. */
  66551. getClassName(): string;
  66552. protected _getTypeName(): string;
  66553. /**
  66554. * Gets the transform node used by this control
  66555. */
  66556. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  66557. /**
  66558. * Gets the mesh used to render this control
  66559. */
  66560. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  66561. /**
  66562. * Link the control as child of the given node
  66563. * @param node defines the node to link to. Use null to unlink the control
  66564. * @returns the current control
  66565. */
  66566. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  66567. /** @hidden **/ private _prepareNode(scene: BABYLON.Scene): void;
  66568. /**
  66569. * Node creation.
  66570. * Can be overriden by children
  66571. * @param scene defines the scene where the node must be attached
  66572. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  66573. */
  66574. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  66575. /**
  66576. * Affect a material to the given mesh
  66577. * @param mesh defines the mesh which will represent the control
  66578. */
  66579. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  66580. /** @hidden */ private _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  66581. /** @hidden */ private _onPointerEnter(target: Control3D): boolean;
  66582. /** @hidden */ private _onPointerOut(target: Control3D): void;
  66583. /** @hidden */ private _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  66584. /** @hidden */ private _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66585. /** @hidden */
  66586. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  66587. /** @hidden */ private _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  66588. /** @hidden */ private _disposeNode(): void;
  66589. /**
  66590. * Releases all associated resources
  66591. */
  66592. dispose(): void;
  66593. }
  66594. }
  66595. declare module BABYLON.GUI {
  66596. /**
  66597. * Class used as a root to all buttons
  66598. */
  66599. export class AbstractButton3D extends Control3D {
  66600. /**
  66601. * Creates a new button
  66602. * @param name defines the control name
  66603. */
  66604. constructor(name?: string);
  66605. protected _getTypeName(): string;
  66606. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66607. }
  66608. }
  66609. declare module BABYLON.GUI {
  66610. /**
  66611. * Class used to create a button in 3D
  66612. */
  66613. export class Button3D extends AbstractButton3D {
  66614. /** @hidden */
  66615. protected _currentMaterial: BABYLON.Material;
  66616. private _facadeTexture;
  66617. private _content;
  66618. private _contentResolution;
  66619. private _contentScaleRatio;
  66620. /**
  66621. * Gets or sets the texture resolution used to render content (512 by default)
  66622. */
  66623. contentResolution: BABYLON.int;
  66624. /**
  66625. * Gets or sets the texture scale ratio used to render content (2 by default)
  66626. */
  66627. contentScaleRatio: number;
  66628. protected _disposeFacadeTexture(): void;
  66629. protected _resetContent(): void;
  66630. /**
  66631. * Creates a new button
  66632. * @param name defines the control name
  66633. */
  66634. constructor(name?: string);
  66635. /**
  66636. * Gets or sets the GUI 2D content used to display the button's facade
  66637. */
  66638. content: Control;
  66639. /**
  66640. * Apply the facade texture (created from the content property).
  66641. * This function can be overloaded by child classes
  66642. * @param facadeTexture defines the AdvancedDynamicTexture to use
  66643. */
  66644. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  66645. protected _getTypeName(): string;
  66646. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66647. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  66648. /**
  66649. * Releases all associated resources
  66650. */
  66651. dispose(): void;
  66652. }
  66653. }
  66654. declare module BABYLON.GUI {
  66655. /**
  66656. * Abstract class used to create a container panel deployed on the surface of a volume
  66657. */
  66658. export abstract class VolumeBasedPanel extends Container3D {
  66659. private _columns;
  66660. private _rows;
  66661. private _rowThenColum;
  66662. private _orientation;
  66663. protected _cellWidth: number;
  66664. protected _cellHeight: number;
  66665. /**
  66666. * Gets or sets the distance between elements
  66667. */
  66668. margin: number;
  66669. /**
  66670. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  66671. * | Value | Type | Description |
  66672. * | ----- | ----------------------------------- | ----------- |
  66673. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  66674. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  66675. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  66676. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  66677. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  66678. */
  66679. orientation: number;
  66680. /**
  66681. * Gets or sets the number of columns requested (10 by default).
  66682. * The panel will automatically compute the number of rows based on number of child controls.
  66683. */
  66684. columns: BABYLON.int;
  66685. /**
  66686. * Gets or sets a the number of rows requested.
  66687. * The panel will automatically compute the number of columns based on number of child controls.
  66688. */
  66689. rows: BABYLON.int;
  66690. /**
  66691. * Creates new VolumeBasedPanel
  66692. */
  66693. constructor();
  66694. protected _arrangeChildren(): void;
  66695. /** Child classes must implement this function to provide correct control positioning */
  66696. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66697. /** Child classes can implement this function to provide additional processing */
  66698. protected _finalProcessing(): void;
  66699. }
  66700. }
  66701. declare module BABYLON.GUI {
  66702. /**
  66703. * Class used to create a container panel deployed on the surface of a cylinder
  66704. */
  66705. export class CylinderPanel extends VolumeBasedPanel {
  66706. private _radius;
  66707. /**
  66708. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  66709. */
  66710. radius: BABYLON.float;
  66711. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66712. private _cylindricalMapping;
  66713. }
  66714. }
  66715. declare module BABYLON.GUI {
  66716. /** @hidden */
  66717. export var fluentVertexShader: {
  66718. name: string;
  66719. shader: string;
  66720. };
  66721. }
  66722. declare module BABYLON.GUI {
  66723. /** @hidden */
  66724. export var fluentPixelShader: {
  66725. name: string;
  66726. shader: string;
  66727. };
  66728. }
  66729. declare module BABYLON.GUI {
  66730. /** @hidden */
  66731. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  66732. INNERGLOW: boolean;
  66733. BORDER: boolean;
  66734. HOVERLIGHT: boolean;
  66735. TEXTURE: boolean;
  66736. constructor();
  66737. }
  66738. /**
  66739. * Class used to render controls with fluent desgin
  66740. */
  66741. export class FluentMaterial extends BABYLON.PushMaterial {
  66742. /**
  66743. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  66744. */
  66745. innerGlowColorIntensity: number;
  66746. /**
  66747. * Gets or sets the inner glow color (white by default)
  66748. */
  66749. innerGlowColor: BABYLON.Color3;
  66750. /**
  66751. * Gets or sets alpha value (default is 1.0)
  66752. */
  66753. alpha: number;
  66754. /**
  66755. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  66756. */
  66757. albedoColor: BABYLON.Color3;
  66758. /**
  66759. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  66760. */
  66761. renderBorders: boolean;
  66762. /**
  66763. * Gets or sets border width (default is 0.5)
  66764. */
  66765. borderWidth: number;
  66766. /**
  66767. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  66768. */
  66769. edgeSmoothingValue: number;
  66770. /**
  66771. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  66772. */
  66773. borderMinValue: number;
  66774. /**
  66775. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  66776. */
  66777. renderHoverLight: boolean;
  66778. /**
  66779. * Gets or sets the radius used to render the hover light (default is 1.0)
  66780. */
  66781. hoverRadius: number;
  66782. /**
  66783. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  66784. */
  66785. hoverColor: BABYLON.Color4;
  66786. /**
  66787. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  66788. */
  66789. hoverPosition: BABYLON.Vector3;
  66790. private _albedoTexture;
  66791. /** Gets or sets the texture to use for albedo color */
  66792. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  66793. /**
  66794. * Creates a new Fluent material
  66795. * @param name defines the name of the material
  66796. * @param scene defines the hosting scene
  66797. */
  66798. constructor(name: string, scene: BABYLON.Scene);
  66799. needAlphaBlending(): boolean;
  66800. needAlphaTesting(): boolean;
  66801. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66802. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66803. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66804. getActiveTextures(): BABYLON.BaseTexture[];
  66805. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66806. dispose(forceDisposeEffect?: boolean): void;
  66807. clone(name: string): FluentMaterial;
  66808. serialize(): any;
  66809. getClassName(): string;
  66810. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  66811. }
  66812. }
  66813. declare module BABYLON.GUI {
  66814. /**
  66815. * Class used to create a holographic button in 3D
  66816. */
  66817. export class HolographicButton extends Button3D {
  66818. private _backPlate;
  66819. private _textPlate;
  66820. private _frontPlate;
  66821. private _text;
  66822. private _imageUrl;
  66823. private _shareMaterials;
  66824. private _frontMaterial;
  66825. private _backMaterial;
  66826. private _plateMaterial;
  66827. private _pickedPointObserver;
  66828. private _tooltipFade;
  66829. private _tooltipTextBlock;
  66830. private _tooltipTexture;
  66831. private _tooltipMesh;
  66832. private _tooltipHoverObserver;
  66833. private _tooltipOutObserver;
  66834. private _disposeTooltip;
  66835. /**
  66836. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  66837. */
  66838. tooltipText: BABYLON.Nullable<string>;
  66839. /**
  66840. * Gets or sets text for the button
  66841. */
  66842. text: string;
  66843. /**
  66844. * Gets or sets the image url for the button
  66845. */
  66846. imageUrl: string;
  66847. /**
  66848. * Gets the back material used by this button
  66849. */
  66850. readonly backMaterial: FluentMaterial;
  66851. /**
  66852. * Gets the front material used by this button
  66853. */
  66854. readonly frontMaterial: FluentMaterial;
  66855. /**
  66856. * Gets the plate material used by this button
  66857. */
  66858. readonly plateMaterial: BABYLON.StandardMaterial;
  66859. /**
  66860. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  66861. */
  66862. readonly shareMaterials: boolean;
  66863. /**
  66864. * Creates a new button
  66865. * @param name defines the control name
  66866. */
  66867. constructor(name?: string, shareMaterials?: boolean);
  66868. protected _getTypeName(): string;
  66869. private _rebuildContent;
  66870. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66871. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  66872. private _createBackMaterial;
  66873. private _createFrontMaterial;
  66874. private _createPlateMaterial;
  66875. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  66876. /**
  66877. * Releases all associated resources
  66878. */
  66879. dispose(): void;
  66880. }
  66881. }
  66882. declare module BABYLON.GUI {
  66883. /**
  66884. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  66885. */
  66886. export class MeshButton3D extends Button3D {
  66887. /** @hidden */
  66888. protected _currentMesh: BABYLON.Mesh;
  66889. /**
  66890. * Creates a new 3D button based on a mesh
  66891. * @param mesh mesh to become a 3D button
  66892. * @param name defines the control name
  66893. */
  66894. constructor(mesh: BABYLON.Mesh, name?: string);
  66895. protected _getTypeName(): string;
  66896. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66897. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  66898. }
  66899. }
  66900. declare module BABYLON.GUI {
  66901. /**
  66902. * Class used to create a container panel deployed on the surface of a plane
  66903. */
  66904. export class PlanePanel extends VolumeBasedPanel {
  66905. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66906. }
  66907. }
  66908. declare module BABYLON.GUI {
  66909. /**
  66910. * Class used to create a container panel where items get randomized planar mapping
  66911. */
  66912. export class ScatterPanel extends VolumeBasedPanel {
  66913. private _iteration;
  66914. /**
  66915. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  66916. */
  66917. iteration: BABYLON.float;
  66918. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66919. private _scatterMapping;
  66920. protected _finalProcessing(): void;
  66921. }
  66922. }
  66923. declare module BABYLON.GUI {
  66924. /**
  66925. * Class used to create a container panel deployed on the surface of a sphere
  66926. */
  66927. export class SpherePanel extends VolumeBasedPanel {
  66928. private _radius;
  66929. /**
  66930. * Gets or sets the radius of the sphere where to project controls (5 by default)
  66931. */
  66932. radius: BABYLON.float;
  66933. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66934. private _sphericalMapping;
  66935. }
  66936. }
  66937. declare module BABYLON.GUI {
  66938. /**
  66939. * Class used to create a stack panel in 3D on XY plane
  66940. */
  66941. export class StackPanel3D extends Container3D {
  66942. private _isVertical;
  66943. /**
  66944. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  66945. */
  66946. isVertical: boolean;
  66947. /**
  66948. * Gets or sets the distance between elements
  66949. */
  66950. margin: number;
  66951. /**
  66952. * Creates new StackPanel
  66953. * @param isVertical
  66954. */
  66955. constructor(isVertical?: boolean);
  66956. protected _arrangeChildren(): void;
  66957. }
  66958. }
  66959. declare module BABYLON {
  66960. /**
  66961. * Interface for a data buffer
  66962. */
  66963. export interface IDataBuffer {
  66964. /**
  66965. * Reads bytes from the data buffer.
  66966. * @param byteOffset The byte offset to read
  66967. * @param byteLength The byte length to read
  66968. * @returns A promise that resolves when the bytes are read
  66969. */
  66970. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  66971. /**
  66972. * The byte length of the buffer.
  66973. */
  66974. readonly byteLength: number;
  66975. }
  66976. /**
  66977. * Utility class for reading from a data buffer
  66978. */
  66979. export class DataReader {
  66980. /**
  66981. * The data buffer associated with this data reader.
  66982. */
  66983. readonly buffer: IDataBuffer;
  66984. /**
  66985. * The current byte offset from the beginning of the data buffer.
  66986. */
  66987. byteOffset: number;
  66988. private _dataView;
  66989. private _dataByteOffset;
  66990. /**
  66991. * Constructor
  66992. * @param buffer The buffer to read
  66993. */
  66994. constructor(buffer: IDataBuffer);
  66995. /**
  66996. * Loads the given byte length.
  66997. * @param byteLength The byte length to load
  66998. * @returns A promise that resolves when the load is complete
  66999. */
  67000. loadAsync(byteLength: number): Promise<void>;
  67001. /**
  67002. * Read a unsigned 32-bit integer from the currently loaded data range.
  67003. * @returns The 32-bit integer read
  67004. */
  67005. readUint32(): number;
  67006. /**
  67007. * Read a byte array from the currently loaded data range.
  67008. * @param byteLength The byte length to read
  67009. * @returns The byte array read
  67010. */
  67011. readUint8Array(byteLength: number): Uint8Array;
  67012. /**
  67013. * Read a string from the currently loaded data range.
  67014. * @param byteLength The byte length to read
  67015. * @returns The string read
  67016. */
  67017. readString(byteLength: number): string;
  67018. /**
  67019. * Skips the given byte length the currently loaded data range.
  67020. * @param byteLength The byte length to skip
  67021. */
  67022. skipBytes(byteLength: number): void;
  67023. }
  67024. }
  67025. declare module BABYLON {
  67026. /**
  67027. * Mode that determines the coordinate system to use.
  67028. */
  67029. export enum GLTFLoaderCoordinateSystemMode {
  67030. /**
  67031. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  67032. */
  67033. AUTO = 0,
  67034. /**
  67035. * Sets the useRightHandedSystem flag on the scene.
  67036. */
  67037. FORCE_RIGHT_HANDED = 1
  67038. }
  67039. /**
  67040. * Mode that determines what animations will start.
  67041. */
  67042. export enum GLTFLoaderAnimationStartMode {
  67043. /**
  67044. * No animation will start.
  67045. */
  67046. NONE = 0,
  67047. /**
  67048. * The first animation will start.
  67049. */
  67050. FIRST = 1,
  67051. /**
  67052. * All animations will start.
  67053. */
  67054. ALL = 2
  67055. }
  67056. /**
  67057. * Interface that contains the data for the glTF asset.
  67058. */
  67059. export interface IGLTFLoaderData {
  67060. /**
  67061. * The object that represents the glTF JSON.
  67062. */
  67063. json: Object;
  67064. /**
  67065. * The BIN chunk of a binary glTF.
  67066. */
  67067. bin: Nullable<IDataBuffer>;
  67068. }
  67069. /**
  67070. * Interface for extending the loader.
  67071. */
  67072. export interface IGLTFLoaderExtension {
  67073. /**
  67074. * The name of this extension.
  67075. */
  67076. readonly name: string;
  67077. /**
  67078. * Defines whether this extension is enabled.
  67079. */
  67080. enabled: boolean;
  67081. }
  67082. /**
  67083. * Loader state.
  67084. */
  67085. export enum GLTFLoaderState {
  67086. /**
  67087. * The asset is loading.
  67088. */
  67089. LOADING = 0,
  67090. /**
  67091. * The asset is ready for rendering.
  67092. */
  67093. READY = 1,
  67094. /**
  67095. * The asset is completely loaded.
  67096. */
  67097. COMPLETE = 2
  67098. }
  67099. /** @hidden */
  67100. export interface IGLTFLoader extends IDisposable {
  67101. readonly state: Nullable<GLTFLoaderState>;
  67102. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  67103. meshes: AbstractMesh[];
  67104. particleSystems: IParticleSystem[];
  67105. skeletons: Skeleton[];
  67106. animationGroups: AnimationGroup[];
  67107. }>;
  67108. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  67109. }
  67110. /**
  67111. * File loader for loading glTF files into a scene.
  67112. */
  67113. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  67114. /** @hidden */ private static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  67115. /** @hidden */ private static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  67116. /**
  67117. * Raised when the asset has been parsed
  67118. */
  67119. onParsedObservable: Observable<IGLTFLoaderData>;
  67120. private _onParsedObserver;
  67121. /**
  67122. * Raised when the asset has been parsed
  67123. */
  67124. onParsed: (loaderData: IGLTFLoaderData) => void;
  67125. /**
  67126. * 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.
  67127. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  67128. * Defaults to true.
  67129. * @hidden
  67130. */
  67131. static IncrementalLoading: boolean;
  67132. /**
  67133. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  67134. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  67135. * @hidden
  67136. */
  67137. static HomogeneousCoordinates: boolean;
  67138. /**
  67139. * The coordinate system mode. Defaults to AUTO.
  67140. */
  67141. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  67142. /**
  67143. * The animation start mode. Defaults to FIRST.
  67144. */
  67145. animationStartMode: GLTFLoaderAnimationStartMode;
  67146. /**
  67147. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  67148. */
  67149. compileMaterials: boolean;
  67150. /**
  67151. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  67152. */
  67153. useClipPlane: boolean;
  67154. /**
  67155. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  67156. */
  67157. compileShadowGenerators: boolean;
  67158. /**
  67159. * Defines if the Alpha blended materials are only applied as coverage.
  67160. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  67161. * If true, no extra effects are applied to transparent pixels.
  67162. */
  67163. transparencyAsCoverage: boolean;
  67164. /**
  67165. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  67166. * Enabling will disable offline support and glTF validator.
  67167. * Defaults to false.
  67168. */
  67169. useRangeRequests: boolean;
  67170. /**
  67171. * Function called before loading a url referenced by the asset.
  67172. */
  67173. preprocessUrlAsync: (url: string) => Promise<string>;
  67174. /**
  67175. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  67176. */
  67177. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  67178. private _onMeshLoadedObserver;
  67179. /**
  67180. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  67181. */
  67182. onMeshLoaded: (mesh: AbstractMesh) => void;
  67183. /**
  67184. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  67185. */
  67186. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  67187. private _onTextureLoadedObserver;
  67188. /**
  67189. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  67190. */
  67191. onTextureLoaded: (texture: BaseTexture) => void;
  67192. /**
  67193. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  67194. */
  67195. readonly onMaterialLoadedObservable: Observable<Material>;
  67196. private _onMaterialLoadedObserver;
  67197. /**
  67198. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  67199. */
  67200. onMaterialLoaded: (material: Material) => void;
  67201. /**
  67202. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  67203. */
  67204. readonly onCameraLoadedObservable: Observable<Camera>;
  67205. private _onCameraLoadedObserver;
  67206. /**
  67207. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  67208. */
  67209. onCameraLoaded: (camera: Camera) => void;
  67210. /**
  67211. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  67212. * For assets with LODs, raised when all of the LODs are complete.
  67213. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  67214. */
  67215. readonly onCompleteObservable: Observable<void>;
  67216. private _onCompleteObserver;
  67217. /**
  67218. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  67219. * For assets with LODs, raised when all of the LODs are complete.
  67220. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  67221. */
  67222. onComplete: () => void;
  67223. /**
  67224. * Observable raised when an error occurs.
  67225. */
  67226. readonly onErrorObservable: Observable<any>;
  67227. private _onErrorObserver;
  67228. /**
  67229. * Callback raised when an error occurs.
  67230. */
  67231. onError: (reason: any) => void;
  67232. /**
  67233. * Observable raised after the loader is disposed.
  67234. */
  67235. readonly onDisposeObservable: Observable<void>;
  67236. private _onDisposeObserver;
  67237. /**
  67238. * Callback raised after the loader is disposed.
  67239. */
  67240. onDispose: () => void;
  67241. /**
  67242. * Observable raised after a loader extension is created.
  67243. * Set additional options for a loader extension in this event.
  67244. */
  67245. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  67246. private _onExtensionLoadedObserver;
  67247. /**
  67248. * Callback raised after a loader extension is created.
  67249. */
  67250. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  67251. /**
  67252. * Defines if the loader logging is enabled.
  67253. */
  67254. loggingEnabled: boolean;
  67255. /**
  67256. * Defines if the loader should capture performance counters.
  67257. */
  67258. capturePerformanceCounters: boolean;
  67259. /**
  67260. * Defines if the loader should validate the asset.
  67261. */
  67262. validate: boolean;
  67263. /**
  67264. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  67265. */
  67266. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  67267. private _onValidatedObserver;
  67268. /**
  67269. * Callback raised after a loader extension is created.
  67270. */
  67271. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  67272. private _loader;
  67273. /**
  67274. * Name of the loader ("gltf")
  67275. */
  67276. name: string;
  67277. /**
  67278. * Supported file extensions of the loader (.gltf, .glb)
  67279. */
  67280. extensions: ISceneLoaderPluginExtensions;
  67281. /**
  67282. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  67283. */
  67284. dispose(): void;
  67285. /** @hidden */ private _clear(): void;
  67286. /**
  67287. * The callback called when loading from a url.
  67288. * @param scene scene loading this url
  67289. * @param url url to load
  67290. * @param onSuccess callback called when the file successfully loads
  67291. * @param onProgress callback called while file is loading (if the server supports this mode)
  67292. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  67293. * @param onError callback called when the file fails to load
  67294. * @returns a file request object
  67295. */
  67296. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  67297. /**
  67298. * The callback called when loading from a file object.
  67299. * @param scene scene loading this file
  67300. * @param file defines the file to load
  67301. * @param onSuccess defines the callback to call when data is loaded
  67302. * @param onProgress defines the callback to call during loading process
  67303. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  67304. * @param onError defines the callback to call when an error occurs
  67305. * @returns a file request object
  67306. */
  67307. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  67308. /**
  67309. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  67310. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  67311. * @param scene the scene the meshes should be added to
  67312. * @param data the glTF data to load
  67313. * @param rootUrl root url to load from
  67314. * @param onProgress event that fires when loading progress has occured
  67315. * @param fileName Defines the name of the file to load
  67316. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  67317. */
  67318. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  67319. meshes: AbstractMesh[];
  67320. particleSystems: IParticleSystem[];
  67321. skeletons: Skeleton[];
  67322. animationGroups: AnimationGroup[];
  67323. }>;
  67324. /**
  67325. * Imports all objects from the loaded glTF data and adds them to the scene
  67326. * @param scene the scene the objects should be added to
  67327. * @param data the glTF data to load
  67328. * @param rootUrl root url to load from
  67329. * @param onProgress event that fires when loading progress has occured
  67330. * @param fileName Defines the name of the file to load
  67331. * @returns a promise which completes when objects have been loaded to the scene
  67332. */
  67333. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  67334. /**
  67335. * Load into an asset container.
  67336. * @param scene The scene to load into
  67337. * @param data The data to import
  67338. * @param rootUrl The root url for scene and resources
  67339. * @param onProgress The callback when the load progresses
  67340. * @param fileName Defines the name of the file to load
  67341. * @returns The loaded asset container
  67342. */
  67343. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  67344. /**
  67345. * The callback that returns true if the data can be directly loaded.
  67346. * @param data string containing the file data
  67347. * @returns if the data can be loaded directly
  67348. */
  67349. canDirectLoad(data: string): boolean;
  67350. /**
  67351. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  67352. * @param scene scene loading this data
  67353. * @param data string containing the data
  67354. * @returns data to pass to the plugin
  67355. */
  67356. directLoad(scene: Scene, data: string): any;
  67357. /**
  67358. * The callback that allows custom handling of the root url based on the response url.
  67359. * @param rootUrl the original root url
  67360. * @param responseURL the response url if available
  67361. * @returns the new root url
  67362. */
  67363. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  67364. /**
  67365. * Instantiates a glTF file loader plugin.
  67366. * @returns the created plugin
  67367. */
  67368. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  67369. /**
  67370. * The loader state or null if the loader is not active.
  67371. */
  67372. readonly loaderState: Nullable<GLTFLoaderState>;
  67373. /**
  67374. * Returns a promise that resolves when the asset is completely loaded.
  67375. * @returns a promise that resolves when the asset is completely loaded.
  67376. */
  67377. whenCompleteAsync(): Promise<void>;
  67378. private _validateAsync;
  67379. private _getLoader;
  67380. private _parseJson;
  67381. private _unpackBinaryAsync;
  67382. private _unpackBinaryV1Async;
  67383. private _unpackBinaryV2Async;
  67384. private static _parseVersion;
  67385. private static _compareVersion;
  67386. private static readonly _logSpaces;
  67387. private _logIndentLevel;
  67388. private _loggingEnabled;
  67389. /** @hidden */ private _log: (message: string) => void;
  67390. /** @hidden */ private _logOpen(message: string): void;
  67391. /** @hidden */ private _logClose(): void;
  67392. private _logEnabled;
  67393. private _logDisabled;
  67394. private _capturePerformanceCounters;
  67395. /** @hidden */ private _startPerformanceCounter: (counterName: string) => void;
  67396. /** @hidden */ private _endPerformanceCounter: (counterName: string) => void;
  67397. private _startPerformanceCounterEnabled;
  67398. private _startPerformanceCounterDisabled;
  67399. private _endPerformanceCounterEnabled;
  67400. private _endPerformanceCounterDisabled;
  67401. }
  67402. }
  67403. declare module BABYLON.GLTF1 {
  67404. /**
  67405. * Enums
  67406. * @hidden
  67407. */
  67408. export enum EComponentType {
  67409. BYTE = 5120,
  67410. UNSIGNED_BYTE = 5121,
  67411. SHORT = 5122,
  67412. UNSIGNED_SHORT = 5123,
  67413. FLOAT = 5126
  67414. }
  67415. /** @hidden */
  67416. export enum EShaderType {
  67417. FRAGMENT = 35632,
  67418. VERTEX = 35633
  67419. }
  67420. /** @hidden */
  67421. export enum EParameterType {
  67422. BYTE = 5120,
  67423. UNSIGNED_BYTE = 5121,
  67424. SHORT = 5122,
  67425. UNSIGNED_SHORT = 5123,
  67426. INT = 5124,
  67427. UNSIGNED_INT = 5125,
  67428. FLOAT = 5126,
  67429. FLOAT_VEC2 = 35664,
  67430. FLOAT_VEC3 = 35665,
  67431. FLOAT_VEC4 = 35666,
  67432. INT_VEC2 = 35667,
  67433. INT_VEC3 = 35668,
  67434. INT_VEC4 = 35669,
  67435. BOOL = 35670,
  67436. BOOL_VEC2 = 35671,
  67437. BOOL_VEC3 = 35672,
  67438. BOOL_VEC4 = 35673,
  67439. FLOAT_MAT2 = 35674,
  67440. FLOAT_MAT3 = 35675,
  67441. FLOAT_MAT4 = 35676,
  67442. SAMPLER_2D = 35678
  67443. }
  67444. /** @hidden */
  67445. export enum ETextureWrapMode {
  67446. CLAMP_TO_EDGE = 33071,
  67447. MIRRORED_REPEAT = 33648,
  67448. REPEAT = 10497
  67449. }
  67450. /** @hidden */
  67451. export enum ETextureFilterType {
  67452. NEAREST = 9728,
  67453. LINEAR = 9728,
  67454. NEAREST_MIPMAP_NEAREST = 9984,
  67455. LINEAR_MIPMAP_NEAREST = 9985,
  67456. NEAREST_MIPMAP_LINEAR = 9986,
  67457. LINEAR_MIPMAP_LINEAR = 9987
  67458. }
  67459. /** @hidden */
  67460. export enum ETextureFormat {
  67461. ALPHA = 6406,
  67462. RGB = 6407,
  67463. RGBA = 6408,
  67464. LUMINANCE = 6409,
  67465. LUMINANCE_ALPHA = 6410
  67466. }
  67467. /** @hidden */
  67468. export enum ECullingType {
  67469. FRONT = 1028,
  67470. BACK = 1029,
  67471. FRONT_AND_BACK = 1032
  67472. }
  67473. /** @hidden */
  67474. export enum EBlendingFunction {
  67475. ZERO = 0,
  67476. ONE = 1,
  67477. SRC_COLOR = 768,
  67478. ONE_MINUS_SRC_COLOR = 769,
  67479. DST_COLOR = 774,
  67480. ONE_MINUS_DST_COLOR = 775,
  67481. SRC_ALPHA = 770,
  67482. ONE_MINUS_SRC_ALPHA = 771,
  67483. DST_ALPHA = 772,
  67484. ONE_MINUS_DST_ALPHA = 773,
  67485. CONSTANT_COLOR = 32769,
  67486. ONE_MINUS_CONSTANT_COLOR = 32770,
  67487. CONSTANT_ALPHA = 32771,
  67488. ONE_MINUS_CONSTANT_ALPHA = 32772,
  67489. SRC_ALPHA_SATURATE = 776
  67490. }
  67491. /** @hidden */
  67492. export interface IGLTFProperty {
  67493. extensions?: {
  67494. [key: string]: any;
  67495. };
  67496. extras?: Object;
  67497. }
  67498. /** @hidden */
  67499. export interface IGLTFChildRootProperty extends IGLTFProperty {
  67500. name?: string;
  67501. }
  67502. /** @hidden */
  67503. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  67504. bufferView: string;
  67505. byteOffset: number;
  67506. byteStride: number;
  67507. count: number;
  67508. type: string;
  67509. componentType: EComponentType;
  67510. max?: number[];
  67511. min?: number[];
  67512. name?: string;
  67513. }
  67514. /** @hidden */
  67515. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  67516. buffer: string;
  67517. byteOffset: number;
  67518. byteLength: number;
  67519. byteStride: number;
  67520. target?: number;
  67521. }
  67522. /** @hidden */
  67523. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  67524. uri: string;
  67525. byteLength?: number;
  67526. type?: string;
  67527. }
  67528. /** @hidden */
  67529. export interface IGLTFShader extends IGLTFChildRootProperty {
  67530. uri: string;
  67531. type: EShaderType;
  67532. }
  67533. /** @hidden */
  67534. export interface IGLTFProgram extends IGLTFChildRootProperty {
  67535. attributes: string[];
  67536. fragmentShader: string;
  67537. vertexShader: string;
  67538. }
  67539. /** @hidden */
  67540. export interface IGLTFTechniqueParameter {
  67541. type: number;
  67542. count?: number;
  67543. semantic?: string;
  67544. node?: string;
  67545. value?: number | boolean | string | Array<any>;
  67546. source?: string;
  67547. babylonValue?: any;
  67548. }
  67549. /** @hidden */
  67550. export interface IGLTFTechniqueCommonProfile {
  67551. lightingModel: string;
  67552. texcoordBindings: Object;
  67553. parameters?: Array<any>;
  67554. }
  67555. /** @hidden */
  67556. export interface IGLTFTechniqueStatesFunctions {
  67557. blendColor?: number[];
  67558. blendEquationSeparate?: number[];
  67559. blendFuncSeparate?: number[];
  67560. colorMask: boolean[];
  67561. cullFace: number[];
  67562. }
  67563. /** @hidden */
  67564. export interface IGLTFTechniqueStates {
  67565. enable: number[];
  67566. functions: IGLTFTechniqueStatesFunctions;
  67567. }
  67568. /** @hidden */
  67569. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  67570. parameters: {
  67571. [key: string]: IGLTFTechniqueParameter;
  67572. };
  67573. program: string;
  67574. attributes: {
  67575. [key: string]: string;
  67576. };
  67577. uniforms: {
  67578. [key: string]: string;
  67579. };
  67580. states: IGLTFTechniqueStates;
  67581. }
  67582. /** @hidden */
  67583. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  67584. technique?: string;
  67585. values: string[];
  67586. }
  67587. /** @hidden */
  67588. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  67589. attributes: {
  67590. [key: string]: string;
  67591. };
  67592. indices: string;
  67593. material: string;
  67594. mode?: number;
  67595. }
  67596. /** @hidden */
  67597. export interface IGLTFMesh extends IGLTFChildRootProperty {
  67598. primitives: IGLTFMeshPrimitive[];
  67599. }
  67600. /** @hidden */
  67601. export interface IGLTFImage extends IGLTFChildRootProperty {
  67602. uri: string;
  67603. }
  67604. /** @hidden */
  67605. export interface IGLTFSampler extends IGLTFChildRootProperty {
  67606. magFilter?: number;
  67607. minFilter?: number;
  67608. wrapS?: number;
  67609. wrapT?: number;
  67610. }
  67611. /** @hidden */
  67612. export interface IGLTFTexture extends IGLTFChildRootProperty {
  67613. sampler: string;
  67614. source: string;
  67615. format?: ETextureFormat;
  67616. internalFormat?: ETextureFormat;
  67617. target?: number;
  67618. type?: number;
  67619. babylonTexture?: Texture;
  67620. }
  67621. /** @hidden */
  67622. export interface IGLTFAmbienLight {
  67623. color?: number[];
  67624. }
  67625. /** @hidden */
  67626. export interface IGLTFDirectionalLight {
  67627. color?: number[];
  67628. }
  67629. /** @hidden */
  67630. export interface IGLTFPointLight {
  67631. color?: number[];
  67632. constantAttenuation?: number;
  67633. linearAttenuation?: number;
  67634. quadraticAttenuation?: number;
  67635. }
  67636. /** @hidden */
  67637. export interface IGLTFSpotLight {
  67638. color?: number[];
  67639. constantAttenuation?: number;
  67640. fallOfAngle?: number;
  67641. fallOffExponent?: number;
  67642. linearAttenuation?: number;
  67643. quadraticAttenuation?: number;
  67644. }
  67645. /** @hidden */
  67646. export interface IGLTFLight extends IGLTFChildRootProperty {
  67647. type: string;
  67648. }
  67649. /** @hidden */
  67650. export interface IGLTFCameraOrthographic {
  67651. xmag: number;
  67652. ymag: number;
  67653. zfar: number;
  67654. znear: number;
  67655. }
  67656. /** @hidden */
  67657. export interface IGLTFCameraPerspective {
  67658. aspectRatio: number;
  67659. yfov: number;
  67660. zfar: number;
  67661. znear: number;
  67662. }
  67663. /** @hidden */
  67664. export interface IGLTFCamera extends IGLTFChildRootProperty {
  67665. type: string;
  67666. }
  67667. /** @hidden */
  67668. export interface IGLTFAnimationChannelTarget {
  67669. id: string;
  67670. path: string;
  67671. }
  67672. /** @hidden */
  67673. export interface IGLTFAnimationChannel {
  67674. sampler: string;
  67675. target: IGLTFAnimationChannelTarget;
  67676. }
  67677. /** @hidden */
  67678. export interface IGLTFAnimationSampler {
  67679. input: string;
  67680. output: string;
  67681. interpolation?: string;
  67682. }
  67683. /** @hidden */
  67684. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  67685. channels?: IGLTFAnimationChannel[];
  67686. parameters?: {
  67687. [key: string]: string;
  67688. };
  67689. samplers?: {
  67690. [key: string]: IGLTFAnimationSampler;
  67691. };
  67692. }
  67693. /** @hidden */
  67694. export interface IGLTFNodeInstanceSkin {
  67695. skeletons: string[];
  67696. skin: string;
  67697. meshes: string[];
  67698. }
  67699. /** @hidden */
  67700. export interface IGLTFSkins extends IGLTFChildRootProperty {
  67701. bindShapeMatrix: number[];
  67702. inverseBindMatrices: string;
  67703. jointNames: string[];
  67704. babylonSkeleton?: Skeleton;
  67705. }
  67706. /** @hidden */
  67707. export interface IGLTFNode extends IGLTFChildRootProperty {
  67708. camera?: string;
  67709. children: string[];
  67710. skin?: string;
  67711. jointName?: string;
  67712. light?: string;
  67713. matrix: number[];
  67714. mesh?: string;
  67715. meshes?: string[];
  67716. rotation?: number[];
  67717. scale?: number[];
  67718. translation?: number[];
  67719. babylonNode?: Node;
  67720. }
  67721. /** @hidden */
  67722. export interface IGLTFScene extends IGLTFChildRootProperty {
  67723. nodes: string[];
  67724. }
  67725. /** @hidden */
  67726. export interface IGLTFRuntime {
  67727. extensions: {
  67728. [key: string]: any;
  67729. };
  67730. accessors: {
  67731. [key: string]: IGLTFAccessor;
  67732. };
  67733. buffers: {
  67734. [key: string]: IGLTFBuffer;
  67735. };
  67736. bufferViews: {
  67737. [key: string]: IGLTFBufferView;
  67738. };
  67739. meshes: {
  67740. [key: string]: IGLTFMesh;
  67741. };
  67742. lights: {
  67743. [key: string]: IGLTFLight;
  67744. };
  67745. cameras: {
  67746. [key: string]: IGLTFCamera;
  67747. };
  67748. nodes: {
  67749. [key: string]: IGLTFNode;
  67750. };
  67751. images: {
  67752. [key: string]: IGLTFImage;
  67753. };
  67754. textures: {
  67755. [key: string]: IGLTFTexture;
  67756. };
  67757. shaders: {
  67758. [key: string]: IGLTFShader;
  67759. };
  67760. programs: {
  67761. [key: string]: IGLTFProgram;
  67762. };
  67763. samplers: {
  67764. [key: string]: IGLTFSampler;
  67765. };
  67766. techniques: {
  67767. [key: string]: IGLTFTechnique;
  67768. };
  67769. materials: {
  67770. [key: string]: IGLTFMaterial;
  67771. };
  67772. animations: {
  67773. [key: string]: IGLTFAnimation;
  67774. };
  67775. skins: {
  67776. [key: string]: IGLTFSkins;
  67777. };
  67778. currentScene?: Object;
  67779. scenes: {
  67780. [key: string]: IGLTFScene;
  67781. };
  67782. extensionsUsed: string[];
  67783. extensionsRequired?: string[];
  67784. buffersCount: number;
  67785. shaderscount: number;
  67786. scene: Scene;
  67787. rootUrl: string;
  67788. loadedBufferCount: number;
  67789. loadedBufferViews: {
  67790. [name: string]: ArrayBufferView;
  67791. };
  67792. loadedShaderCount: number;
  67793. importOnlyMeshes: boolean;
  67794. importMeshesNames?: string[];
  67795. dummyNodes: Node[];
  67796. }
  67797. /** @hidden */
  67798. export interface INodeToRoot {
  67799. bone: Bone;
  67800. node: IGLTFNode;
  67801. id: string;
  67802. }
  67803. /** @hidden */
  67804. export interface IJointNode {
  67805. node: IGLTFNode;
  67806. id: string;
  67807. }
  67808. }
  67809. declare module BABYLON.GLTF1 {
  67810. /**
  67811. * Utils functions for GLTF
  67812. * @hidden
  67813. */
  67814. export class GLTFUtils {
  67815. /**
  67816. * Sets the given "parameter" matrix
  67817. * @param scene: the Scene object
  67818. * @param source: the source node where to pick the matrix
  67819. * @param parameter: the GLTF technique parameter
  67820. * @param uniformName: the name of the shader's uniform
  67821. * @param shaderMaterial: the shader material
  67822. */
  67823. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  67824. /**
  67825. * Sets the given "parameter" matrix
  67826. * @param shaderMaterial: the shader material
  67827. * @param uniform: the name of the shader's uniform
  67828. * @param value: the value of the uniform
  67829. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  67830. */
  67831. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  67832. /**
  67833. * Returns the wrap mode of the texture
  67834. * @param mode: the mode value
  67835. */
  67836. static GetWrapMode(mode: number): number;
  67837. /**
  67838. * Returns the byte stride giving an accessor
  67839. * @param accessor: the GLTF accessor objet
  67840. */
  67841. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  67842. /**
  67843. * Returns the texture filter mode giving a mode value
  67844. * @param mode: the filter mode value
  67845. */
  67846. static GetTextureFilterMode(mode: number): ETextureFilterType;
  67847. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  67848. /**
  67849. * Returns a buffer from its accessor
  67850. * @param gltfRuntime: the GLTF runtime
  67851. * @param accessor: the GLTF accessor
  67852. */
  67853. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  67854. /**
  67855. * Decodes a buffer view into a string
  67856. * @param view: the buffer view
  67857. */
  67858. static DecodeBufferToText(view: ArrayBufferView): string;
  67859. /**
  67860. * Returns the default material of gltf. Related to
  67861. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  67862. * @param scene: the Babylon.js scene
  67863. */
  67864. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  67865. private static _DefaultMaterial;
  67866. }
  67867. }
  67868. declare module BABYLON.GLTF1 {
  67869. /**
  67870. * Implementation of the base glTF spec
  67871. * @hidden
  67872. */
  67873. export class GLTFLoaderBase {
  67874. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  67875. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  67876. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  67877. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  67878. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  67879. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  67880. }
  67881. /**
  67882. * glTF V1 Loader
  67883. * @hidden
  67884. */
  67885. export class GLTFLoader implements IGLTFLoader {
  67886. static Extensions: {
  67887. [name: string]: GLTFLoaderExtension;
  67888. };
  67889. static RegisterExtension(extension: GLTFLoaderExtension): void;
  67890. state: Nullable<GLTFLoaderState>;
  67891. dispose(): void;
  67892. private _importMeshAsync;
  67893. /**
  67894. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  67895. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  67896. * @param scene the scene the meshes should be added to
  67897. * @param data gltf data containing information of the meshes in a loaded file
  67898. * @param rootUrl root url to load from
  67899. * @param onProgress event that fires when loading progress has occured
  67900. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  67901. */
  67902. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  67903. meshes: AbstractMesh[];
  67904. particleSystems: IParticleSystem[];
  67905. skeletons: Skeleton[];
  67906. animationGroups: AnimationGroup[];
  67907. }>;
  67908. private _loadAsync;
  67909. /**
  67910. * Imports all objects from a loaded gltf file and adds them to the scene
  67911. * @param scene the scene the objects should be added to
  67912. * @param data gltf data containing information of the meshes in a loaded file
  67913. * @param rootUrl root url to load from
  67914. * @param onProgress event that fires when loading progress has occured
  67915. * @returns a promise which completes when objects have been loaded to the scene
  67916. */
  67917. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  67918. private _loadShadersAsync;
  67919. private _loadBuffersAsync;
  67920. private _createNodes;
  67921. }
  67922. /** @hidden */
  67923. export abstract class GLTFLoaderExtension {
  67924. private _name;
  67925. constructor(name: string);
  67926. readonly name: string;
  67927. /**
  67928. * Defines an override for loading the runtime
  67929. * Return true to stop further extensions from loading the runtime
  67930. */
  67931. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  67932. /**
  67933. * Defines an onverride for creating gltf runtime
  67934. * Return true to stop further extensions from creating the runtime
  67935. */
  67936. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  67937. /**
  67938. * Defines an override for loading buffers
  67939. * Return true to stop further extensions from loading this buffer
  67940. */
  67941. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  67942. /**
  67943. * Defines an override for loading texture buffers
  67944. * Return true to stop further extensions from loading this texture data
  67945. */
  67946. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  67947. /**
  67948. * Defines an override for creating textures
  67949. * Return true to stop further extensions from loading this texture
  67950. */
  67951. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  67952. /**
  67953. * Defines an override for loading shader strings
  67954. * Return true to stop further extensions from loading this shader data
  67955. */
  67956. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  67957. /**
  67958. * Defines an override for loading materials
  67959. * Return true to stop further extensions from loading this material
  67960. */
  67961. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  67962. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  67963. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  67964. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  67965. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  67966. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  67967. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  67968. private static LoadTextureBufferAsync;
  67969. private static CreateTextureAsync;
  67970. private static ApplyExtensions;
  67971. }
  67972. }
  67973. declare module BABYLON.GLTF1 {
  67974. /** @hidden */
  67975. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  67976. private _bin;
  67977. constructor();
  67978. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  67979. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  67980. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  67981. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  67982. }
  67983. }
  67984. declare module BABYLON.GLTF1 {
  67985. /** @hidden */
  67986. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  67987. constructor();
  67988. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  67989. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  67990. private _loadTexture;
  67991. }
  67992. }
  67993. declare module BABYLON.GLTF2.Loader {
  67994. /**
  67995. * Loader interface with an index field.
  67996. */
  67997. export interface IArrayItem {
  67998. /**
  67999. * The index of this item in the array.
  68000. */
  68001. index: number;
  68002. }
  68003. /**
  68004. * Loader interface with additional members.
  68005. */
  68006. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  68007. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  68008. /** @hidden */ private _babylonVertexBuffer?: Promise<VertexBuffer>;
  68009. }
  68010. /**
  68011. * Loader interface with additional members.
  68012. */
  68013. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  68014. }
  68015. /** @hidden */
  68016. export interface _IAnimationSamplerData {
  68017. input: Float32Array;
  68018. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  68019. output: Float32Array;
  68020. }
  68021. /**
  68022. * Loader interface with additional members.
  68023. */
  68024. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  68025. /** @hidden */ private _data?: Promise<_IAnimationSamplerData>;
  68026. }
  68027. /**
  68028. * Loader interface with additional members.
  68029. */
  68030. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  68031. channels: IAnimationChannel[];
  68032. samplers: IAnimationSampler[];
  68033. /** @hidden */ private _babylonAnimationGroup?: AnimationGroup;
  68034. }
  68035. /**
  68036. * Loader interface with additional members.
  68037. */
  68038. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  68039. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  68040. }
  68041. /**
  68042. * Loader interface with additional members.
  68043. */
  68044. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  68045. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  68046. /** @hidden */ private _babylonBuffer?: Promise<Buffer>;
  68047. }
  68048. /**
  68049. * Loader interface with additional members.
  68050. */
  68051. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  68052. }
  68053. /**
  68054. * Loader interface with additional members.
  68055. */
  68056. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  68057. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  68058. }
  68059. /**
  68060. * Loader interface with additional members.
  68061. */
  68062. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  68063. }
  68064. /**
  68065. * Loader interface with additional members.
  68066. */
  68067. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  68068. }
  68069. /**
  68070. * Loader interface with additional members.
  68071. */
  68072. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  68073. baseColorTexture?: ITextureInfo;
  68074. metallicRoughnessTexture?: ITextureInfo;
  68075. }
  68076. /**
  68077. * Loader interface with additional members.
  68078. */
  68079. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  68080. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  68081. normalTexture?: IMaterialNormalTextureInfo;
  68082. occlusionTexture?: IMaterialOcclusionTextureInfo;
  68083. emissiveTexture?: ITextureInfo;
  68084. /** @hidden */ private _data?: {
  68085. [babylonDrawMode: number]: {
  68086. babylonMaterial: Material;
  68087. babylonMeshes: AbstractMesh[];
  68088. promise: Promise<void>;
  68089. };
  68090. };
  68091. }
  68092. /**
  68093. * Loader interface with additional members.
  68094. */
  68095. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  68096. primitives: IMeshPrimitive[];
  68097. }
  68098. /**
  68099. * Loader interface with additional members.
  68100. */
  68101. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  68102. /** @hidden */ private _instanceData?: {
  68103. babylonSourceMesh: Mesh;
  68104. promise: Promise<any>;
  68105. };
  68106. }
  68107. /**
  68108. * Loader interface with additional members.
  68109. */
  68110. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  68111. /**
  68112. * The parent glTF node.
  68113. */
  68114. parent?: INode;
  68115. /** @hidden */ private _babylonTransformNode?: TransformNode;
  68116. /** @hidden */ private _primitiveBabylonMeshes?: AbstractMesh[];
  68117. /** @hidden */ private _babylonBones?: Bone[];
  68118. /** @hidden */ private _numMorphTargets?: number;
  68119. }
  68120. /** @hidden */
  68121. export interface _ISamplerData {
  68122. noMipMaps: boolean;
  68123. samplingMode: number;
  68124. wrapU: number;
  68125. wrapV: number;
  68126. }
  68127. /**
  68128. * Loader interface with additional members.
  68129. */
  68130. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  68131. /** @hidden */ private _data?: _ISamplerData;
  68132. }
  68133. /**
  68134. * Loader interface with additional members.
  68135. */
  68136. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  68137. }
  68138. /**
  68139. * Loader interface with additional members.
  68140. */
  68141. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  68142. /** @hidden */ private _data?: {
  68143. babylonSkeleton: Skeleton;
  68144. promise: Promise<void>;
  68145. };
  68146. }
  68147. /**
  68148. * Loader interface with additional members.
  68149. */
  68150. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  68151. }
  68152. /**
  68153. * Loader interface with additional members.
  68154. */
  68155. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  68156. }
  68157. /**
  68158. * Loader interface with additional members.
  68159. */
  68160. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  68161. accessors?: IAccessor[];
  68162. animations?: IAnimation[];
  68163. buffers?: IBuffer[];
  68164. bufferViews?: IBufferView[];
  68165. cameras?: ICamera[];
  68166. images?: IImage[];
  68167. materials?: IMaterial[];
  68168. meshes?: IMesh[];
  68169. nodes?: INode[];
  68170. samplers?: ISampler[];
  68171. scenes?: IScene[];
  68172. skins?: ISkin[];
  68173. textures?: ITexture[];
  68174. }
  68175. }
  68176. declare module BABYLON.GLTF2 {
  68177. /**
  68178. * Interface for a glTF loader extension.
  68179. */
  68180. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  68181. /**
  68182. * Called after the loader state changes to LOADING.
  68183. */
  68184. onLoading?(): void;
  68185. /**
  68186. * Called after the loader state changes to READY.
  68187. */
  68188. onReady?(): void;
  68189. /**
  68190. * Define this method to modify the default behavior when loading scenes.
  68191. * @param context The context when loading the asset
  68192. * @param scene The glTF scene property
  68193. * @returns A promise that resolves when the load is complete or null if not handled
  68194. */
  68195. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  68196. /**
  68197. * Define this method to modify the default behavior when loading nodes.
  68198. * @param context The context when loading the asset
  68199. * @param node The glTF node property
  68200. * @param assign A function called synchronously after parsing the glTF properties
  68201. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  68202. */
  68203. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68204. /**
  68205. * Define this method to modify the default behavior when loading cameras.
  68206. * @param context The context when loading the asset
  68207. * @param camera The glTF camera property
  68208. * @param assign A function called synchronously after parsing the glTF properties
  68209. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  68210. */
  68211. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  68212. /**
  68213. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  68214. * @param context The context when loading the asset
  68215. * @param primitive The glTF mesh primitive property
  68216. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  68217. */ private _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  68218. /**
  68219. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  68220. * @param context The context when loading the asset
  68221. * @param name The mesh name when loading the asset
  68222. * @param node The glTF node when loading the asset
  68223. * @param mesh The glTF mesh when loading the asset
  68224. * @param primitive The glTF mesh primitive property
  68225. * @param assign A function called synchronously after parsing the glTF properties
  68226. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  68227. */ private _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  68228. /**
  68229. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  68230. * @param context The context when loading the asset
  68231. * @param material The glTF material property
  68232. * @param assign A function called synchronously after parsing the glTF properties
  68233. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  68234. */ private _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  68235. /**
  68236. * Define this method to modify the default behavior when creating materials.
  68237. * @param context The context when loading the asset
  68238. * @param material The glTF material property
  68239. * @param babylonDrawMode The draw mode for the Babylon material
  68240. * @returns The Babylon material or null if not handled
  68241. */
  68242. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  68243. /**
  68244. * Define this method to modify the default behavior when loading material properties.
  68245. * @param context The context when loading the asset
  68246. * @param material The glTF material property
  68247. * @param babylonMaterial The Babylon material
  68248. * @returns A promise that resolves when the load is complete or null if not handled
  68249. */
  68250. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68251. /**
  68252. * Define this method to modify the default behavior when loading texture infos.
  68253. * @param context The context when loading the asset
  68254. * @param textureInfo The glTF texture info property
  68255. * @param assign A function called synchronously after parsing the glTF properties
  68256. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  68257. */
  68258. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  68259. /**
  68260. * Define this method to modify the default behavior when loading animations.
  68261. * @param context The context when loading the asset
  68262. * @param animation The glTF animation property
  68263. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  68264. */
  68265. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  68266. /**
  68267. * @hidden Define this method to modify the default behavior when loading skins.
  68268. * @param context The context when loading the asset
  68269. * @param node The glTF node property
  68270. * @param skin The glTF skin property
  68271. * @returns A promise that resolves when the load is complete or null if not handled
  68272. */ private _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  68273. /**
  68274. * @hidden Define this method to modify the default behavior when loading uris.
  68275. * @param context The context when loading the asset
  68276. * @param property The glTF property associated with the uri
  68277. * @param uri The uri to load
  68278. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  68279. */ private _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  68280. /**
  68281. * Define this method to modify the default behavior when loading buffer views.
  68282. * @param context The context when loading the asset
  68283. * @param bufferView The glTF buffer view property
  68284. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  68285. */
  68286. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  68287. /**
  68288. * Define this method to modify the default behavior when loading buffers.
  68289. * @param context The context when loading the asset
  68290. * @param buffer The glTF buffer property
  68291. * @param byteOffset The byte offset to load
  68292. * @param byteLength The byte length to load
  68293. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  68294. */
  68295. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  68296. }
  68297. }
  68298. declare module BABYLON.GLTF2 {
  68299. /**
  68300. * Helper class for working with arrays when loading the glTF asset
  68301. */
  68302. export class ArrayItem {
  68303. /**
  68304. * Gets an item from the given array.
  68305. * @param context The context when loading the asset
  68306. * @param array The array to get the item from
  68307. * @param index The index to the array
  68308. * @returns The array item
  68309. */
  68310. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  68311. /**
  68312. * Assign an `index` field to each item of the given array.
  68313. * @param array The array of items
  68314. */
  68315. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  68316. }
  68317. /**
  68318. * The glTF 2.0 loader
  68319. */
  68320. export class GLTFLoader implements IGLTFLoader {
  68321. /** @hidden */ private _completePromises: Promise<any>[];
  68322. private _disposed;
  68323. private _parent;
  68324. private _state;
  68325. private _extensions;
  68326. private _rootUrl;
  68327. private _fileName;
  68328. private _uniqueRootUrl;
  68329. private _gltf;
  68330. private _bin;
  68331. private _babylonScene;
  68332. private _rootBabylonMesh;
  68333. private _defaultBabylonMaterialData;
  68334. private _progressCallback?;
  68335. private _requests;
  68336. private static readonly _DefaultSampler;
  68337. private static _ExtensionNames;
  68338. private static _ExtensionFactories;
  68339. /**
  68340. * Registers a loader extension.
  68341. * @param name The name of the loader extension.
  68342. * @param factory The factory function that creates the loader extension.
  68343. */
  68344. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  68345. /**
  68346. * Unregisters a loader extension.
  68347. * @param name The name of the loader extenion.
  68348. * @returns A boolean indicating whether the extension has been unregistered
  68349. */
  68350. static UnregisterExtension(name: string): boolean;
  68351. /**
  68352. * Gets the loader state.
  68353. */
  68354. readonly state: Nullable<GLTFLoaderState>;
  68355. /**
  68356. * The object that represents the glTF JSON.
  68357. */
  68358. readonly gltf: IGLTF;
  68359. /**
  68360. * The BIN chunk of a binary glTF.
  68361. */
  68362. readonly bin: Nullable<IDataBuffer>;
  68363. /**
  68364. * The parent file loader.
  68365. */
  68366. readonly parent: GLTFFileLoader;
  68367. /**
  68368. * The Babylon scene when loading the asset.
  68369. */
  68370. readonly babylonScene: Scene;
  68371. /**
  68372. * The root Babylon mesh when loading the asset.
  68373. */
  68374. readonly rootBabylonMesh: Mesh;
  68375. /** @hidden */
  68376. constructor(parent: GLTFFileLoader);
  68377. /** @hidden */
  68378. dispose(): void;
  68379. /** @hidden */
  68380. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  68381. meshes: AbstractMesh[];
  68382. particleSystems: IParticleSystem[];
  68383. skeletons: Skeleton[];
  68384. animationGroups: AnimationGroup[];
  68385. }>;
  68386. /** @hidden */
  68387. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  68388. private _loadAsync;
  68389. private _loadData;
  68390. private _setupData;
  68391. private _loadExtensions;
  68392. private _checkExtensions;
  68393. private _setState;
  68394. private _createRootNode;
  68395. /**
  68396. * Loads a glTF scene.
  68397. * @param context The context when loading the asset
  68398. * @param scene The glTF scene property
  68399. * @returns A promise that resolves when the load is complete
  68400. */
  68401. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  68402. private _forEachPrimitive;
  68403. private _getMeshes;
  68404. private _getSkeletons;
  68405. private _getAnimationGroups;
  68406. private _startAnimations;
  68407. /**
  68408. * Loads a glTF node.
  68409. * @param context The context when loading the asset
  68410. * @param node The glTF node property
  68411. * @param assign A function called synchronously after parsing the glTF properties
  68412. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  68413. */
  68414. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  68415. private _loadMeshAsync;
  68416. /**
  68417. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  68418. * @param context The context when loading the asset
  68419. * @param name The mesh name when loading the asset
  68420. * @param node The glTF node when loading the asset
  68421. * @param mesh The glTF mesh when loading the asset
  68422. * @param primitive The glTF mesh primitive property
  68423. * @param assign A function called synchronously after parsing the glTF properties
  68424. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  68425. */ private _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  68426. private _loadVertexDataAsync;
  68427. private _createMorphTargets;
  68428. private _loadMorphTargetsAsync;
  68429. private _loadMorphTargetVertexDataAsync;
  68430. private static _LoadTransform;
  68431. private _loadSkinAsync;
  68432. private _loadBones;
  68433. private _loadBone;
  68434. private _loadSkinInverseBindMatricesDataAsync;
  68435. private _updateBoneMatrices;
  68436. private _getNodeMatrix;
  68437. /**
  68438. * Loads a glTF camera.
  68439. * @param context The context when loading the asset
  68440. * @param camera The glTF camera property
  68441. * @param assign A function called synchronously after parsing the glTF properties
  68442. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  68443. */
  68444. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  68445. private _loadAnimationsAsync;
  68446. /**
  68447. * Loads a glTF animation.
  68448. * @param context The context when loading the asset
  68449. * @param animation The glTF animation property
  68450. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  68451. */
  68452. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  68453. /**
  68454. * @hidden Loads a glTF animation channel.
  68455. * @param context The context when loading the asset
  68456. * @param animationContext The context of the animation when loading the asset
  68457. * @param animation The glTF animation property
  68458. * @param channel The glTF animation channel property
  68459. * @param babylonAnimationGroup The babylon animation group property
  68460. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  68461. * @returns A void promise when the channel load is complete
  68462. */ private _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  68463. private _loadAnimationSamplerAsync;
  68464. private _loadBufferAsync;
  68465. /**
  68466. * Loads a glTF buffer view.
  68467. * @param context The context when loading the asset
  68468. * @param bufferView The glTF buffer view property
  68469. * @returns A promise that resolves with the loaded data when the load is complete
  68470. */
  68471. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  68472. private _loadAccessorAsync;
  68473. private _loadFloatAccessorAsync;
  68474. private _loadIndicesAccessorAsync;
  68475. private _loadVertexBufferViewAsync;
  68476. private _loadVertexAccessorAsync;
  68477. private _loadMaterialMetallicRoughnessPropertiesAsync;
  68478. /** @hidden */ private _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  68479. private _createDefaultMaterial;
  68480. /**
  68481. * Creates a Babylon material from a glTF material.
  68482. * @param context The context when loading the asset
  68483. * @param material The glTF material property
  68484. * @param babylonDrawMode The draw mode for the Babylon material
  68485. * @returns The Babylon material
  68486. */
  68487. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  68488. /**
  68489. * Loads properties from a glTF material into a Babylon material.
  68490. * @param context The context when loading the asset
  68491. * @param material The glTF material property
  68492. * @param babylonMaterial The Babylon material
  68493. * @returns A promise that resolves when the load is complete
  68494. */
  68495. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  68496. /**
  68497. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  68498. * @param context The context when loading the asset
  68499. * @param material The glTF material property
  68500. * @param babylonMaterial The Babylon material
  68501. * @returns A promise that resolves when the load is complete
  68502. */
  68503. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  68504. /**
  68505. * Loads the alpha properties from a glTF material into a Babylon material.
  68506. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  68507. * @param context The context when loading the asset
  68508. * @param material The glTF material property
  68509. * @param babylonMaterial The Babylon material
  68510. */
  68511. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  68512. /**
  68513. * Loads a glTF texture info.
  68514. * @param context The context when loading the asset
  68515. * @param textureInfo The glTF texture info property
  68516. * @param assign A function called synchronously after parsing the glTF properties
  68517. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  68518. */
  68519. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  68520. private _loadTextureAsync;
  68521. private _loadSampler;
  68522. /**
  68523. * Loads a glTF image.
  68524. * @param context The context when loading the asset
  68525. * @param image The glTF image property
  68526. * @returns A promise that resolves with the loaded data when the load is complete
  68527. */
  68528. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  68529. /**
  68530. * Loads a glTF uri.
  68531. * @param context The context when loading the asset
  68532. * @param property The glTF property associated with the uri
  68533. * @param uri The base64 or relative uri
  68534. * @returns A promise that resolves with the loaded data when the load is complete
  68535. */
  68536. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  68537. private _onProgress;
  68538. /**
  68539. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  68540. * @param babylonObject the Babylon object with metadata
  68541. * @param pointer the JSON pointer
  68542. */
  68543. static AddPointerMetadata(babylonObject: {
  68544. metadata: any;
  68545. }, pointer: string): void;
  68546. private static _GetTextureWrapMode;
  68547. private static _GetTextureSamplingMode;
  68548. private static _GetTypedArrayConstructor;
  68549. private static _GetTypedArray;
  68550. private static _GetNumComponents;
  68551. private static _ValidateUri;
  68552. private static _GetDrawMode;
  68553. private _compileMaterialsAsync;
  68554. private _compileShadowGeneratorsAsync;
  68555. private _forEachExtensions;
  68556. private _applyExtensions;
  68557. private _extensionsOnLoading;
  68558. private _extensionsOnReady;
  68559. private _extensionsLoadSceneAsync;
  68560. private _extensionsLoadNodeAsync;
  68561. private _extensionsLoadCameraAsync;
  68562. private _extensionsLoadVertexDataAsync;
  68563. private _extensionsLoadMeshPrimitiveAsync;
  68564. private _extensionsLoadMaterialAsync;
  68565. private _extensionsCreateMaterial;
  68566. private _extensionsLoadMaterialPropertiesAsync;
  68567. private _extensionsLoadTextureInfoAsync;
  68568. private _extensionsLoadAnimationAsync;
  68569. private _extensionsLoadSkinAsync;
  68570. private _extensionsLoadUriAsync;
  68571. private _extensionsLoadBufferViewAsync;
  68572. private _extensionsLoadBufferAsync;
  68573. /**
  68574. * Helper method called by a loader extension to load an glTF extension.
  68575. * @param context The context when loading the asset
  68576. * @param property The glTF property to load the extension from
  68577. * @param extensionName The name of the extension to load
  68578. * @param actionAsync The action to run
  68579. * @returns The promise returned by actionAsync or null if the extension does not exist
  68580. */
  68581. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  68582. /**
  68583. * Helper method called by a loader extension to load a glTF extra.
  68584. * @param context The context when loading the asset
  68585. * @param property The glTF property to load the extra from
  68586. * @param extensionName The name of the extension to load
  68587. * @param actionAsync The action to run
  68588. * @returns The promise returned by actionAsync or null if the extra does not exist
  68589. */
  68590. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  68591. /**
  68592. * Checks for presence of an extension.
  68593. * @param name The name of the extension to check
  68594. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  68595. */
  68596. isExtensionUsed(name: string): boolean;
  68597. /**
  68598. * Increments the indentation level and logs a message.
  68599. * @param message The message to log
  68600. */
  68601. logOpen(message: string): void;
  68602. /**
  68603. * Decrements the indentation level.
  68604. */
  68605. logClose(): void;
  68606. /**
  68607. * Logs a message
  68608. * @param message The message to log
  68609. */
  68610. log(message: string): void;
  68611. /**
  68612. * Starts a performance counter.
  68613. * @param counterName The name of the performance counter
  68614. */
  68615. startPerformanceCounter(counterName: string): void;
  68616. /**
  68617. * Ends a performance counter.
  68618. * @param counterName The name of the performance counter
  68619. */
  68620. endPerformanceCounter(counterName: string): void;
  68621. }
  68622. }
  68623. declare module BABYLON.GLTF2.Loader.Extensions {
  68624. /**
  68625. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  68626. */
  68627. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  68628. /** The name of this extension. */
  68629. readonly name: string;
  68630. /** Defines whether this extension is enabled. */
  68631. enabled: boolean;
  68632. private _loader;
  68633. private _lights?;
  68634. /** @hidden */
  68635. constructor(loader: GLTFLoader);
  68636. /** @hidden */
  68637. dispose(): void;
  68638. /** @hidden */
  68639. onLoading(): void;
  68640. /** @hidden */
  68641. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  68642. private _loadLightAsync;
  68643. }
  68644. }
  68645. declare module BABYLON.GLTF2.Loader.Extensions {
  68646. /**
  68647. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  68648. */
  68649. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  68650. /** The name of this extension. */
  68651. readonly name: string;
  68652. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  68653. dracoCompression?: DracoCompression;
  68654. /** Defines whether this extension is enabled. */
  68655. enabled: boolean;
  68656. private _loader;
  68657. /** @hidden */
  68658. constructor(loader: GLTFLoader);
  68659. /** @hidden */
  68660. dispose(): void;
  68661. /** @hidden */ private _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  68662. }
  68663. }
  68664. declare module BABYLON.GLTF2.Loader.Extensions {
  68665. /**
  68666. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  68667. */
  68668. export class KHR_lights implements IGLTFLoaderExtension {
  68669. /** The name of this extension. */
  68670. readonly name: string;
  68671. /** Defines whether this extension is enabled. */
  68672. enabled: boolean;
  68673. private _loader;
  68674. private _lights?;
  68675. /** @hidden */
  68676. constructor(loader: GLTFLoader);
  68677. /** @hidden */
  68678. dispose(): void;
  68679. /** @hidden */
  68680. onLoading(): void;
  68681. /** @hidden */
  68682. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68683. }
  68684. }
  68685. declare module BABYLON.GLTF2.Loader.Extensions {
  68686. /**
  68687. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  68688. */
  68689. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  68690. /** The name of this extension. */
  68691. readonly name: string;
  68692. /** Defines whether this extension is enabled. */
  68693. enabled: boolean;
  68694. private _loader;
  68695. /** @hidden */
  68696. constructor(loader: GLTFLoader);
  68697. /** @hidden */
  68698. dispose(): void;
  68699. /** @hidden */
  68700. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68701. private _loadSpecularGlossinessPropertiesAsync;
  68702. }
  68703. }
  68704. declare module BABYLON.GLTF2.Loader.Extensions {
  68705. /**
  68706. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  68707. */
  68708. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  68709. /** The name of this extension. */
  68710. readonly name: string;
  68711. /** Defines whether this extension is enabled. */
  68712. enabled: boolean;
  68713. private _loader;
  68714. /** @hidden */
  68715. constructor(loader: GLTFLoader);
  68716. /** @hidden */
  68717. dispose(): void;
  68718. /** @hidden */
  68719. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68720. private _loadUnlitPropertiesAsync;
  68721. }
  68722. }
  68723. declare module BABYLON.GLTF2.Loader.Extensions {
  68724. /**
  68725. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  68726. */
  68727. export class KHR_texture_transform implements IGLTFLoaderExtension {
  68728. /** The name of this extension. */
  68729. readonly name: string;
  68730. /** Defines whether this extension is enabled. */
  68731. enabled: boolean;
  68732. private _loader;
  68733. /** @hidden */
  68734. constructor(loader: GLTFLoader);
  68735. /** @hidden */
  68736. dispose(): void;
  68737. /** @hidden */
  68738. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  68739. }
  68740. }
  68741. declare module BABYLON.GLTF2.Loader.Extensions {
  68742. /**
  68743. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  68744. */
  68745. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  68746. /** The name of this extension. */
  68747. readonly name: string;
  68748. /** Defines whether this extension is enabled. */
  68749. enabled: boolean;
  68750. private _loader;
  68751. private _clips;
  68752. private _emitters;
  68753. /** @hidden */
  68754. constructor(loader: GLTFLoader);
  68755. /** @hidden */
  68756. dispose(): void;
  68757. /** @hidden */
  68758. onLoading(): void;
  68759. /** @hidden */
  68760. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  68761. /** @hidden */
  68762. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68763. /** @hidden */
  68764. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  68765. private _loadClipAsync;
  68766. private _loadEmitterAsync;
  68767. private _getEventAction;
  68768. private _loadAnimationEventAsync;
  68769. }
  68770. }
  68771. declare module BABYLON.GLTF2.Loader.Extensions {
  68772. /**
  68773. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  68774. */
  68775. export class MSFT_lod implements IGLTFLoaderExtension {
  68776. /** The name of this extension. */
  68777. readonly name: string;
  68778. /** Defines whether this extension is enabled. */
  68779. enabled: boolean;
  68780. /**
  68781. * Maximum number of LODs to load, starting from the lowest LOD.
  68782. */
  68783. maxLODsToLoad: number;
  68784. /**
  68785. * Observable raised when all node LODs of one level are loaded.
  68786. * The event data is the index of the loaded LOD starting from zero.
  68787. * Dispose the loader to cancel the loading of the next level of LODs.
  68788. */
  68789. onNodeLODsLoadedObservable: Observable<number>;
  68790. /**
  68791. * Observable raised when all material LODs of one level are loaded.
  68792. * The event data is the index of the loaded LOD starting from zero.
  68793. * Dispose the loader to cancel the loading of the next level of LODs.
  68794. */
  68795. onMaterialLODsLoadedObservable: Observable<number>;
  68796. private _loader;
  68797. private _nodeIndexLOD;
  68798. private _nodeSignalLODs;
  68799. private _nodePromiseLODs;
  68800. private _materialIndexLOD;
  68801. private _materialSignalLODs;
  68802. private _materialPromiseLODs;
  68803. private _indexLOD;
  68804. private _bufferLODs;
  68805. /** @hidden */
  68806. constructor(loader: GLTFLoader);
  68807. /** @hidden */
  68808. dispose(): void;
  68809. /** @hidden */
  68810. onReady(): void;
  68811. /** @hidden */
  68812. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68813. /** @hidden */ private _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  68814. /** @hidden */ private _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  68815. /** @hidden */
  68816. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  68817. private _loadBufferLOD;
  68818. /**
  68819. * Gets an array of LOD properties from lowest to highest.
  68820. */
  68821. private _getLODs;
  68822. private _disposeUnusedMaterials;
  68823. }
  68824. }
  68825. declare module BABYLON.GLTF2.Loader.Extensions {
  68826. /** @hidden */
  68827. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  68828. readonly name: string;
  68829. enabled: boolean;
  68830. private _loader;
  68831. constructor(loader: GLTFLoader);
  68832. dispose(): void;
  68833. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68834. }
  68835. }
  68836. declare module BABYLON.GLTF2.Loader.Extensions {
  68837. /** @hidden */
  68838. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  68839. readonly name: string;
  68840. enabled: boolean;
  68841. private _loader;
  68842. constructor(loader: GLTFLoader);
  68843. dispose(): void;
  68844. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68845. }
  68846. }
  68847. declare module BABYLON.GLTF2.Loader.Extensions {
  68848. /**
  68849. * Store glTF extras (if present) in BJS objects' metadata
  68850. */
  68851. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  68852. /** The name of this extension. */
  68853. readonly name: string;
  68854. /** Defines whether this extension is enabled. */
  68855. enabled: boolean;
  68856. private _loader;
  68857. private _assignExtras;
  68858. /** @hidden */
  68859. constructor(loader: GLTFLoader);
  68860. /** @hidden */
  68861. dispose(): void;
  68862. /** @hidden */
  68863. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68864. /** @hidden */
  68865. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  68866. /** @hidden */
  68867. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  68868. }
  68869. }
  68870. declare module BABYLON {
  68871. /**
  68872. * Class reading and parsing the MTL file bundled with the obj file.
  68873. */
  68874. export class MTLFileLoader {
  68875. /**
  68876. * All material loaded from the mtl will be set here
  68877. */
  68878. materials: StandardMaterial[];
  68879. /**
  68880. * This function will read the mtl file and create each material described inside
  68881. * This function could be improve by adding :
  68882. * -some component missing (Ni, Tf...)
  68883. * -including the specific options available
  68884. *
  68885. * @param scene defines the scene the material will be created in
  68886. * @param data defines the mtl data to parse
  68887. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  68888. */
  68889. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  68890. /**
  68891. * Gets the texture for the material.
  68892. *
  68893. * If the material is imported from input file,
  68894. * We sanitize the url to ensure it takes the textre from aside the material.
  68895. *
  68896. * @param rootUrl The root url to load from
  68897. * @param value The value stored in the mtl
  68898. * @return The Texture
  68899. */
  68900. private static _getTexture;
  68901. }
  68902. /**
  68903. * Options for loading OBJ/MTL files
  68904. */
  68905. type MeshLoadOptions = {
  68906. /**
  68907. * Defines if UVs are optimized by default during load.
  68908. */
  68909. OptimizeWithUV: boolean;
  68910. /**
  68911. * Defines custom scaling of UV coordinates of loaded meshes.
  68912. */
  68913. UVScaling: Vector2;
  68914. /**
  68915. * Invert model on y-axis (does a model scaling inversion)
  68916. */
  68917. InvertY: boolean;
  68918. /**
  68919. * Invert Y-Axis of referenced textures on load
  68920. */
  68921. InvertTextureY: boolean;
  68922. /**
  68923. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  68924. */
  68925. ImportVertexColors: boolean;
  68926. /**
  68927. * Compute the normals for the model, even if normals are present in the file.
  68928. */
  68929. ComputeNormals: boolean;
  68930. /**
  68931. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  68932. */
  68933. SkipMaterials: boolean;
  68934. /**
  68935. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  68936. */
  68937. MaterialLoadingFailsSilently: boolean;
  68938. };
  68939. /**
  68940. * OBJ file type loader.
  68941. * This is a babylon scene loader plugin.
  68942. */
  68943. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  68944. /**
  68945. * Defines if UVs are optimized by default during load.
  68946. */
  68947. static OPTIMIZE_WITH_UV: boolean;
  68948. /**
  68949. * Invert model on y-axis (does a model scaling inversion)
  68950. */
  68951. static INVERT_Y: boolean;
  68952. /**
  68953. * Invert Y-Axis of referenced textures on load
  68954. */
  68955. static INVERT_TEXTURE_Y: boolean;
  68956. /**
  68957. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  68958. */
  68959. static IMPORT_VERTEX_COLORS: boolean;
  68960. /**
  68961. * Compute the normals for the model, even if normals are present in the file.
  68962. */
  68963. static COMPUTE_NORMALS: boolean;
  68964. /**
  68965. * Defines custom scaling of UV coordinates of loaded meshes.
  68966. */
  68967. static UV_SCALING: Vector2;
  68968. /**
  68969. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  68970. */
  68971. static SKIP_MATERIALS: boolean;
  68972. /**
  68973. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  68974. *
  68975. * Defaults to true for backwards compatibility.
  68976. */
  68977. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  68978. /**
  68979. * Defines the name of the plugin.
  68980. */
  68981. name: string;
  68982. /**
  68983. * Defines the extension the plugin is able to load.
  68984. */
  68985. extensions: string;
  68986. /** @hidden */
  68987. obj: RegExp;
  68988. /** @hidden */
  68989. group: RegExp;
  68990. /** @hidden */
  68991. mtllib: RegExp;
  68992. /** @hidden */
  68993. usemtl: RegExp;
  68994. /** @hidden */
  68995. smooth: RegExp;
  68996. /** @hidden */
  68997. vertexPattern: RegExp;
  68998. /** @hidden */
  68999. normalPattern: RegExp;
  69000. /** @hidden */
  69001. uvPattern: RegExp;
  69002. /** @hidden */
  69003. facePattern1: RegExp;
  69004. /** @hidden */
  69005. facePattern2: RegExp;
  69006. /** @hidden */
  69007. facePattern3: RegExp;
  69008. /** @hidden */
  69009. facePattern4: RegExp;
  69010. /** @hidden */
  69011. facePattern5: RegExp;
  69012. private _meshLoadOptions;
  69013. /**
  69014. * Creates loader for .OBJ files
  69015. *
  69016. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  69017. */
  69018. constructor(meshLoadOptions?: MeshLoadOptions);
  69019. private static readonly currentMeshLoadOptions;
  69020. /**
  69021. * Calls synchronously the MTL file attached to this obj.
  69022. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  69023. * Without this function materials are not displayed in the first frame (but displayed after).
  69024. * In consequence it is impossible to get material information in your HTML file
  69025. *
  69026. * @param url The URL of the MTL file
  69027. * @param rootUrl
  69028. * @param onSuccess Callback function to be called when the MTL file is loaded
  69029. * @private
  69030. */
  69031. private _loadMTL;
  69032. /**
  69033. * Instantiates a OBJ file loader plugin.
  69034. * @returns the created plugin
  69035. */
  69036. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  69037. /**
  69038. * If the data string can be loaded directly.
  69039. *
  69040. * @param data string containing the file data
  69041. * @returns if the data can be loaded directly
  69042. */
  69043. canDirectLoad(data: string): boolean;
  69044. /**
  69045. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  69046. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  69047. * @param scene the scene the meshes should be added to
  69048. * @param data the OBJ data to load
  69049. * @param rootUrl root url to load from
  69050. * @param onProgress event that fires when loading progress has occured
  69051. * @param fileName Defines the name of the file to load
  69052. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  69053. */
  69054. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  69055. meshes: AbstractMesh[];
  69056. particleSystems: IParticleSystem[];
  69057. skeletons: Skeleton[];
  69058. animationGroups: AnimationGroup[];
  69059. }>;
  69060. /**
  69061. * Imports all objects from the loaded OBJ data and adds them to the scene
  69062. * @param scene the scene the objects should be added to
  69063. * @param data the OBJ data to load
  69064. * @param rootUrl root url to load from
  69065. * @param onProgress event that fires when loading progress has occured
  69066. * @param fileName Defines the name of the file to load
  69067. * @returns a promise which completes when objects have been loaded to the scene
  69068. */
  69069. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  69070. /**
  69071. * Load into an asset container.
  69072. * @param scene The scene to load into
  69073. * @param data The data to import
  69074. * @param rootUrl The root url for scene and resources
  69075. * @param onProgress The callback when the load progresses
  69076. * @param fileName Defines the name of the file to load
  69077. * @returns The loaded asset container
  69078. */
  69079. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  69080. /**
  69081. * Read the OBJ file and create an Array of meshes.
  69082. * Each mesh contains all information given by the OBJ and the MTL file.
  69083. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  69084. *
  69085. * @param meshesNames
  69086. * @param scene Scene The scene where are displayed the data
  69087. * @param data String The content of the obj file
  69088. * @param rootUrl String The path to the folder
  69089. * @returns Array<AbstractMesh>
  69090. * @private
  69091. */
  69092. private _parseSolid;
  69093. }
  69094. }
  69095. declare module BABYLON {
  69096. /**
  69097. * STL file type loader.
  69098. * This is a babylon scene loader plugin.
  69099. */
  69100. export class STLFileLoader implements ISceneLoaderPlugin {
  69101. /** @hidden */
  69102. solidPattern: RegExp;
  69103. /** @hidden */
  69104. facetsPattern: RegExp;
  69105. /** @hidden */
  69106. normalPattern: RegExp;
  69107. /** @hidden */
  69108. vertexPattern: RegExp;
  69109. /**
  69110. * Defines the name of the plugin.
  69111. */
  69112. name: string;
  69113. /**
  69114. * Defines the extensions the stl loader is able to load.
  69115. * force data to come in as an ArrayBuffer
  69116. * we'll convert to string if it looks like it's an ASCII .stl
  69117. */
  69118. extensions: ISceneLoaderPluginExtensions;
  69119. /**
  69120. * Import meshes into a scene.
  69121. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  69122. * @param scene The scene to import into
  69123. * @param data The data to import
  69124. * @param rootUrl The root url for scene and resources
  69125. * @param meshes The meshes array to import into
  69126. * @param particleSystems The particle systems array to import into
  69127. * @param skeletons The skeletons array to import into
  69128. * @param onError The callback when import fails
  69129. * @returns True if successful or false otherwise
  69130. */
  69131. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  69132. /**
  69133. * Load into a scene.
  69134. * @param scene The scene to load into
  69135. * @param data The data to import
  69136. * @param rootUrl The root url for scene and resources
  69137. * @param onError The callback when import fails
  69138. * @returns true if successful or false otherwise
  69139. */
  69140. load(scene: Scene, data: any, rootUrl: string): boolean;
  69141. /**
  69142. * Load into an asset container.
  69143. * @param scene The scene to load into
  69144. * @param data The data to import
  69145. * @param rootUrl The root url for scene and resources
  69146. * @param onError The callback when import fails
  69147. * @returns The loaded asset container
  69148. */
  69149. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  69150. private _isBinary;
  69151. private _parseBinary;
  69152. private _parseASCII;
  69153. }
  69154. }
  69155. declare module BABYLON {
  69156. /**
  69157. * Class for generating OBJ data from a Babylon scene.
  69158. */
  69159. export class OBJExport {
  69160. /**
  69161. * Exports the geometry of a Mesh array in .OBJ file format (text)
  69162. * @param mesh defines the list of meshes to serialize
  69163. * @param materials defines if materials should be exported
  69164. * @param matlibname defines the name of the associated mtl file
  69165. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  69166. * @returns the OBJ content
  69167. */
  69168. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  69169. /**
  69170. * Exports the material(s) of a mesh in .MTL file format (text)
  69171. * @param mesh defines the mesh to extract the material from
  69172. * @returns the mtl content
  69173. */
  69174. static MTL(mesh: Mesh): string;
  69175. }
  69176. }
  69177. declare module BABYLON {
  69178. /** @hidden */
  69179. export var __IGLTFExporterExtension: number;
  69180. /**
  69181. * Interface for extending the exporter
  69182. * @hidden
  69183. */
  69184. export interface IGLTFExporterExtension {
  69185. /**
  69186. * The name of this extension
  69187. */
  69188. readonly name: string;
  69189. /**
  69190. * Defines whether this extension is enabled
  69191. */
  69192. enabled: boolean;
  69193. /**
  69194. * Defines whether this extension is required
  69195. */
  69196. required: boolean;
  69197. }
  69198. }
  69199. declare module BABYLON.GLTF2.Exporter {
  69200. /** @hidden */
  69201. export var __IGLTFExporterExtensionV2: number;
  69202. /**
  69203. * Interface for a glTF exporter extension
  69204. * @hidden
  69205. */
  69206. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  69207. /**
  69208. * Define this method to modify the default behavior before exporting a texture
  69209. * @param context The context when loading the asset
  69210. * @param babylonTexture The glTF texture info property
  69211. * @param mimeType The mime-type of the generated image
  69212. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  69213. */
  69214. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  69215. /**
  69216. * Define this method to modify the default behavior when exporting texture info
  69217. * @param context The context when loading the asset
  69218. * @param meshPrimitive glTF mesh primitive
  69219. * @param babylonSubMesh Babylon submesh
  69220. * @param binaryWriter glTF serializer binary writer instance
  69221. * @returns nullable IMeshPrimitive promise
  69222. */
  69223. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  69224. /**
  69225. * Define this method to modify the default behavior when exporting a node
  69226. * @param context The context when exporting the node
  69227. * @param node glTF node
  69228. * @param babylonNode BabylonJS node
  69229. * @returns nullable INode promise
  69230. */
  69231. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  69232. /**
  69233. * Called after the exporter state changes to EXPORTING
  69234. */
  69235. onExporting?(): void;
  69236. }
  69237. }
  69238. declare module BABYLON.GLTF2.Exporter {
  69239. /**
  69240. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  69241. * @hidden
  69242. */
  69243. export class _GLTFMaterialExporter {
  69244. /**
  69245. * Represents the dielectric specular values for R, G and B
  69246. */
  69247. private static readonly _DielectricSpecular;
  69248. /**
  69249. * Allows the maximum specular power to be defined for material calculations
  69250. */
  69251. private static readonly _MaxSpecularPower;
  69252. /**
  69253. * Mapping to store textures
  69254. */
  69255. private _textureMap;
  69256. /**
  69257. * Numeric tolerance value
  69258. */
  69259. private static readonly _Epsilon;
  69260. /**
  69261. * Reference to the glTF Exporter
  69262. */
  69263. private _exporter;
  69264. constructor(exporter: _Exporter);
  69265. /**
  69266. * Specifies if two colors are approximately equal in value
  69267. * @param color1 first color to compare to
  69268. * @param color2 second color to compare to
  69269. * @param epsilon threshold value
  69270. */
  69271. private static FuzzyEquals;
  69272. /**
  69273. * Gets the materials from a Babylon scene and converts them to glTF materials
  69274. * @param scene babylonjs scene
  69275. * @param mimeType texture mime type
  69276. * @param images array of images
  69277. * @param textures array of textures
  69278. * @param materials array of materials
  69279. * @param imageData mapping of texture names to base64 textures
  69280. * @param hasTextureCoords specifies if texture coordinates are present on the material
  69281. */ private _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69282. /**
  69283. * Makes a copy of the glTF material without the texture parameters
  69284. * @param originalMaterial original glTF material
  69285. * @returns glTF material without texture parameters
  69286. */ private _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  69287. /**
  69288. * Specifies if the material has any texture parameters present
  69289. * @param material glTF Material
  69290. * @returns boolean specifying if texture parameters are present
  69291. */ private _hasTexturesPresent(material: IMaterial): boolean;
  69292. /**
  69293. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  69294. * @param babylonStandardMaterial
  69295. * @returns glTF Metallic Roughness Material representation
  69296. */ private _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  69297. /**
  69298. * Computes the metallic factor
  69299. * @param diffuse diffused value
  69300. * @param specular specular value
  69301. * @param oneMinusSpecularStrength one minus the specular strength
  69302. * @returns metallic value
  69303. */ private static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  69304. /**
  69305. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  69306. * @param glTFMaterial glTF material
  69307. * @param babylonMaterial Babylon material
  69308. */
  69309. private static _SetAlphaMode;
  69310. /**
  69311. * Converts a Babylon Standard Material to a glTF Material
  69312. * @param babylonStandardMaterial BJS Standard Material
  69313. * @param mimeType mime type to use for the textures
  69314. * @param images array of glTF image interfaces
  69315. * @param textures array of glTF texture interfaces
  69316. * @param materials array of glTF material interfaces
  69317. * @param imageData map of image file name to data
  69318. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69319. */ private _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69320. /**
  69321. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  69322. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  69323. * @param mimeType mime type to use for the textures
  69324. * @param images array of glTF image interfaces
  69325. * @param textures array of glTF texture interfaces
  69326. * @param materials array of glTF material interfaces
  69327. * @param imageData map of image file name to data
  69328. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69329. */ private _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69330. /**
  69331. * Converts an image typed array buffer to a base64 image
  69332. * @param buffer typed array buffer
  69333. * @param width width of the image
  69334. * @param height height of the image
  69335. * @param mimeType mimetype of the image
  69336. * @returns base64 image string
  69337. */
  69338. private _createBase64FromCanvasAsync;
  69339. /**
  69340. * Generates a white texture based on the specified width and height
  69341. * @param width width of the texture in pixels
  69342. * @param height height of the texture in pixels
  69343. * @param scene babylonjs scene
  69344. * @returns white texture
  69345. */
  69346. private _createWhiteTexture;
  69347. /**
  69348. * 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
  69349. * @param texture1 first texture to resize
  69350. * @param texture2 second texture to resize
  69351. * @param scene babylonjs scene
  69352. * @returns resized textures or null
  69353. */
  69354. private _resizeTexturesToSameDimensions;
  69355. /**
  69356. * Converts an array of pixels to a Float32Array
  69357. * Throws an error if the pixel format is not supported
  69358. * @param pixels - array buffer containing pixel values
  69359. * @returns Float32 of pixels
  69360. */
  69361. private _convertPixelArrayToFloat32;
  69362. /**
  69363. * Convert Specular Glossiness Textures to Metallic Roughness
  69364. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  69365. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  69366. * @param diffuseTexture texture used to store diffuse information
  69367. * @param specularGlossinessTexture texture used to store specular and glossiness information
  69368. * @param factors specular glossiness material factors
  69369. * @param mimeType the mime type to use for the texture
  69370. * @returns pbr metallic roughness interface or null
  69371. */
  69372. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  69373. /**
  69374. * Converts specular glossiness material properties to metallic roughness
  69375. * @param specularGlossiness interface with specular glossiness material properties
  69376. * @returns interface with metallic roughness material properties
  69377. */
  69378. private _convertSpecularGlossinessToMetallicRoughness;
  69379. /**
  69380. * Calculates the surface reflectance, independent of lighting conditions
  69381. * @param color Color source to calculate brightness from
  69382. * @returns number representing the perceived brightness, or zero if color is undefined
  69383. */
  69384. private _getPerceivedBrightness;
  69385. /**
  69386. * Returns the maximum color component value
  69387. * @param color
  69388. * @returns maximum color component value, or zero if color is null or undefined
  69389. */
  69390. private _getMaxComponent;
  69391. /**
  69392. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  69393. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  69394. * @param mimeType mime type to use for the textures
  69395. * @param images array of glTF image interfaces
  69396. * @param textures array of glTF texture interfaces
  69397. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  69398. * @param imageData map of image file name to data
  69399. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69400. * @returns glTF PBR Metallic Roughness factors
  69401. */
  69402. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  69403. private _getGLTFTextureSampler;
  69404. private _getGLTFTextureWrapMode;
  69405. private _getGLTFTextureWrapModesSampler;
  69406. /**
  69407. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  69408. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  69409. * @param mimeType mime type to use for the textures
  69410. * @param images array of glTF image interfaces
  69411. * @param textures array of glTF texture interfaces
  69412. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  69413. * @param imageData map of image file name to data
  69414. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69415. * @returns glTF PBR Metallic Roughness factors
  69416. */
  69417. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  69418. /**
  69419. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  69420. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  69421. * @param mimeType mime type to use for the textures
  69422. * @param images array of glTF image interfaces
  69423. * @param textures array of glTF texture interfaces
  69424. * @param materials array of glTF material interfaces
  69425. * @param imageData map of image file name to data
  69426. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69427. */ private _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69428. private setMetallicRoughnessPbrMaterial;
  69429. private getPixelsFromTexture;
  69430. /**
  69431. * Extracts a texture from a Babylon texture into file data and glTF data
  69432. * @param babylonTexture Babylon texture to extract
  69433. * @param mimeType Mime Type of the babylonTexture
  69434. * @return glTF texture info, or null if the texture format is not supported
  69435. */ private _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>; private _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  69436. /**
  69437. * Builds a texture from base64 string
  69438. * @param base64Texture base64 texture string
  69439. * @param baseTextureName Name to use for the texture
  69440. * @param mimeType image mime type for the texture
  69441. * @param images array of images
  69442. * @param textures array of textures
  69443. * @param imageData map of image data
  69444. * @returns glTF texture info, or null if the texture format is not supported
  69445. */
  69446. private _getTextureInfoFromBase64;
  69447. }
  69448. }
  69449. declare module BABYLON {
  69450. /**
  69451. * Class for holding and downloading glTF file data
  69452. */
  69453. export class GLTFData {
  69454. /**
  69455. * Object which contains the file name as the key and its data as the value
  69456. */
  69457. glTFFiles: {
  69458. [fileName: string]: string | Blob;
  69459. };
  69460. /**
  69461. * Initializes the glTF file object
  69462. */
  69463. constructor();
  69464. /**
  69465. * Downloads the glTF data as files based on their names and data
  69466. */
  69467. downloadFiles(): void;
  69468. }
  69469. }
  69470. declare module BABYLON {
  69471. /**
  69472. * Holds a collection of exporter options and parameters
  69473. */
  69474. export interface IExportOptions {
  69475. /**
  69476. * Function which indicates whether a babylon node should be exported or not
  69477. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  69478. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  69479. */
  69480. shouldExportNode?(node: Node): boolean;
  69481. /**
  69482. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  69483. * @param metadata source metadata to read from
  69484. * @returns the data to store to glTF node extras
  69485. */
  69486. metadataSelector?(metadata: any): any;
  69487. /**
  69488. * The sample rate to bake animation curves
  69489. */
  69490. animationSampleRate?: number;
  69491. /**
  69492. * Begin serialization without waiting for the scene to be ready
  69493. */
  69494. exportWithoutWaitingForScene?: boolean;
  69495. }
  69496. /**
  69497. * Class for generating glTF data from a Babylon scene.
  69498. */
  69499. export class GLTF2Export {
  69500. /**
  69501. * Exports the geometry of the scene to .gltf file format asynchronously
  69502. * @param scene Babylon scene with scene hierarchy information
  69503. * @param filePrefix File prefix to use when generating the glTF file
  69504. * @param options Exporter options
  69505. * @returns Returns an object with a .gltf file and associates texture names
  69506. * as keys and their data and paths as values
  69507. */
  69508. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  69509. private static _PreExportAsync;
  69510. private static _PostExportAsync;
  69511. /**
  69512. * Exports the geometry of the scene to .glb file format asychronously
  69513. * @param scene Babylon scene with scene hierarchy information
  69514. * @param filePrefix File prefix to use when generating glb file
  69515. * @param options Exporter options
  69516. * @returns Returns an object with a .glb filename as key and data as value
  69517. */
  69518. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  69519. }
  69520. }
  69521. declare module BABYLON.GLTF2.Exporter {
  69522. /**
  69523. * @hidden
  69524. */
  69525. export class _GLTFUtilities {
  69526. /**
  69527. * Creates a buffer view based on the supplied arguments
  69528. * @param bufferIndex index value of the specified buffer
  69529. * @param byteOffset byte offset value
  69530. * @param byteLength byte length of the bufferView
  69531. * @param byteStride byte distance between conequential elements
  69532. * @param name name of the buffer view
  69533. * @returns bufferView for glTF
  69534. */ private static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  69535. /**
  69536. * Creates an accessor based on the supplied arguments
  69537. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  69538. * @param name The name of the accessor
  69539. * @param type The type of the accessor
  69540. * @param componentType The datatype of components in the attribute
  69541. * @param count The number of attributes referenced by this accessor
  69542. * @param byteOffset The offset relative to the start of the bufferView in bytes
  69543. * @param min Minimum value of each component in this attribute
  69544. * @param max Maximum value of each component in this attribute
  69545. * @returns accessor for glTF
  69546. */ private static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  69547. /**
  69548. * Calculates the minimum and maximum values of an array of position floats
  69549. * @param positions Positions array of a mesh
  69550. * @param vertexStart Starting vertex offset to calculate min and max values
  69551. * @param vertexCount Number of vertices to check for min and max values
  69552. * @returns min number array and max number array
  69553. */ private static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  69554. min: number[];
  69555. max: number[];
  69556. };
  69557. /**
  69558. * Converts a new right-handed Vector3
  69559. * @param vector vector3 array
  69560. * @returns right-handed Vector3
  69561. */ private static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  69562. /**
  69563. * Converts a Vector3 to right-handed
  69564. * @param vector Vector3 to convert to right-handed
  69565. */ private static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  69566. /**
  69567. * Converts a three element number array to right-handed
  69568. * @param vector number array to convert to right-handed
  69569. */ private static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  69570. /**
  69571. * Converts a new right-handed Vector3
  69572. * @param vector vector3 array
  69573. * @returns right-handed Vector3
  69574. */ private static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  69575. /**
  69576. * Converts a Vector3 to right-handed
  69577. * @param vector Vector3 to convert to right-handed
  69578. */ private static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  69579. /**
  69580. * Converts a three element number array to right-handed
  69581. * @param vector number array to convert to right-handed
  69582. */ private static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  69583. /**
  69584. * Converts a Vector4 to right-handed
  69585. * @param vector Vector4 to convert to right-handed
  69586. */ private static _GetRightHandedVector4FromRef(vector: Vector4): void;
  69587. /**
  69588. * Converts a Vector4 to right-handed
  69589. * @param vector Vector4 to convert to right-handed
  69590. */ private static _GetRightHandedArray4FromRef(vector: number[]): void;
  69591. /**
  69592. * Converts a Quaternion to right-handed
  69593. * @param quaternion Source quaternion to convert to right-handed
  69594. */ private static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  69595. /**
  69596. * Converts a Quaternion to right-handed
  69597. * @param quaternion Source quaternion to convert to right-handed
  69598. */ private static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void; private static _NormalizeTangentFromRef(tangent: Vector4): void;
  69599. }
  69600. }
  69601. declare module BABYLON.GLTF2.Exporter {
  69602. /**
  69603. * Converts Babylon Scene into glTF 2.0.
  69604. * @hidden
  69605. */
  69606. export class _Exporter {
  69607. /**
  69608. * Stores the glTF to export
  69609. */ private _glTF: IGLTF;
  69610. /**
  69611. * Stores all generated buffer views, which represents views into the main glTF buffer data
  69612. */ private _bufferViews: IBufferView[];
  69613. /**
  69614. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  69615. */ private _accessors: IAccessor[];
  69616. /**
  69617. * Stores all the generated nodes, which contains transform and/or mesh information per node
  69618. */
  69619. private _nodes;
  69620. /**
  69621. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  69622. */
  69623. private _scenes;
  69624. /**
  69625. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  69626. */
  69627. private _meshes;
  69628. /**
  69629. * Stores all the generated material information, which represents the appearance of each primitive
  69630. */ private _materials: IMaterial[]; private _materialMap: {
  69631. [materialID: number]: number;
  69632. };
  69633. /**
  69634. * Stores all the generated texture information, which is referenced by glTF materials
  69635. */ private _textures: ITexture[];
  69636. /**
  69637. * Stores all the generated image information, which is referenced by glTF textures
  69638. */ private _images: IImage[];
  69639. /**
  69640. * Stores all the texture samplers
  69641. */ private _samplers: ISampler[];
  69642. /**
  69643. * Stores all the generated animation samplers, which is referenced by glTF animations
  69644. */
  69645. /**
  69646. * Stores the animations for glTF models
  69647. */
  69648. private _animations;
  69649. /**
  69650. * Stores the total amount of bytes stored in the glTF buffer
  69651. */
  69652. private _totalByteLength;
  69653. /**
  69654. * Stores a reference to the Babylon scene containing the source geometry and material information
  69655. */ private _babylonScene: Scene;
  69656. /**
  69657. * Stores a map of the image data, where the key is the file name and the value
  69658. * is the image data
  69659. */ private _imageData: {
  69660. [fileName: string]: {
  69661. data: Uint8Array;
  69662. mimeType: ImageMimeType;
  69663. };
  69664. };
  69665. /**
  69666. * Stores a map of the unique id of a node to its index in the node array
  69667. */
  69668. private _nodeMap;
  69669. /**
  69670. * Specifies if the Babylon scene should be converted to right-handed on export
  69671. */ private _convertToRightHandedSystem: boolean;
  69672. /**
  69673. * Baked animation sample rate
  69674. */
  69675. private _animationSampleRate;
  69676. private _options;
  69677. private _localEngine; private _glTFMaterialExporter: _GLTFMaterialExporter;
  69678. private _extensions;
  69679. private static _ExtensionNames;
  69680. private static _ExtensionFactories;
  69681. private _applyExtensions; private _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>; private _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>; private _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  69682. private _forEachExtensions;
  69683. private _extensionsOnExporting;
  69684. /**
  69685. * Load glTF serializer extensions
  69686. */
  69687. private _loadExtensions;
  69688. /**
  69689. * Creates a glTF Exporter instance, which can accept optional exporter options
  69690. * @param babylonScene Babylon scene object
  69691. * @param options Options to modify the behavior of the exporter
  69692. */
  69693. constructor(babylonScene: Scene, options?: IExportOptions);
  69694. /**
  69695. * Registers a glTF exporter extension
  69696. * @param name Name of the extension to export
  69697. * @param factory The factory function that creates the exporter extension
  69698. */
  69699. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  69700. /**
  69701. * Un-registers an exporter extension
  69702. * @param name The name fo the exporter extension
  69703. * @returns A boolean indicating whether the extension has been un-registered
  69704. */
  69705. static UnregisterExtension(name: string): boolean;
  69706. /**
  69707. * Lazy load a local engine with premultiplied alpha set to false
  69708. */ private _getLocalEngine(): Engine;
  69709. private reorderIndicesBasedOnPrimitiveMode;
  69710. /**
  69711. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  69712. * clock-wise during export to glTF
  69713. * @param submesh BabylonJS submesh
  69714. * @param primitiveMode Primitive mode of the mesh
  69715. * @param sideOrientation the winding order of the submesh
  69716. * @param vertexBufferKind The type of vertex attribute
  69717. * @param meshAttributeArray The vertex attribute data
  69718. * @param byteOffset The offset to the binary data
  69719. * @param binaryWriter The binary data for the glTF file
  69720. */
  69721. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  69722. /**
  69723. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  69724. * clock-wise during export to glTF
  69725. * @param submesh BabylonJS submesh
  69726. * @param primitiveMode Primitive mode of the mesh
  69727. * @param sideOrientation the winding order of the submesh
  69728. * @param vertexBufferKind The type of vertex attribute
  69729. * @param meshAttributeArray The vertex attribute data
  69730. * @param byteOffset The offset to the binary data
  69731. * @param binaryWriter The binary data for the glTF file
  69732. */
  69733. private reorderTriangleFillMode;
  69734. /**
  69735. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  69736. * clock-wise during export to glTF
  69737. * @param submesh BabylonJS submesh
  69738. * @param primitiveMode Primitive mode of the mesh
  69739. * @param sideOrientation the winding order of the submesh
  69740. * @param vertexBufferKind The type of vertex attribute
  69741. * @param meshAttributeArray The vertex attribute data
  69742. * @param byteOffset The offset to the binary data
  69743. * @param binaryWriter The binary data for the glTF file
  69744. */
  69745. private reorderTriangleStripDrawMode;
  69746. /**
  69747. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  69748. * clock-wise during export to glTF
  69749. * @param submesh BabylonJS submesh
  69750. * @param primitiveMode Primitive mode of the mesh
  69751. * @param sideOrientation the winding order of the submesh
  69752. * @param vertexBufferKind The type of vertex attribute
  69753. * @param meshAttributeArray The vertex attribute data
  69754. * @param byteOffset The offset to the binary data
  69755. * @param binaryWriter The binary data for the glTF file
  69756. */
  69757. private reorderTriangleFanMode;
  69758. /**
  69759. * Writes the vertex attribute data to binary
  69760. * @param vertices The vertices to write to the binary writer
  69761. * @param byteOffset The offset into the binary writer to overwrite binary data
  69762. * @param vertexAttributeKind The vertex attribute type
  69763. * @param meshAttributeArray The vertex attribute data
  69764. * @param binaryWriter The writer containing the binary data
  69765. */
  69766. private writeVertexAttributeData;
  69767. /**
  69768. * Writes mesh attribute data to a data buffer
  69769. * Returns the bytelength of the data
  69770. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  69771. * @param meshAttributeArray Array containing the attribute data
  69772. * @param binaryWriter The buffer to write the binary data to
  69773. * @param indices Used to specify the order of the vertex data
  69774. */
  69775. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  69776. /**
  69777. * Generates glTF json data
  69778. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  69779. * @param glTFPrefix Text to use when prefixing a glTF file
  69780. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  69781. * @returns json data as string
  69782. */
  69783. private generateJSON;
  69784. /**
  69785. * Generates data for .gltf and .bin files based on the glTF prefix string
  69786. * @param glTFPrefix Text to use when prefixing a glTF file
  69787. * @returns GLTFData with glTF file data
  69788. */ private _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  69789. /**
  69790. * Creates a binary buffer for glTF
  69791. * @returns array buffer for binary data
  69792. */
  69793. private _generateBinaryAsync;
  69794. /**
  69795. * Pads the number to a multiple of 4
  69796. * @param num number to pad
  69797. * @returns padded number
  69798. */
  69799. private _getPadding;
  69800. /**
  69801. * Generates a glb file from the json and binary data
  69802. * Returns an object with the glb file name as the key and data as the value
  69803. * @param glTFPrefix
  69804. * @returns object with glb filename as key and data as value
  69805. */ private _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  69806. /**
  69807. * Sets the TRS for each node
  69808. * @param node glTF Node for storing the transformation data
  69809. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  69810. */
  69811. private setNodeTransformation;
  69812. private getVertexBufferFromMesh;
  69813. /**
  69814. * Creates a bufferview based on the vertices type for the Babylon mesh
  69815. * @param kind Indicates the type of vertices data
  69816. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  69817. * @param binaryWriter The buffer to write the bufferview data to
  69818. */
  69819. private createBufferViewKind;
  69820. /**
  69821. * The primitive mode of the Babylon mesh
  69822. * @param babylonMesh The BabylonJS mesh
  69823. */
  69824. private getMeshPrimitiveMode;
  69825. /**
  69826. * Sets the primitive mode of the glTF mesh primitive
  69827. * @param meshPrimitive glTF mesh primitive
  69828. * @param primitiveMode The primitive mode
  69829. */
  69830. private setPrimitiveMode;
  69831. /**
  69832. * Sets the vertex attribute accessor based of the glTF mesh primitive
  69833. * @param meshPrimitive glTF mesh primitive
  69834. * @param attributeKind vertex attribute
  69835. * @returns boolean specifying if uv coordinates are present
  69836. */
  69837. private setAttributeKind;
  69838. /**
  69839. * Sets data for the primitive attributes of each submesh
  69840. * @param mesh glTF Mesh object to store the primitive attribute information
  69841. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  69842. * @param binaryWriter Buffer to write the attribute data to
  69843. */
  69844. private setPrimitiveAttributesAsync;
  69845. /**
  69846. * Creates a glTF scene based on the array of meshes
  69847. * Returns the the total byte offset
  69848. * @param babylonScene Babylon scene to get the mesh data from
  69849. * @param binaryWriter Buffer to write binary data to
  69850. */
  69851. private createSceneAsync;
  69852. /**
  69853. * Creates a mapping of Node unique id to node index and handles animations
  69854. * @param babylonScene Babylon Scene
  69855. * @param nodes Babylon transform nodes
  69856. * @param binaryWriter Buffer to write binary data to
  69857. * @returns Node mapping of unique id to index
  69858. */
  69859. private createNodeMapAndAnimationsAsync;
  69860. /**
  69861. * Creates a glTF node from a Babylon mesh
  69862. * @param babylonMesh Source Babylon mesh
  69863. * @param binaryWriter Buffer for storing geometry data
  69864. * @returns glTF node
  69865. */
  69866. private createNodeAsync;
  69867. }
  69868. /**
  69869. * @hidden
  69870. *
  69871. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  69872. */
  69873. export class _BinaryWriter {
  69874. /**
  69875. * Array buffer which stores all binary data
  69876. */
  69877. private _arrayBuffer;
  69878. /**
  69879. * View of the array buffer
  69880. */
  69881. private _dataView;
  69882. /**
  69883. * byte offset of data in array buffer
  69884. */
  69885. private _byteOffset;
  69886. /**
  69887. * Initialize binary writer with an initial byte length
  69888. * @param byteLength Initial byte length of the array buffer
  69889. */
  69890. constructor(byteLength: number);
  69891. /**
  69892. * Resize the array buffer to the specified byte length
  69893. * @param byteLength
  69894. */
  69895. private resizeBuffer;
  69896. /**
  69897. * Get an array buffer with the length of the byte offset
  69898. * @returns ArrayBuffer resized to the byte offset
  69899. */
  69900. getArrayBuffer(): ArrayBuffer;
  69901. /**
  69902. * Get the byte offset of the array buffer
  69903. * @returns byte offset
  69904. */
  69905. getByteOffset(): number;
  69906. /**
  69907. * Stores an UInt8 in the array buffer
  69908. * @param entry
  69909. * @param byteOffset If defined, specifies where to set the value as an offset.
  69910. */
  69911. setUInt8(entry: number, byteOffset?: number): void;
  69912. /**
  69913. * Gets an UInt32 in the array buffer
  69914. * @param entry
  69915. * @param byteOffset If defined, specifies where to set the value as an offset.
  69916. */
  69917. getUInt32(byteOffset: number): number;
  69918. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  69919. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  69920. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  69921. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  69922. /**
  69923. * Stores a Float32 in the array buffer
  69924. * @param entry
  69925. */
  69926. setFloat32(entry: number, byteOffset?: number): void;
  69927. /**
  69928. * Stores an UInt32 in the array buffer
  69929. * @param entry
  69930. * @param byteOffset If defined, specifies where to set the value as an offset.
  69931. */
  69932. setUInt32(entry: number, byteOffset?: number): void;
  69933. }
  69934. }
  69935. declare module BABYLON.GLTF2.Exporter {
  69936. /**
  69937. * @hidden
  69938. * Interface to store animation data.
  69939. */
  69940. export interface _IAnimationData {
  69941. /**
  69942. * Keyframe data.
  69943. */
  69944. inputs: number[];
  69945. /**
  69946. * Value data.
  69947. */
  69948. outputs: number[][];
  69949. /**
  69950. * Animation interpolation data.
  69951. */
  69952. samplerInterpolation: AnimationSamplerInterpolation;
  69953. /**
  69954. * Minimum keyframe value.
  69955. */
  69956. inputsMin: number;
  69957. /**
  69958. * Maximum keyframe value.
  69959. */
  69960. inputsMax: number;
  69961. }
  69962. /**
  69963. * @hidden
  69964. */
  69965. export interface _IAnimationInfo {
  69966. /**
  69967. * The target channel for the animation
  69968. */
  69969. animationChannelTargetPath: AnimationChannelTargetPath;
  69970. /**
  69971. * The glTF accessor type for the data.
  69972. */
  69973. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  69974. /**
  69975. * Specifies if quaternions should be used.
  69976. */
  69977. useQuaternion: boolean;
  69978. }
  69979. /**
  69980. * @hidden
  69981. * Utility class for generating glTF animation data from BabylonJS.
  69982. */
  69983. export class _GLTFAnimation {
  69984. /**
  69985. * @ignore
  69986. *
  69987. * Creates glTF channel animation from BabylonJS animation.
  69988. * @param babylonTransformNode - BabylonJS mesh.
  69989. * @param animation - animation.
  69990. * @param animationChannelTargetPath - The target animation channel.
  69991. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  69992. * @param useQuaternion - Specifies if quaternions are used.
  69993. * @returns nullable IAnimationData
  69994. */ private static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  69995. private static _DeduceAnimationInfo;
  69996. /**
  69997. * @ignore
  69998. * Create node animations from the transform node animations
  69999. * @param babylonNode
  70000. * @param runtimeGLTFAnimation
  70001. * @param idleGLTFAnimations
  70002. * @param nodeMap
  70003. * @param nodes
  70004. * @param binaryWriter
  70005. * @param bufferViews
  70006. * @param accessors
  70007. * @param convertToRightHandedSystem
  70008. */ private static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  70009. [key: number]: number;
  70010. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  70011. /**
  70012. * @ignore
  70013. * Create node animations from the animation groups
  70014. * @param babylonScene
  70015. * @param glTFAnimations
  70016. * @param nodeMap
  70017. * @param nodes
  70018. * @param binaryWriter
  70019. * @param bufferViews
  70020. * @param accessors
  70021. * @param convertToRightHandedSystem
  70022. */ private static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  70023. [key: number]: number;
  70024. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  70025. private static AddAnimation;
  70026. /**
  70027. * Create a baked animation
  70028. * @param babylonTransformNode BabylonJS mesh
  70029. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  70030. * @param animationChannelTargetPath animation target channel
  70031. * @param minFrame minimum animation frame
  70032. * @param maxFrame maximum animation frame
  70033. * @param fps frames per second of the animation
  70034. * @param inputs input key frames of the animation
  70035. * @param outputs output key frame data of the animation
  70036. * @param convertToRightHandedSystem converts the values to right-handed
  70037. * @param useQuaternion specifies if quaternions should be used
  70038. */
  70039. private static _CreateBakedAnimation;
  70040. private static _ConvertFactorToVector3OrQuaternion;
  70041. private static _SetInterpolatedValue;
  70042. /**
  70043. * Creates linear animation from the animation key frames
  70044. * @param babylonTransformNode BabylonJS mesh
  70045. * @param animation BabylonJS animation
  70046. * @param animationChannelTargetPath The target animation channel
  70047. * @param frameDelta The difference between the last and first frame of the animation
  70048. * @param inputs Array to store the key frame times
  70049. * @param outputs Array to store the key frame data
  70050. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  70051. * @param useQuaternion Specifies if quaternions are used in the animation
  70052. */
  70053. private static _CreateLinearOrStepAnimation;
  70054. /**
  70055. * Creates cubic spline animation from the animation key frames
  70056. * @param babylonTransformNode BabylonJS mesh
  70057. * @param animation BabylonJS animation
  70058. * @param animationChannelTargetPath The target animation channel
  70059. * @param frameDelta The difference between the last and first frame of the animation
  70060. * @param inputs Array to store the key frame times
  70061. * @param outputs Array to store the key frame data
  70062. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  70063. * @param useQuaternion Specifies if quaternions are used in the animation
  70064. */
  70065. private static _CreateCubicSplineAnimation;
  70066. private static _GetBasePositionRotationOrScale;
  70067. /**
  70068. * Adds a key frame value
  70069. * @param keyFrame
  70070. * @param animation
  70071. * @param outputs
  70072. * @param animationChannelTargetPath
  70073. * @param basePositionRotationOrScale
  70074. * @param convertToRightHandedSystem
  70075. * @param useQuaternion
  70076. */
  70077. private static _AddKeyframeValue;
  70078. /**
  70079. * Determine the interpolation based on the key frames
  70080. * @param keyFrames
  70081. * @param animationChannelTargetPath
  70082. * @param useQuaternion
  70083. */
  70084. private static _DeduceInterpolation;
  70085. /**
  70086. * Adds an input tangent or output tangent to the output data
  70087. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  70088. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  70089. * @param outputs The animation data by keyframe
  70090. * @param animationChannelTargetPath The target animation channel
  70091. * @param interpolation The interpolation type
  70092. * @param keyFrame The key frame with the animation data
  70093. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  70094. * @param useQuaternion Specifies if quaternions are used
  70095. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  70096. */
  70097. private static AddSplineTangent;
  70098. /**
  70099. * Get the minimum and maximum key frames' frame values
  70100. * @param keyFrames animation key frames
  70101. * @returns the minimum and maximum key frame value
  70102. */
  70103. private static calculateMinMaxKeyFrames;
  70104. }
  70105. }
  70106. declare module BABYLON.GLTF2.Exporter {
  70107. /** @hidden */
  70108. export var textureTransformPixelShader: {
  70109. name: string;
  70110. shader: string;
  70111. };
  70112. }
  70113. declare module BABYLON.GLTF2.Exporter.Extensions {
  70114. /**
  70115. * @hidden
  70116. */
  70117. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  70118. /** Name of this extension */
  70119. readonly name: string;
  70120. /** Defines whether this extension is enabled */
  70121. enabled: boolean;
  70122. /** Defines whether this extension is required */
  70123. required: boolean;
  70124. /** Reference to the glTF exporter */
  70125. private _exporter;
  70126. constructor(exporter: _Exporter);
  70127. dispose(): void;
  70128. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  70129. /**
  70130. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  70131. * @param babylonTexture
  70132. * @param offset
  70133. * @param rotation
  70134. * @param scale
  70135. * @param scene
  70136. */
  70137. private _textureTransformTextureAsync;
  70138. }
  70139. }
  70140. declare module BABYLON.GLTF2.Exporter.Extensions {
  70141. /**
  70142. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  70143. */
  70144. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  70145. /** The name of this extension. */
  70146. readonly name: string;
  70147. /** Defines whether this extension is enabled. */
  70148. enabled: boolean;
  70149. /** Defines whether this extension is required */
  70150. required: boolean;
  70151. /** Reference to the glTF exporter */
  70152. private _exporter;
  70153. private _lights;
  70154. /** @hidden */
  70155. constructor(exporter: _Exporter);
  70156. /** @hidden */
  70157. dispose(): void;
  70158. /** @hidden */
  70159. onExporting(): void;
  70160. /**
  70161. * Define this method to modify the default behavior when exporting a node
  70162. * @param context The context when exporting the node
  70163. * @param node glTF node
  70164. * @param babylonNode BabylonJS node
  70165. * @returns nullable INode promise
  70166. */
  70167. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  70168. }
  70169. }
  70170. declare module BABYLON {
  70171. /**
  70172. * Class for generating STL data from a Babylon scene.
  70173. */
  70174. export class STLExport {
  70175. /**
  70176. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  70177. * @param meshes list defines the mesh to serialize
  70178. * @param download triggers the automatic download of the file.
  70179. * @param fileName changes the downloads fileName.
  70180. * @param binary changes the STL to a binary type.
  70181. * @param isLittleEndian toggle for binary type exporter.
  70182. * @returns the STL as UTF8 string
  70183. */
  70184. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  70185. }
  70186. }
  70187. declare module "babylonjs-gltf2interface" {
  70188. export = BABYLON.GLTF2;
  70189. }
  70190. /**
  70191. * Module for glTF 2.0 Interface
  70192. */
  70193. declare module BABYLON.GLTF2 {
  70194. /**
  70195. * The datatype of the components in the attribute
  70196. */
  70197. const enum AccessorComponentType {
  70198. /**
  70199. * Byte
  70200. */
  70201. BYTE = 5120,
  70202. /**
  70203. * Unsigned Byte
  70204. */
  70205. UNSIGNED_BYTE = 5121,
  70206. /**
  70207. * Short
  70208. */
  70209. SHORT = 5122,
  70210. /**
  70211. * Unsigned Short
  70212. */
  70213. UNSIGNED_SHORT = 5123,
  70214. /**
  70215. * Unsigned Int
  70216. */
  70217. UNSIGNED_INT = 5125,
  70218. /**
  70219. * Float
  70220. */
  70221. FLOAT = 5126,
  70222. }
  70223. /**
  70224. * Specifies if the attirbute is a scalar, vector, or matrix
  70225. */
  70226. const enum AccessorType {
  70227. /**
  70228. * Scalar
  70229. */
  70230. SCALAR = "SCALAR",
  70231. /**
  70232. * Vector2
  70233. */
  70234. VEC2 = "VEC2",
  70235. /**
  70236. * Vector3
  70237. */
  70238. VEC3 = "VEC3",
  70239. /**
  70240. * Vector4
  70241. */
  70242. VEC4 = "VEC4",
  70243. /**
  70244. * Matrix2x2
  70245. */
  70246. MAT2 = "MAT2",
  70247. /**
  70248. * Matrix3x3
  70249. */
  70250. MAT3 = "MAT3",
  70251. /**
  70252. * Matrix4x4
  70253. */
  70254. MAT4 = "MAT4",
  70255. }
  70256. /**
  70257. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  70258. */
  70259. const enum AnimationChannelTargetPath {
  70260. /**
  70261. * Translation
  70262. */
  70263. TRANSLATION = "translation",
  70264. /**
  70265. * Rotation
  70266. */
  70267. ROTATION = "rotation",
  70268. /**
  70269. * Scale
  70270. */
  70271. SCALE = "scale",
  70272. /**
  70273. * Weights
  70274. */
  70275. WEIGHTS = "weights",
  70276. }
  70277. /**
  70278. * Interpolation algorithm
  70279. */
  70280. const enum AnimationSamplerInterpolation {
  70281. /**
  70282. * The animated values are linearly interpolated between keyframes
  70283. */
  70284. LINEAR = "LINEAR",
  70285. /**
  70286. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  70287. */
  70288. STEP = "STEP",
  70289. /**
  70290. * The animation's interpolation is computed using a cubic spline with specified tangents
  70291. */
  70292. CUBICSPLINE = "CUBICSPLINE",
  70293. }
  70294. /**
  70295. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  70296. */
  70297. const enum CameraType {
  70298. /**
  70299. * A perspective camera containing properties to create a perspective projection matrix
  70300. */
  70301. PERSPECTIVE = "perspective",
  70302. /**
  70303. * An orthographic camera containing properties to create an orthographic projection matrix
  70304. */
  70305. ORTHOGRAPHIC = "orthographic",
  70306. }
  70307. /**
  70308. * The mime-type of the image
  70309. */
  70310. const enum ImageMimeType {
  70311. /**
  70312. * JPEG Mime-type
  70313. */
  70314. JPEG = "image/jpeg",
  70315. /**
  70316. * PNG Mime-type
  70317. */
  70318. PNG = "image/png",
  70319. }
  70320. /**
  70321. * The alpha rendering mode of the material
  70322. */
  70323. const enum MaterialAlphaMode {
  70324. /**
  70325. * The alpha value is ignored and the rendered output is fully opaque
  70326. */
  70327. OPAQUE = "OPAQUE",
  70328. /**
  70329. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  70330. */
  70331. MASK = "MASK",
  70332. /**
  70333. * 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)
  70334. */
  70335. BLEND = "BLEND",
  70336. }
  70337. /**
  70338. * The type of the primitives to render
  70339. */
  70340. const enum MeshPrimitiveMode {
  70341. /**
  70342. * Points
  70343. */
  70344. POINTS = 0,
  70345. /**
  70346. * Lines
  70347. */
  70348. LINES = 1,
  70349. /**
  70350. * Line Loop
  70351. */
  70352. LINE_LOOP = 2,
  70353. /**
  70354. * Line Strip
  70355. */
  70356. LINE_STRIP = 3,
  70357. /**
  70358. * Triangles
  70359. */
  70360. TRIANGLES = 4,
  70361. /**
  70362. * Triangle Strip
  70363. */
  70364. TRIANGLE_STRIP = 5,
  70365. /**
  70366. * Triangle Fan
  70367. */
  70368. TRIANGLE_FAN = 6,
  70369. }
  70370. /**
  70371. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  70372. */
  70373. const enum TextureMagFilter {
  70374. /**
  70375. * Nearest
  70376. */
  70377. NEAREST = 9728,
  70378. /**
  70379. * Linear
  70380. */
  70381. LINEAR = 9729,
  70382. }
  70383. /**
  70384. * Minification filter. All valid values correspond to WebGL enums
  70385. */
  70386. const enum TextureMinFilter {
  70387. /**
  70388. * Nearest
  70389. */
  70390. NEAREST = 9728,
  70391. /**
  70392. * Linear
  70393. */
  70394. LINEAR = 9729,
  70395. /**
  70396. * Nearest Mip-Map Nearest
  70397. */
  70398. NEAREST_MIPMAP_NEAREST = 9984,
  70399. /**
  70400. * Linear Mipmap Nearest
  70401. */
  70402. LINEAR_MIPMAP_NEAREST = 9985,
  70403. /**
  70404. * Nearest Mipmap Linear
  70405. */
  70406. NEAREST_MIPMAP_LINEAR = 9986,
  70407. /**
  70408. * Linear Mipmap Linear
  70409. */
  70410. LINEAR_MIPMAP_LINEAR = 9987,
  70411. }
  70412. /**
  70413. * S (U) wrapping mode. All valid values correspond to WebGL enums
  70414. */
  70415. const enum TextureWrapMode {
  70416. /**
  70417. * Clamp to Edge
  70418. */
  70419. CLAMP_TO_EDGE = 33071,
  70420. /**
  70421. * Mirrored Repeat
  70422. */
  70423. MIRRORED_REPEAT = 33648,
  70424. /**
  70425. * Repeat
  70426. */
  70427. REPEAT = 10497,
  70428. }
  70429. /**
  70430. * glTF Property
  70431. */
  70432. interface IProperty {
  70433. /**
  70434. * Dictionary object with extension-specific objects
  70435. */
  70436. extensions?: {
  70437. [key: string]: any;
  70438. };
  70439. /**
  70440. * Application-Specific data
  70441. */
  70442. extras?: any;
  70443. }
  70444. /**
  70445. * glTF Child of Root Property
  70446. */
  70447. interface IChildRootProperty extends IProperty {
  70448. /**
  70449. * The user-defined name of this object
  70450. */
  70451. name?: string;
  70452. }
  70453. /**
  70454. * Indices of those attributes that deviate from their initialization value
  70455. */
  70456. interface IAccessorSparseIndices extends IProperty {
  70457. /**
  70458. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  70459. */
  70460. bufferView: number;
  70461. /**
  70462. * The offset relative to the start of the bufferView in bytes. Must be aligned
  70463. */
  70464. byteOffset?: number;
  70465. /**
  70466. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  70467. */
  70468. componentType: AccessorComponentType;
  70469. }
  70470. /**
  70471. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  70472. */
  70473. interface IAccessorSparseValues extends IProperty {
  70474. /**
  70475. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  70476. */
  70477. bufferView: number;
  70478. /**
  70479. * The offset relative to the start of the bufferView in bytes. Must be aligned
  70480. */
  70481. byteOffset?: number;
  70482. }
  70483. /**
  70484. * Sparse storage of attributes that deviate from their initialization value
  70485. */
  70486. interface IAccessorSparse extends IProperty {
  70487. /**
  70488. * The number of attributes encoded in this sparse accessor
  70489. */
  70490. count: number;
  70491. /**
  70492. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  70493. */
  70494. indices: IAccessorSparseIndices;
  70495. /**
  70496. * 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
  70497. */
  70498. values: IAccessorSparseValues;
  70499. }
  70500. /**
  70501. * 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
  70502. */
  70503. interface IAccessor extends IChildRootProperty {
  70504. /**
  70505. * The index of the bufferview
  70506. */
  70507. bufferView?: number;
  70508. /**
  70509. * The offset relative to the start of the bufferView in bytes
  70510. */
  70511. byteOffset?: number;
  70512. /**
  70513. * The datatype of components in the attribute
  70514. */
  70515. componentType: AccessorComponentType;
  70516. /**
  70517. * Specifies whether integer data values should be normalized
  70518. */
  70519. normalized?: boolean;
  70520. /**
  70521. * The number of attributes referenced by this accessor
  70522. */
  70523. count: number;
  70524. /**
  70525. * Specifies if the attribute is a scalar, vector, or matrix
  70526. */
  70527. type: AccessorType;
  70528. /**
  70529. * Maximum value of each component in this attribute
  70530. */
  70531. max?: number[];
  70532. /**
  70533. * Minimum value of each component in this attribute
  70534. */
  70535. min?: number[];
  70536. /**
  70537. * Sparse storage of attributes that deviate from their initialization value
  70538. */
  70539. sparse?: IAccessorSparse;
  70540. }
  70541. /**
  70542. * Targets an animation's sampler at a node's property
  70543. */
  70544. interface IAnimationChannel extends IProperty {
  70545. /**
  70546. * The index of a sampler in this animation used to compute the value for the target
  70547. */
  70548. sampler: number;
  70549. /**
  70550. * The index of the node and TRS property to target
  70551. */
  70552. target: IAnimationChannelTarget;
  70553. }
  70554. /**
  70555. * The index of the node and TRS property that an animation channel targets
  70556. */
  70557. interface IAnimationChannelTarget extends IProperty {
  70558. /**
  70559. * The index of the node to target
  70560. */
  70561. node: number;
  70562. /**
  70563. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  70564. */
  70565. path: AnimationChannelTargetPath;
  70566. }
  70567. /**
  70568. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  70569. */
  70570. interface IAnimationSampler extends IProperty {
  70571. /**
  70572. * The index of an accessor containing keyframe input values, e.g., time
  70573. */
  70574. input: number;
  70575. /**
  70576. * Interpolation algorithm
  70577. */
  70578. interpolation?: AnimationSamplerInterpolation;
  70579. /**
  70580. * The index of an accessor, containing keyframe output values
  70581. */
  70582. output: number;
  70583. }
  70584. /**
  70585. * A keyframe animation
  70586. */
  70587. interface IAnimation extends IChildRootProperty {
  70588. /**
  70589. * An array of channels, each of which targets an animation's sampler at a node's property
  70590. */
  70591. channels: IAnimationChannel[];
  70592. /**
  70593. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  70594. */
  70595. samplers: IAnimationSampler[];
  70596. }
  70597. /**
  70598. * Metadata about the glTF asset
  70599. */
  70600. interface IAsset extends IChildRootProperty {
  70601. /**
  70602. * A copyright message suitable for display to credit the content creator
  70603. */
  70604. copyright?: string;
  70605. /**
  70606. * Tool that generated this glTF model. Useful for debugging
  70607. */
  70608. generator?: string;
  70609. /**
  70610. * The glTF version that this asset targets
  70611. */
  70612. version: string;
  70613. /**
  70614. * The minimum glTF version that this asset targets
  70615. */
  70616. minVersion?: string;
  70617. }
  70618. /**
  70619. * A buffer points to binary geometry, animation, or skins
  70620. */
  70621. interface IBuffer extends IChildRootProperty {
  70622. /**
  70623. * 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
  70624. */
  70625. uri?: string;
  70626. /**
  70627. * The length of the buffer in bytes
  70628. */
  70629. byteLength: number;
  70630. }
  70631. /**
  70632. * A view into a buffer generally representing a subset of the buffer
  70633. */
  70634. interface IBufferView extends IChildRootProperty {
  70635. /**
  70636. * The index of the buffer
  70637. */
  70638. buffer: number;
  70639. /**
  70640. * The offset into the buffer in bytes
  70641. */
  70642. byteOffset?: number;
  70643. /**
  70644. * The lenth of the bufferView in bytes
  70645. */
  70646. byteLength: number;
  70647. /**
  70648. * The stride, in bytes
  70649. */
  70650. byteStride?: number;
  70651. }
  70652. /**
  70653. * An orthographic camera containing properties to create an orthographic projection matrix
  70654. */
  70655. interface ICameraOrthographic extends IProperty {
  70656. /**
  70657. * The floating-point horizontal magnification of the view. Must not be zero
  70658. */
  70659. xmag: number;
  70660. /**
  70661. * The floating-point vertical magnification of the view. Must not be zero
  70662. */
  70663. ymag: number;
  70664. /**
  70665. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  70666. */
  70667. zfar: number;
  70668. /**
  70669. * The floating-point distance to the near clipping plane
  70670. */
  70671. znear: number;
  70672. }
  70673. /**
  70674. * A perspective camera containing properties to create a perspective projection matrix
  70675. */
  70676. interface ICameraPerspective extends IProperty {
  70677. /**
  70678. * The floating-point aspect ratio of the field of view
  70679. */
  70680. aspectRatio?: number;
  70681. /**
  70682. * The floating-point vertical field of view in radians
  70683. */
  70684. yfov: number;
  70685. /**
  70686. * The floating-point distance to the far clipping plane
  70687. */
  70688. zfar?: number;
  70689. /**
  70690. * The floating-point distance to the near clipping plane
  70691. */
  70692. znear: number;
  70693. }
  70694. /**
  70695. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  70696. */
  70697. interface ICamera extends IChildRootProperty {
  70698. /**
  70699. * An orthographic camera containing properties to create an orthographic projection matrix
  70700. */
  70701. orthographic?: ICameraOrthographic;
  70702. /**
  70703. * A perspective camera containing properties to create a perspective projection matrix
  70704. */
  70705. perspective?: ICameraPerspective;
  70706. /**
  70707. * Specifies if the camera uses a perspective or orthographic projection
  70708. */
  70709. type: CameraType;
  70710. }
  70711. /**
  70712. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  70713. */
  70714. interface IImage extends IChildRootProperty {
  70715. /**
  70716. * 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
  70717. */
  70718. uri?: string;
  70719. /**
  70720. * The image's MIME type
  70721. */
  70722. mimeType?: ImageMimeType;
  70723. /**
  70724. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  70725. */
  70726. bufferView?: number;
  70727. }
  70728. /**
  70729. * Material Normal Texture Info
  70730. */
  70731. interface IMaterialNormalTextureInfo extends ITextureInfo {
  70732. /**
  70733. * The scalar multiplier applied to each normal vector of the normal texture
  70734. */
  70735. scale?: number;
  70736. }
  70737. /**
  70738. * Material Occlusion Texture Info
  70739. */
  70740. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  70741. /**
  70742. * A scalar multiplier controlling the amount of occlusion applied
  70743. */
  70744. strength?: number;
  70745. }
  70746. /**
  70747. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  70748. */
  70749. interface IMaterialPbrMetallicRoughness {
  70750. /**
  70751. * The material's base color factor
  70752. */
  70753. baseColorFactor?: number[];
  70754. /**
  70755. * The base color texture
  70756. */
  70757. baseColorTexture?: ITextureInfo;
  70758. /**
  70759. * The metalness of the material
  70760. */
  70761. metallicFactor?: number;
  70762. /**
  70763. * The roughness of the material
  70764. */
  70765. roughnessFactor?: number;
  70766. /**
  70767. * The metallic-roughness texture
  70768. */
  70769. metallicRoughnessTexture?: ITextureInfo;
  70770. }
  70771. /**
  70772. * The material appearance of a primitive
  70773. */
  70774. interface IMaterial extends IChildRootProperty {
  70775. /**
  70776. * 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
  70777. */
  70778. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  70779. /**
  70780. * The normal map texture
  70781. */
  70782. normalTexture?: IMaterialNormalTextureInfo;
  70783. /**
  70784. * The occlusion map texture
  70785. */
  70786. occlusionTexture?: IMaterialOcclusionTextureInfo;
  70787. /**
  70788. * The emissive map texture
  70789. */
  70790. emissiveTexture?: ITextureInfo;
  70791. /**
  70792. * 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
  70793. */
  70794. emissiveFactor?: number[];
  70795. /**
  70796. * The alpha rendering mode of the material
  70797. */
  70798. alphaMode?: MaterialAlphaMode;
  70799. /**
  70800. * The alpha cutoff value of the material
  70801. */
  70802. alphaCutoff?: number;
  70803. /**
  70804. * Specifies whether the material is double sided
  70805. */
  70806. doubleSided?: boolean;
  70807. }
  70808. /**
  70809. * Geometry to be rendered with the given material
  70810. */
  70811. interface IMeshPrimitive extends IProperty {
  70812. /**
  70813. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  70814. */
  70815. attributes: {
  70816. [name: string]: number;
  70817. };
  70818. /**
  70819. * The index of the accessor that contains the indices
  70820. */
  70821. indices?: number;
  70822. /**
  70823. * The index of the material to apply to this primitive when rendering
  70824. */
  70825. material?: number;
  70826. /**
  70827. * The type of primitives to render. All valid values correspond to WebGL enums
  70828. */
  70829. mode?: MeshPrimitiveMode;
  70830. /**
  70831. * 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
  70832. */
  70833. targets?: {
  70834. [name: string]: number;
  70835. }[];
  70836. }
  70837. /**
  70838. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  70839. */
  70840. interface IMesh extends IChildRootProperty {
  70841. /**
  70842. * An array of primitives, each defining geometry to be rendered with a material
  70843. */
  70844. primitives: IMeshPrimitive[];
  70845. /**
  70846. * Array of weights to be applied to the Morph Targets
  70847. */
  70848. weights?: number[];
  70849. }
  70850. /**
  70851. * A node in the node hierarchy
  70852. */
  70853. interface INode extends IChildRootProperty {
  70854. /**
  70855. * The index of the camera referenced by this node
  70856. */
  70857. camera?: number;
  70858. /**
  70859. * The indices of this node's children
  70860. */
  70861. children?: number[];
  70862. /**
  70863. * The index of the skin referenced by this node
  70864. */
  70865. skin?: number;
  70866. /**
  70867. * A floating-point 4x4 transformation matrix stored in column-major order
  70868. */
  70869. matrix?: number[];
  70870. /**
  70871. * The index of the mesh in this node
  70872. */
  70873. mesh?: number;
  70874. /**
  70875. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  70876. */
  70877. rotation?: number[];
  70878. /**
  70879. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  70880. */
  70881. scale?: number[];
  70882. /**
  70883. * The node's translation along the x, y, and z axes
  70884. */
  70885. translation?: number[];
  70886. /**
  70887. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  70888. */
  70889. weights?: number[];
  70890. }
  70891. /**
  70892. * Texture sampler properties for filtering and wrapping modes
  70893. */
  70894. interface ISampler extends IChildRootProperty {
  70895. /**
  70896. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  70897. */
  70898. magFilter?: TextureMagFilter;
  70899. /**
  70900. * Minification filter. All valid values correspond to WebGL enums
  70901. */
  70902. minFilter?: TextureMinFilter;
  70903. /**
  70904. * S (U) wrapping mode. All valid values correspond to WebGL enums
  70905. */
  70906. wrapS?: TextureWrapMode;
  70907. /**
  70908. * T (V) wrapping mode. All valid values correspond to WebGL enums
  70909. */
  70910. wrapT?: TextureWrapMode;
  70911. }
  70912. /**
  70913. * The root nodes of a scene
  70914. */
  70915. interface IScene extends IChildRootProperty {
  70916. /**
  70917. * The indices of each root node
  70918. */
  70919. nodes: number[];
  70920. }
  70921. /**
  70922. * Joints and matrices defining a skin
  70923. */
  70924. interface ISkin extends IChildRootProperty {
  70925. /**
  70926. * 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
  70927. */
  70928. inverseBindMatrices?: number;
  70929. /**
  70930. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  70931. */
  70932. skeleton?: number;
  70933. /**
  70934. * 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)
  70935. */
  70936. joints: number[];
  70937. }
  70938. /**
  70939. * A texture and its sampler
  70940. */
  70941. interface ITexture extends IChildRootProperty {
  70942. /**
  70943. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  70944. */
  70945. sampler?: number;
  70946. /**
  70947. * The index of the image used by this texture
  70948. */
  70949. source: number;
  70950. }
  70951. /**
  70952. * Reference to a texture
  70953. */
  70954. interface ITextureInfo extends IProperty {
  70955. /**
  70956. * The index of the texture
  70957. */
  70958. index: number;
  70959. /**
  70960. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  70961. */
  70962. texCoord?: number;
  70963. }
  70964. /**
  70965. * The root object for a glTF asset
  70966. */
  70967. interface IGLTF extends IProperty {
  70968. /**
  70969. * An array of accessors. An accessor is a typed view into a bufferView
  70970. */
  70971. accessors?: IAccessor[];
  70972. /**
  70973. * An array of keyframe animations
  70974. */
  70975. animations?: IAnimation[];
  70976. /**
  70977. * Metadata about the glTF asset
  70978. */
  70979. asset: IAsset;
  70980. /**
  70981. * An array of buffers. A buffer points to binary geometry, animation, or skins
  70982. */
  70983. buffers?: IBuffer[];
  70984. /**
  70985. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  70986. */
  70987. bufferViews?: IBufferView[];
  70988. /**
  70989. * An array of cameras
  70990. */
  70991. cameras?: ICamera[];
  70992. /**
  70993. * Names of glTF extensions used somewhere in this asset
  70994. */
  70995. extensionsUsed?: string[];
  70996. /**
  70997. * Names of glTF extensions required to properly load this asset
  70998. */
  70999. extensionsRequired?: string[];
  71000. /**
  71001. * An array of images. An image defines data used to create a texture
  71002. */
  71003. images?: IImage[];
  71004. /**
  71005. * An array of materials. A material defines the appearance of a primitive
  71006. */
  71007. materials?: IMaterial[];
  71008. /**
  71009. * An array of meshes. A mesh is a set of primitives to be rendered
  71010. */
  71011. meshes?: IMesh[];
  71012. /**
  71013. * An array of nodes
  71014. */
  71015. nodes?: INode[];
  71016. /**
  71017. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  71018. */
  71019. samplers?: ISampler[];
  71020. /**
  71021. * The index of the default scene
  71022. */
  71023. scene?: number;
  71024. /**
  71025. * An array of scenes
  71026. */
  71027. scenes?: IScene[];
  71028. /**
  71029. * An array of skins. A skin is defined by joints and matrices
  71030. */
  71031. skins?: ISkin[];
  71032. /**
  71033. * An array of textures
  71034. */
  71035. textures?: ITexture[];
  71036. }
  71037. /**
  71038. * The glTF validation results
  71039. * @ignore
  71040. */
  71041. interface IGLTFValidationResults {
  71042. info: {
  71043. generator: string;
  71044. hasAnimations: boolean;
  71045. hasDefaultScene: boolean;
  71046. hasMaterials: boolean;
  71047. hasMorphTargets: boolean;
  71048. hasSkins: boolean;
  71049. hasTextures: boolean;
  71050. maxAttributesUsed: number;
  71051. primitivesCount: number
  71052. };
  71053. issues: {
  71054. messages: Array<string>;
  71055. numErrors: number;
  71056. numHints: number;
  71057. numInfos: number;
  71058. numWarnings: number;
  71059. truncated: boolean
  71060. };
  71061. mimeType: string;
  71062. uri: string;
  71063. validatedAt: string;
  71064. validatorVersion: string;
  71065. }
  71066. /**
  71067. * The glTF validation options
  71068. */
  71069. interface IGLTFValidationOptions {
  71070. /** Uri to use */
  71071. uri?: string;
  71072. /** Function used to load external resources */
  71073. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  71074. /** Boolean indicating that we need to validate accessor data */
  71075. validateAccessorData?: boolean;
  71076. /** max number of issues allowed */
  71077. maxIssues?: number;
  71078. /** Ignored issues */
  71079. ignoredIssues?: Array<string>;
  71080. /** Value to override severy settings */
  71081. severityOverrides?: Object;
  71082. }
  71083. /**
  71084. * The glTF validator object
  71085. * @ignore
  71086. */
  71087. interface IGLTFValidator {
  71088. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  71089. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  71090. }
  71091. }
  71092. declare module BABYLON {
  71093. /** @hidden */
  71094. export var cellPixelShader: {
  71095. name: string;
  71096. shader: string;
  71097. };
  71098. }
  71099. declare module BABYLON {
  71100. /** @hidden */
  71101. export var cellVertexShader: {
  71102. name: string;
  71103. shader: string;
  71104. };
  71105. }
  71106. declare module BABYLON {
  71107. export class CellMaterial extends BABYLON.PushMaterial {
  71108. private _diffuseTexture;
  71109. diffuseTexture: BABYLON.BaseTexture;
  71110. diffuseColor: BABYLON.Color3; private _computeHighLevel: boolean;
  71111. computeHighLevel: boolean;
  71112. private _disableLighting;
  71113. disableLighting: boolean;
  71114. private _maxSimultaneousLights;
  71115. maxSimultaneousLights: number;
  71116. private _renderId;
  71117. constructor(name: string, scene: BABYLON.Scene);
  71118. needAlphaBlending(): boolean;
  71119. needAlphaTesting(): boolean;
  71120. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71121. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71122. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71123. getAnimatables(): BABYLON.IAnimatable[];
  71124. getActiveTextures(): BABYLON.BaseTexture[];
  71125. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71126. dispose(forceDisposeEffect?: boolean): void;
  71127. getClassName(): string;
  71128. clone(name: string): CellMaterial;
  71129. serialize(): any;
  71130. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  71131. }
  71132. }
  71133. declare module BABYLON {
  71134. export class CustomShaderStructure {
  71135. FragmentStore: string;
  71136. VertexStore: string;
  71137. constructor();
  71138. }
  71139. export class ShaderSpecialParts {
  71140. constructor();
  71141. Fragment_Begin: string;
  71142. Fragment_Definitions: string;
  71143. Fragment_MainBegin: string;
  71144. Fragment_Custom_Diffuse: string;
  71145. Fragment_Before_Lights: string;
  71146. Fragment_Before_Fog: string;
  71147. Fragment_Custom_Alpha: string;
  71148. Fragment_Before_FragColor: string;
  71149. Vertex_Begin: string;
  71150. Vertex_Definitions: string;
  71151. Vertex_MainBegin: string;
  71152. Vertex_Before_PositionUpdated: string;
  71153. Vertex_Before_NormalUpdated: string;
  71154. Vertex_MainEnd: string;
  71155. }
  71156. export class CustomMaterial extends BABYLON.StandardMaterial {
  71157. static ShaderIndexer: number;
  71158. CustomParts: ShaderSpecialParts; private _isCreatedShader: boolean; private _createdShaderName: string; private _customUniform: string[]; private _newUniforms: string[]; private _newUniformInstances: any[]; private _newSamplerInstances: BABYLON.Texture[];
  71159. FragmentShader: string;
  71160. VertexShader: string;
  71161. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  71162. ReviewUniform(name: string, arr: string[]): string[];
  71163. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  71164. constructor(name: string, scene: BABYLON.Scene);
  71165. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  71166. Fragment_Begin(shaderPart: string): CustomMaterial;
  71167. Fragment_Definitions(shaderPart: string): CustomMaterial;
  71168. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  71169. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  71170. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  71171. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  71172. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  71173. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  71174. Vertex_Begin(shaderPart: string): CustomMaterial;
  71175. Vertex_Definitions(shaderPart: string): CustomMaterial;
  71176. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  71177. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  71178. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  71179. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  71180. }
  71181. }
  71182. declare module BABYLON {
  71183. export class ShaderAlebdoParts {
  71184. constructor();
  71185. Fragment_Begin: string;
  71186. Fragment_Definitions: string;
  71187. Fragment_MainBegin: string;
  71188. Fragment_Custom_Albedo: string;
  71189. Fragment_Before_Lights: string;
  71190. Fragment_Custom_MetallicRoughness: string;
  71191. Fragment_Custom_MicroSurface: string;
  71192. Fragment_Before_Fog: string;
  71193. Fragment_Custom_Alpha: string;
  71194. Fragment_Before_FragColor: string;
  71195. Vertex_Begin: string;
  71196. Vertex_Definitions: string;
  71197. Vertex_MainBegin: string;
  71198. Vertex_Before_PositionUpdated: string;
  71199. Vertex_Before_NormalUpdated: string;
  71200. Vertex_MainEnd: string;
  71201. }
  71202. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  71203. static ShaderIndexer: number;
  71204. CustomParts: ShaderAlebdoParts; private _isCreatedShader: boolean; private _createdShaderName: string; private _customUniform: string[]; private _newUniforms: string[]; private _newUniformInstances: any[]; private _newSamplerInstances: BABYLON.Texture[];
  71205. FragmentShader: string;
  71206. VertexShader: string;
  71207. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  71208. ReviewUniform(name: string, arr: string[]): string[];
  71209. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  71210. constructor(name: string, scene: BABYLON.Scene);
  71211. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  71212. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  71213. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  71214. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  71215. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  71216. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  71217. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  71218. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  71219. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  71220. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  71221. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  71222. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  71223. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  71224. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  71225. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  71226. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  71227. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  71228. }
  71229. }
  71230. declare module BABYLON {
  71231. /** @hidden */
  71232. export var firePixelShader: {
  71233. name: string;
  71234. shader: string;
  71235. };
  71236. }
  71237. declare module BABYLON {
  71238. /** @hidden */
  71239. export var fireVertexShader: {
  71240. name: string;
  71241. shader: string;
  71242. };
  71243. }
  71244. declare module BABYLON {
  71245. export class FireMaterial extends BABYLON.PushMaterial {
  71246. private _diffuseTexture;
  71247. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  71248. private _distortionTexture;
  71249. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  71250. private _opacityTexture;
  71251. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  71252. diffuseColor: BABYLON.Color3;
  71253. speed: number;
  71254. private _scaledDiffuse;
  71255. private _renderId;
  71256. private _lastTime;
  71257. constructor(name: string, scene: BABYLON.Scene);
  71258. needAlphaBlending(): boolean;
  71259. needAlphaTesting(): boolean;
  71260. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71261. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71262. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71263. getAnimatables(): BABYLON.IAnimatable[];
  71264. getActiveTextures(): BABYLON.BaseTexture[];
  71265. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71266. getClassName(): string;
  71267. dispose(forceDisposeEffect?: boolean): void;
  71268. clone(name: string): FireMaterial;
  71269. serialize(): any;
  71270. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  71271. }
  71272. }
  71273. declare module BABYLON {
  71274. /** @hidden */
  71275. export var furPixelShader: {
  71276. name: string;
  71277. shader: string;
  71278. };
  71279. }
  71280. declare module BABYLON {
  71281. /** @hidden */
  71282. export var furVertexShader: {
  71283. name: string;
  71284. shader: string;
  71285. };
  71286. }
  71287. declare module BABYLON {
  71288. export class FurMaterial extends BABYLON.PushMaterial {
  71289. private _diffuseTexture;
  71290. diffuseTexture: BABYLON.BaseTexture;
  71291. private _heightTexture;
  71292. heightTexture: BABYLON.BaseTexture;
  71293. diffuseColor: BABYLON.Color3;
  71294. furLength: number;
  71295. furAngle: number;
  71296. furColor: BABYLON.Color3;
  71297. furOffset: number;
  71298. furSpacing: number;
  71299. furGravity: BABYLON.Vector3;
  71300. furSpeed: number;
  71301. furDensity: number;
  71302. furOcclusion: number;
  71303. furTexture: BABYLON.DynamicTexture;
  71304. private _disableLighting;
  71305. disableLighting: boolean;
  71306. private _maxSimultaneousLights;
  71307. maxSimultaneousLights: number;
  71308. highLevelFur: boolean; private _meshes: BABYLON.AbstractMesh[];
  71309. private _renderId;
  71310. private _furTime;
  71311. constructor(name: string, scene: BABYLON.Scene);
  71312. furTime: number;
  71313. needAlphaBlending(): boolean;
  71314. needAlphaTesting(): boolean;
  71315. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71316. updateFur(): void;
  71317. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71318. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71319. getAnimatables(): BABYLON.IAnimatable[];
  71320. getActiveTextures(): BABYLON.BaseTexture[];
  71321. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71322. dispose(forceDisposeEffect?: boolean): void;
  71323. clone(name: string): FurMaterial;
  71324. serialize(): any;
  71325. getClassName(): string;
  71326. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  71327. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  71328. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  71329. }
  71330. }
  71331. declare module BABYLON {
  71332. /** @hidden */
  71333. export var gradientPixelShader: {
  71334. name: string;
  71335. shader: string;
  71336. };
  71337. }
  71338. declare module BABYLON {
  71339. /** @hidden */
  71340. export var gradientVertexShader: {
  71341. name: string;
  71342. shader: string;
  71343. };
  71344. }
  71345. declare module BABYLON {
  71346. export class GradientMaterial extends BABYLON.PushMaterial {
  71347. private _maxSimultaneousLights;
  71348. maxSimultaneousLights: number;
  71349. topColor: BABYLON.Color3;
  71350. topColorAlpha: number;
  71351. bottomColor: BABYLON.Color3;
  71352. bottomColorAlpha: number;
  71353. offset: number;
  71354. scale: number;
  71355. smoothness: number;
  71356. private _disableLighting;
  71357. disableLighting: boolean;
  71358. private _renderId;
  71359. constructor(name: string, scene: BABYLON.Scene);
  71360. needAlphaBlending(): boolean;
  71361. needAlphaTesting(): boolean;
  71362. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71363. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71364. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71365. getAnimatables(): BABYLON.IAnimatable[];
  71366. dispose(forceDisposeEffect?: boolean): void;
  71367. clone(name: string): GradientMaterial;
  71368. serialize(): any;
  71369. getClassName(): string;
  71370. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  71371. }
  71372. }
  71373. declare module BABYLON {
  71374. /** @hidden */
  71375. export var gridPixelShader: {
  71376. name: string;
  71377. shader: string;
  71378. };
  71379. }
  71380. declare module BABYLON {
  71381. /** @hidden */
  71382. export var gridVertexShader: {
  71383. name: string;
  71384. shader: string;
  71385. };
  71386. }
  71387. declare module BABYLON {
  71388. /**
  71389. * The grid materials allows you to wrap any shape with a grid.
  71390. * Colors are customizable.
  71391. */
  71392. export class GridMaterial extends BABYLON.PushMaterial {
  71393. /**
  71394. * Main color of the grid (e.g. between lines)
  71395. */
  71396. mainColor: BABYLON.Color3;
  71397. /**
  71398. * Color of the grid lines.
  71399. */
  71400. lineColor: BABYLON.Color3;
  71401. /**
  71402. * The scale of the grid compared to unit.
  71403. */
  71404. gridRatio: number;
  71405. /**
  71406. * Allows setting an offset for the grid lines.
  71407. */
  71408. gridOffset: BABYLON.Vector3;
  71409. /**
  71410. * The frequency of thicker lines.
  71411. */
  71412. majorUnitFrequency: number;
  71413. /**
  71414. * The visibility of minor units in the grid.
  71415. */
  71416. minorUnitVisibility: number;
  71417. /**
  71418. * The grid opacity outside of the lines.
  71419. */
  71420. opacity: number;
  71421. /**
  71422. * Determine RBG output is premultiplied by alpha value.
  71423. */
  71424. preMultiplyAlpha: boolean;
  71425. private _opacityTexture;
  71426. opacityTexture: BABYLON.BaseTexture;
  71427. private _gridControl;
  71428. private _renderId;
  71429. /**
  71430. * constructor
  71431. * @param name The name given to the material in order to identify it afterwards.
  71432. * @param scene The scene the material is used in.
  71433. */
  71434. constructor(name: string, scene: BABYLON.Scene);
  71435. /**
  71436. * Returns wehter or not the grid requires alpha blending.
  71437. */
  71438. needAlphaBlending(): boolean;
  71439. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  71440. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71441. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71442. /**
  71443. * Dispose the material and its associated resources.
  71444. * @param forceDisposeEffect will also dispose the used effect when true
  71445. */
  71446. dispose(forceDisposeEffect?: boolean): void;
  71447. clone(name: string): GridMaterial;
  71448. serialize(): any;
  71449. getClassName(): string;
  71450. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  71451. }
  71452. }
  71453. declare module BABYLON {
  71454. /** @hidden */
  71455. export var lavaPixelShader: {
  71456. name: string;
  71457. shader: string;
  71458. };
  71459. }
  71460. declare module BABYLON {
  71461. /** @hidden */
  71462. export var lavaVertexShader: {
  71463. name: string;
  71464. shader: string;
  71465. };
  71466. }
  71467. declare module BABYLON {
  71468. export class LavaMaterial extends BABYLON.PushMaterial {
  71469. private _diffuseTexture;
  71470. diffuseTexture: BABYLON.BaseTexture;
  71471. noiseTexture: BABYLON.BaseTexture;
  71472. fogColor: BABYLON.Color3;
  71473. speed: number;
  71474. movingSpeed: number;
  71475. lowFrequencySpeed: number;
  71476. fogDensity: number;
  71477. private _lastTime;
  71478. diffuseColor: BABYLON.Color3;
  71479. private _disableLighting;
  71480. disableLighting: boolean;
  71481. private _unlit;
  71482. unlit: boolean;
  71483. private _maxSimultaneousLights;
  71484. maxSimultaneousLights: number;
  71485. private _scaledDiffuse;
  71486. private _renderId;
  71487. constructor(name: string, scene: BABYLON.Scene);
  71488. needAlphaBlending(): boolean;
  71489. needAlphaTesting(): boolean;
  71490. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71491. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71492. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71493. getAnimatables(): BABYLON.IAnimatable[];
  71494. getActiveTextures(): BABYLON.BaseTexture[];
  71495. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71496. dispose(forceDisposeEffect?: boolean): void;
  71497. clone(name: string): LavaMaterial;
  71498. serialize(): any;
  71499. getClassName(): string;
  71500. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  71501. }
  71502. }
  71503. declare module BABYLON {
  71504. /** @hidden */
  71505. export var mixPixelShader: {
  71506. name: string;
  71507. shader: string;
  71508. };
  71509. }
  71510. declare module BABYLON {
  71511. /** @hidden */
  71512. export var mixVertexShader: {
  71513. name: string;
  71514. shader: string;
  71515. };
  71516. }
  71517. declare module BABYLON {
  71518. export class MixMaterial extends BABYLON.PushMaterial {
  71519. /**
  71520. * Mix textures
  71521. */
  71522. private _mixTexture1;
  71523. mixTexture1: BABYLON.BaseTexture;
  71524. private _mixTexture2;
  71525. mixTexture2: BABYLON.BaseTexture;
  71526. /**
  71527. * Diffuse textures
  71528. */
  71529. private _diffuseTexture1;
  71530. diffuseTexture1: BABYLON.Texture;
  71531. private _diffuseTexture2;
  71532. diffuseTexture2: BABYLON.Texture;
  71533. private _diffuseTexture3;
  71534. diffuseTexture3: BABYLON.Texture;
  71535. private _diffuseTexture4;
  71536. diffuseTexture4: BABYLON.Texture;
  71537. private _diffuseTexture5;
  71538. diffuseTexture5: BABYLON.Texture;
  71539. private _diffuseTexture6;
  71540. diffuseTexture6: BABYLON.Texture;
  71541. private _diffuseTexture7;
  71542. diffuseTexture7: BABYLON.Texture;
  71543. private _diffuseTexture8;
  71544. diffuseTexture8: BABYLON.Texture;
  71545. /**
  71546. * Uniforms
  71547. */
  71548. diffuseColor: BABYLON.Color3;
  71549. specularColor: BABYLON.Color3;
  71550. specularPower: number;
  71551. private _disableLighting;
  71552. disableLighting: boolean;
  71553. private _maxSimultaneousLights;
  71554. maxSimultaneousLights: number;
  71555. private _renderId;
  71556. constructor(name: string, scene: BABYLON.Scene);
  71557. needAlphaBlending(): boolean;
  71558. needAlphaTesting(): boolean;
  71559. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71560. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71561. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71562. getAnimatables(): BABYLON.IAnimatable[];
  71563. getActiveTextures(): BABYLON.BaseTexture[];
  71564. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71565. dispose(forceDisposeEffect?: boolean): void;
  71566. clone(name: string): MixMaterial;
  71567. serialize(): any;
  71568. getClassName(): string;
  71569. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  71570. }
  71571. }
  71572. declare module BABYLON {
  71573. /** @hidden */
  71574. export var normalPixelShader: {
  71575. name: string;
  71576. shader: string;
  71577. };
  71578. }
  71579. declare module BABYLON {
  71580. /** @hidden */
  71581. export var normalVertexShader: {
  71582. name: string;
  71583. shader: string;
  71584. };
  71585. }
  71586. declare module BABYLON {
  71587. export class NormalMaterial extends BABYLON.PushMaterial {
  71588. private _diffuseTexture;
  71589. diffuseTexture: BABYLON.BaseTexture;
  71590. diffuseColor: BABYLON.Color3;
  71591. private _disableLighting;
  71592. disableLighting: boolean;
  71593. private _maxSimultaneousLights;
  71594. maxSimultaneousLights: number;
  71595. private _renderId;
  71596. constructor(name: string, scene: BABYLON.Scene);
  71597. needAlphaBlending(): boolean;
  71598. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  71599. needAlphaTesting(): boolean;
  71600. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71601. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71602. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71603. getAnimatables(): BABYLON.IAnimatable[];
  71604. getActiveTextures(): BABYLON.BaseTexture[];
  71605. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71606. dispose(forceDisposeEffect?: boolean): void;
  71607. clone(name: string): NormalMaterial;
  71608. serialize(): any;
  71609. getClassName(): string;
  71610. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  71611. }
  71612. }
  71613. declare module BABYLON {
  71614. /** @hidden */
  71615. export var shadowOnlyPixelShader: {
  71616. name: string;
  71617. shader: string;
  71618. };
  71619. }
  71620. declare module BABYLON {
  71621. /** @hidden */
  71622. export var shadowOnlyVertexShader: {
  71623. name: string;
  71624. shader: string;
  71625. };
  71626. }
  71627. declare module BABYLON {
  71628. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  71629. private _renderId;
  71630. private _activeLight;
  71631. constructor(name: string, scene: BABYLON.Scene);
  71632. shadowColor: BABYLON.Color3;
  71633. needAlphaBlending(): boolean;
  71634. needAlphaTesting(): boolean;
  71635. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71636. activeLight: BABYLON.IShadowLight;
  71637. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71638. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71639. clone(name: string): ShadowOnlyMaterial;
  71640. serialize(): any;
  71641. getClassName(): string;
  71642. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  71643. }
  71644. }
  71645. declare module BABYLON {
  71646. /** @hidden */
  71647. export var simplePixelShader: {
  71648. name: string;
  71649. shader: string;
  71650. };
  71651. }
  71652. declare module BABYLON {
  71653. /** @hidden */
  71654. export var simpleVertexShader: {
  71655. name: string;
  71656. shader: string;
  71657. };
  71658. }
  71659. declare module BABYLON {
  71660. export class SimpleMaterial extends BABYLON.PushMaterial {
  71661. private _diffuseTexture;
  71662. diffuseTexture: BABYLON.BaseTexture;
  71663. diffuseColor: BABYLON.Color3;
  71664. private _disableLighting;
  71665. disableLighting: boolean;
  71666. private _maxSimultaneousLights;
  71667. maxSimultaneousLights: number;
  71668. private _renderId;
  71669. constructor(name: string, scene: BABYLON.Scene);
  71670. needAlphaBlending(): boolean;
  71671. needAlphaTesting(): boolean;
  71672. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71673. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71674. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71675. getAnimatables(): BABYLON.IAnimatable[];
  71676. getActiveTextures(): BABYLON.BaseTexture[];
  71677. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71678. dispose(forceDisposeEffect?: boolean): void;
  71679. clone(name: string): SimpleMaterial;
  71680. serialize(): any;
  71681. getClassName(): string;
  71682. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  71683. }
  71684. }
  71685. declare module BABYLON {
  71686. /** @hidden */
  71687. export var skyPixelShader: {
  71688. name: string;
  71689. shader: string;
  71690. };
  71691. }
  71692. declare module BABYLON {
  71693. /** @hidden */
  71694. export var skyVertexShader: {
  71695. name: string;
  71696. shader: string;
  71697. };
  71698. }
  71699. declare module BABYLON {
  71700. /**
  71701. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  71702. * @see https://doc.babylonjs.com/extensions/sky
  71703. */
  71704. export class SkyMaterial extends BABYLON.PushMaterial {
  71705. /**
  71706. * Defines the overall luminance of sky in interval ]0, 1[.
  71707. */
  71708. luminance: number;
  71709. /**
  71710. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  71711. */
  71712. turbidity: number;
  71713. /**
  71714. * Defines the sky appearance (light intensity).
  71715. */
  71716. rayleigh: number;
  71717. /**
  71718. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  71719. */
  71720. mieCoefficient: number;
  71721. /**
  71722. * Defines the amount of haze particles following the Mie scattering theory.
  71723. */
  71724. mieDirectionalG: number;
  71725. /**
  71726. * Defines the distance of the sun according to the active scene camera.
  71727. */
  71728. distance: number;
  71729. /**
  71730. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  71731. * "inclined".
  71732. */
  71733. inclination: number;
  71734. /**
  71735. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  71736. * an object direction and a reference direction.
  71737. */
  71738. azimuth: number;
  71739. /**
  71740. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  71741. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  71742. */
  71743. sunPosition: BABYLON.Vector3;
  71744. /**
  71745. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  71746. * .sunPosition property.
  71747. */
  71748. useSunPosition: boolean;
  71749. /**
  71750. * Defines an offset vector used to get a horizon offset.
  71751. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  71752. */
  71753. cameraOffset: BABYLON.Vector3;
  71754. private _cameraPosition;
  71755. private _renderId;
  71756. /**
  71757. * Instantiates a new sky material.
  71758. * This material allows to create dynamic and texture free
  71759. * effects for skyboxes by taking care of the atmosphere state.
  71760. * @see https://doc.babylonjs.com/extensions/sky
  71761. * @param name Define the name of the material in the scene
  71762. * @param scene Define the scene the material belong to
  71763. */
  71764. constructor(name: string, scene: BABYLON.Scene);
  71765. /**
  71766. * Specifies if the material will require alpha blending
  71767. * @returns a boolean specifying if alpha blending is needed
  71768. */
  71769. needAlphaBlending(): boolean;
  71770. /**
  71771. * Specifies if this material should be rendered in alpha test mode
  71772. * @returns false as the sky material doesn't need alpha testing.
  71773. */
  71774. needAlphaTesting(): boolean;
  71775. /**
  71776. * Get the texture used for alpha test purpose.
  71777. * @returns null as the sky material has no texture.
  71778. */
  71779. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71780. /**
  71781. * Get if the submesh is ready to be used and all its information available.
  71782. * Child classes can use it to update shaders
  71783. * @param mesh defines the mesh to check
  71784. * @param subMesh defines which submesh to check
  71785. * @param useInstances specifies that instances should be used
  71786. * @returns a boolean indicating that the submesh is ready or not
  71787. */
  71788. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71789. /**
  71790. * Binds the submesh to this material by preparing the effect and shader to draw
  71791. * @param world defines the world transformation matrix
  71792. * @param mesh defines the mesh containing the submesh
  71793. * @param subMesh defines the submesh to bind the material to
  71794. */
  71795. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71796. /**
  71797. * Get the list of animatables in the material.
  71798. * @returns the list of animatables object used in the material
  71799. */
  71800. getAnimatables(): BABYLON.IAnimatable[];
  71801. /**
  71802. * Disposes the material
  71803. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  71804. */
  71805. dispose(forceDisposeEffect?: boolean): void;
  71806. /**
  71807. * Makes a duplicate of the material, and gives it a new name
  71808. * @param name defines the new name for the duplicated material
  71809. * @returns the cloned material
  71810. */
  71811. clone(name: string): SkyMaterial;
  71812. /**
  71813. * Serializes this material in a JSON representation
  71814. * @returns the serialized material object
  71815. */
  71816. serialize(): any;
  71817. /**
  71818. * Gets the current class name of the material e.g. "SkyMaterial"
  71819. * Mainly use in serialization.
  71820. * @returns the class name
  71821. */
  71822. getClassName(): string;
  71823. /**
  71824. * Creates a sky material from parsed material data
  71825. * @param source defines the JSON representation of the material
  71826. * @param scene defines the hosting scene
  71827. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71828. * @returns a new sky material
  71829. */
  71830. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  71831. }
  71832. }
  71833. declare module BABYLON {
  71834. /** @hidden */
  71835. export var terrainPixelShader: {
  71836. name: string;
  71837. shader: string;
  71838. };
  71839. }
  71840. declare module BABYLON {
  71841. /** @hidden */
  71842. export var terrainVertexShader: {
  71843. name: string;
  71844. shader: string;
  71845. };
  71846. }
  71847. declare module BABYLON {
  71848. export class TerrainMaterial extends BABYLON.PushMaterial {
  71849. private _mixTexture;
  71850. mixTexture: BABYLON.BaseTexture;
  71851. private _diffuseTexture1;
  71852. diffuseTexture1: BABYLON.Texture;
  71853. private _diffuseTexture2;
  71854. diffuseTexture2: BABYLON.Texture;
  71855. private _diffuseTexture3;
  71856. diffuseTexture3: BABYLON.Texture;
  71857. private _bumpTexture1;
  71858. bumpTexture1: BABYLON.Texture;
  71859. private _bumpTexture2;
  71860. bumpTexture2: BABYLON.Texture;
  71861. private _bumpTexture3;
  71862. bumpTexture3: BABYLON.Texture;
  71863. diffuseColor: BABYLON.Color3;
  71864. specularColor: BABYLON.Color3;
  71865. specularPower: number;
  71866. private _disableLighting;
  71867. disableLighting: boolean;
  71868. private _maxSimultaneousLights;
  71869. maxSimultaneousLights: number;
  71870. private _renderId;
  71871. constructor(name: string, scene: BABYLON.Scene);
  71872. needAlphaBlending(): boolean;
  71873. needAlphaTesting(): boolean;
  71874. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71875. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71876. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71877. getAnimatables(): BABYLON.IAnimatable[];
  71878. getActiveTextures(): BABYLON.BaseTexture[];
  71879. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71880. dispose(forceDisposeEffect?: boolean): void;
  71881. clone(name: string): TerrainMaterial;
  71882. serialize(): any;
  71883. getClassName(): string;
  71884. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  71885. }
  71886. }
  71887. declare module BABYLON {
  71888. /** @hidden */
  71889. export var triplanarPixelShader: {
  71890. name: string;
  71891. shader: string;
  71892. };
  71893. }
  71894. declare module BABYLON {
  71895. /** @hidden */
  71896. export var triplanarVertexShader: {
  71897. name: string;
  71898. shader: string;
  71899. };
  71900. }
  71901. declare module BABYLON {
  71902. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  71903. mixTexture: BABYLON.BaseTexture;
  71904. private _diffuseTextureX;
  71905. diffuseTextureX: BABYLON.BaseTexture;
  71906. private _diffuseTextureY;
  71907. diffuseTextureY: BABYLON.BaseTexture;
  71908. private _diffuseTextureZ;
  71909. diffuseTextureZ: BABYLON.BaseTexture;
  71910. private _normalTextureX;
  71911. normalTextureX: BABYLON.BaseTexture;
  71912. private _normalTextureY;
  71913. normalTextureY: BABYLON.BaseTexture;
  71914. private _normalTextureZ;
  71915. normalTextureZ: BABYLON.BaseTexture;
  71916. tileSize: number;
  71917. diffuseColor: BABYLON.Color3;
  71918. specularColor: BABYLON.Color3;
  71919. specularPower: number;
  71920. private _disableLighting;
  71921. disableLighting: boolean;
  71922. private _maxSimultaneousLights;
  71923. maxSimultaneousLights: number;
  71924. private _renderId;
  71925. constructor(name: string, scene: BABYLON.Scene);
  71926. needAlphaBlending(): boolean;
  71927. needAlphaTesting(): boolean;
  71928. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71929. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71930. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71931. getAnimatables(): BABYLON.IAnimatable[];
  71932. getActiveTextures(): BABYLON.BaseTexture[];
  71933. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71934. dispose(forceDisposeEffect?: boolean): void;
  71935. clone(name: string): TriPlanarMaterial;
  71936. serialize(): any;
  71937. getClassName(): string;
  71938. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  71939. }
  71940. }
  71941. declare module BABYLON {
  71942. /** @hidden */
  71943. export var waterPixelShader: {
  71944. name: string;
  71945. shader: string;
  71946. };
  71947. }
  71948. declare module BABYLON {
  71949. /** @hidden */
  71950. export var waterVertexShader: {
  71951. name: string;
  71952. shader: string;
  71953. };
  71954. }
  71955. declare module BABYLON {
  71956. export class WaterMaterial extends BABYLON.PushMaterial {
  71957. renderTargetSize: BABYLON.Vector2;
  71958. private _bumpTexture;
  71959. bumpTexture: BABYLON.BaseTexture;
  71960. diffuseColor: BABYLON.Color3;
  71961. specularColor: BABYLON.Color3;
  71962. specularPower: number;
  71963. private _disableLighting;
  71964. disableLighting: boolean;
  71965. private _maxSimultaneousLights;
  71966. maxSimultaneousLights: number;
  71967. /**
  71968. * @param {number}: Represents the wind force
  71969. */
  71970. windForce: number;
  71971. /**
  71972. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  71973. */
  71974. windDirection: BABYLON.Vector2;
  71975. /**
  71976. * @param {number}: Wave height, represents the height of the waves
  71977. */
  71978. waveHeight: number;
  71979. /**
  71980. * @param {number}: Bump height, represents the bump height related to the bump map
  71981. */
  71982. bumpHeight: number;
  71983. /**
  71984. * @param {boolean}: Add a smaller moving bump to less steady waves.
  71985. */
  71986. private _bumpSuperimpose;
  71987. bumpSuperimpose: boolean;
  71988. /**
  71989. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  71990. */
  71991. private _fresnelSeparate;
  71992. fresnelSeparate: boolean;
  71993. /**
  71994. * @param {boolean}: bump Waves modify the reflection.
  71995. */
  71996. private _bumpAffectsReflection;
  71997. bumpAffectsReflection: boolean;
  71998. /**
  71999. * @param {number}: The water color blended with the refraction (near)
  72000. */
  72001. waterColor: BABYLON.Color3;
  72002. /**
  72003. * @param {number}: The blend factor related to the water color
  72004. */
  72005. colorBlendFactor: number;
  72006. /**
  72007. * @param {number}: The water color blended with the reflection (far)
  72008. */
  72009. waterColor2: BABYLON.Color3;
  72010. /**
  72011. * @param {number}: The blend factor related to the water color (reflection, far)
  72012. */
  72013. colorBlendFactor2: number;
  72014. /**
  72015. * @param {number}: Represents the maximum length of a wave
  72016. */
  72017. waveLength: number;
  72018. /**
  72019. * @param {number}: Defines the waves speed
  72020. */
  72021. waveSpeed: number;
  72022. /**
  72023. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  72024. * will avoid calculating useless pixels in the pixel shader of the water material.
  72025. */
  72026. disableClipPlane: boolean;
  72027. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  72028. private _mesh;
  72029. private _refractionRTT;
  72030. private _reflectionRTT;
  72031. private _reflectionTransform;
  72032. private _lastTime;
  72033. private _lastDeltaTime;
  72034. private _renderId;
  72035. private _useLogarithmicDepth;
  72036. private _waitingRenderList;
  72037. private _imageProcessingConfiguration;
  72038. private _imageProcessingObserver;
  72039. /**
  72040. * Gets a boolean indicating that current material needs to register RTT
  72041. */
  72042. readonly hasRenderTargetTextures: boolean;
  72043. /**
  72044. * Constructor
  72045. */
  72046. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  72047. useLogarithmicDepth: boolean;
  72048. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  72049. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  72050. addToRenderList(node: any): void;
  72051. enableRenderTargets(enable: boolean): void;
  72052. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  72053. readonly renderTargetsEnabled: boolean;
  72054. needAlphaBlending(): boolean;
  72055. needAlphaTesting(): boolean;
  72056. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72057. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72058. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72059. private _createRenderTargets;
  72060. getAnimatables(): BABYLON.IAnimatable[];
  72061. getActiveTextures(): BABYLON.BaseTexture[];
  72062. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72063. dispose(forceDisposeEffect?: boolean): void;
  72064. clone(name: string): WaterMaterial;
  72065. serialize(): any;
  72066. getClassName(): string;
  72067. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  72068. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  72069. }
  72070. }
  72071. declare module BABYLON {
  72072. /** @hidden */
  72073. export var asciiartPixelShader: {
  72074. name: string;
  72075. shader: string;
  72076. };
  72077. }
  72078. declare module BABYLON {
  72079. /**
  72080. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  72081. *
  72082. * It basically takes care rendering the font front the given font size to a texture.
  72083. * This is used later on in the postprocess.
  72084. */
  72085. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  72086. private _font;
  72087. private _text;
  72088. private _charSize;
  72089. /**
  72090. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  72091. */
  72092. readonly charSize: number;
  72093. /**
  72094. * Create a new instance of the Ascii Art FontTexture class
  72095. * @param name the name of the texture
  72096. * @param font the font to use, use the W3C CSS notation
  72097. * @param text the caracter set to use in the rendering.
  72098. * @param scene the scene that owns the texture
  72099. */
  72100. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  72101. /**
  72102. * Gets the max char width of a font.
  72103. * @param font the font to use, use the W3C CSS notation
  72104. * @return the max char width
  72105. */
  72106. private getFontWidth;
  72107. /**
  72108. * Gets the max char height of a font.
  72109. * @param font the font to use, use the W3C CSS notation
  72110. * @return the max char height
  72111. */
  72112. private getFontHeight;
  72113. /**
  72114. * Clones the current AsciiArtTexture.
  72115. * @return the clone of the texture.
  72116. */
  72117. clone(): AsciiArtFontTexture;
  72118. /**
  72119. * Parses a json object representing the texture and returns an instance of it.
  72120. * @param source the source JSON representation
  72121. * @param scene the scene to create the texture for
  72122. * @return the parsed texture
  72123. */
  72124. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  72125. }
  72126. /**
  72127. * Option available in the Ascii Art Post Process.
  72128. */
  72129. export interface IAsciiArtPostProcessOptions {
  72130. /**
  72131. * The font to use following the w3c font definition.
  72132. */
  72133. font?: string;
  72134. /**
  72135. * The character set to use in the postprocess.
  72136. */
  72137. characterSet?: string;
  72138. /**
  72139. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  72140. * This number is defined between 0 and 1;
  72141. */
  72142. mixToTile?: number;
  72143. /**
  72144. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  72145. * This number is defined between 0 and 1;
  72146. */
  72147. mixToNormal?: number;
  72148. }
  72149. /**
  72150. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  72151. *
  72152. * Simmply add it to your scene and let the nerd that lives in you have fun.
  72153. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  72154. */
  72155. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  72156. /**
  72157. * The font texture used to render the char in the post process.
  72158. */
  72159. private _asciiArtFontTexture;
  72160. /**
  72161. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  72162. * This number is defined between 0 and 1;
  72163. */
  72164. mixToTile: number;
  72165. /**
  72166. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  72167. * This number is defined between 0 and 1;
  72168. */
  72169. mixToNormal: number;
  72170. /**
  72171. * Instantiates a new Ascii Art Post Process.
  72172. * @param name the name to give to the postprocess
  72173. * @camera the camera to apply the post process to.
  72174. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  72175. */
  72176. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  72177. }
  72178. }
  72179. declare module BABYLON {
  72180. /** @hidden */
  72181. export var digitalrainPixelShader: {
  72182. name: string;
  72183. shader: string;
  72184. };
  72185. }
  72186. declare module BABYLON {
  72187. /**
  72188. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  72189. *
  72190. * It basically takes care rendering the font front the given font size to a texture.
  72191. * This is used later on in the postprocess.
  72192. */
  72193. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  72194. private _font;
  72195. private _text;
  72196. private _charSize;
  72197. /**
  72198. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  72199. */
  72200. readonly charSize: number;
  72201. /**
  72202. * Create a new instance of the Digital Rain FontTexture class
  72203. * @param name the name of the texture
  72204. * @param font the font to use, use the W3C CSS notation
  72205. * @param text the caracter set to use in the rendering.
  72206. * @param scene the scene that owns the texture
  72207. */
  72208. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  72209. /**
  72210. * Gets the max char width of a font.
  72211. * @param font the font to use, use the W3C CSS notation
  72212. * @return the max char width
  72213. */
  72214. private getFontWidth;
  72215. /**
  72216. * Gets the max char height of a font.
  72217. * @param font the font to use, use the W3C CSS notation
  72218. * @return the max char height
  72219. */
  72220. private getFontHeight;
  72221. /**
  72222. * Clones the current DigitalRainFontTexture.
  72223. * @return the clone of the texture.
  72224. */
  72225. clone(): DigitalRainFontTexture;
  72226. /**
  72227. * Parses a json object representing the texture and returns an instance of it.
  72228. * @param source the source JSON representation
  72229. * @param scene the scene to create the texture for
  72230. * @return the parsed texture
  72231. */
  72232. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  72233. }
  72234. /**
  72235. * Option available in the Digital Rain Post Process.
  72236. */
  72237. export interface IDigitalRainPostProcessOptions {
  72238. /**
  72239. * The font to use following the w3c font definition.
  72240. */
  72241. font?: string;
  72242. /**
  72243. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  72244. * This number is defined between 0 and 1;
  72245. */
  72246. mixToTile?: number;
  72247. /**
  72248. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  72249. * This number is defined between 0 and 1;
  72250. */
  72251. mixToNormal?: number;
  72252. }
  72253. /**
  72254. * DigitalRainPostProcess helps rendering everithing in digital rain.
  72255. *
  72256. * Simmply add it to your scene and let the nerd that lives in you have fun.
  72257. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  72258. */
  72259. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  72260. /**
  72261. * The font texture used to render the char in the post process.
  72262. */
  72263. private _digitalRainFontTexture;
  72264. /**
  72265. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  72266. * This number is defined between 0 and 1;
  72267. */
  72268. mixToTile: number;
  72269. /**
  72270. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  72271. * This number is defined between 0 and 1;
  72272. */
  72273. mixToNormal: number;
  72274. /**
  72275. * Instantiates a new Digital Rain Post Process.
  72276. * @param name the name to give to the postprocess
  72277. * @camera the camera to apply the post process to.
  72278. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  72279. */
  72280. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  72281. }
  72282. }
  72283. declare module BABYLON {
  72284. /** @hidden */
  72285. export var oceanPostProcessPixelShader: {
  72286. name: string;
  72287. shader: string;
  72288. };
  72289. }
  72290. declare module BABYLON {
  72291. /**
  72292. * Option available in the Ocean Post Process.
  72293. */
  72294. export interface IOceanPostProcessOptions {
  72295. /**
  72296. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  72297. */
  72298. reflectionSize?: number | {
  72299. width: number;
  72300. height: number;
  72301. } | {
  72302. ratio: number;
  72303. };
  72304. /**
  72305. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  72306. */
  72307. refractionSize?: number | {
  72308. width: number;
  72309. height: number;
  72310. } | {
  72311. ratio: number;
  72312. };
  72313. }
  72314. /**
  72315. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  72316. *
  72317. * Simmply add it to your scene and let the nerd that lives in you have fun.
  72318. * Example usage:
  72319. * var pp = new OceanPostProcess("myOcean", camera);
  72320. * pp.reflectionEnabled = true;
  72321. * pp.refractionEnabled = true;
  72322. */
  72323. export class OceanPostProcess extends BABYLON.PostProcess {
  72324. /**
  72325. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  72326. */
  72327. /**
  72328. * Sets weither or not the real-time reflection is enabled on the ocean.
  72329. * Is set to true, the reflection mirror texture will be used as reflection texture.
  72330. */
  72331. reflectionEnabled: boolean;
  72332. /**
  72333. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  72334. */
  72335. /**
  72336. * Sets weither or not the real-time refraction is enabled on the ocean.
  72337. * Is set to true, the refraction render target texture will be used as refraction texture.
  72338. */
  72339. refractionEnabled: boolean;
  72340. /**
  72341. * Gets wether or not the post-processes is supported by the running hardware.
  72342. * This requires draw buffer supports.
  72343. */
  72344. readonly isSupported: boolean;
  72345. /**
  72346. * This is the reflection mirror texture used to display reflections on the ocean.
  72347. * By default, render list is empty.
  72348. */
  72349. reflectionTexture: BABYLON.MirrorTexture;
  72350. /**
  72351. * This is the refraction render target texture used to display refraction on the ocean.
  72352. * By default, render list is empty.
  72353. */
  72354. refractionTexture: BABYLON.RenderTargetTexture;
  72355. private _time;
  72356. private _cameraRotation;
  72357. private _cameraViewMatrix;
  72358. private _reflectionEnabled;
  72359. private _refractionEnabled;
  72360. private _geometryRenderer;
  72361. /**
  72362. * Instantiates a new Ocean Post Process.
  72363. * @param name the name to give to the postprocess.
  72364. * @camera the camera to apply the post process to.
  72365. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  72366. */
  72367. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  72368. /**
  72369. * Returns the appropriate defines according to the current configuration.
  72370. */
  72371. private _getDefines;
  72372. /**
  72373. * Computes the current camera rotation as the shader requires a camera rotation.
  72374. */
  72375. private _computeCameraRotation;
  72376. }
  72377. }
  72378. declare module BABYLON {
  72379. /** @hidden */
  72380. export var brickProceduralTexturePixelShader: {
  72381. name: string;
  72382. shader: string;
  72383. };
  72384. }
  72385. declare module BABYLON {
  72386. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  72387. private _numberOfBricksHeight;
  72388. private _numberOfBricksWidth;
  72389. private _jointColor;
  72390. private _brickColor;
  72391. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72392. updateShaderUniforms(): void;
  72393. numberOfBricksHeight: number;
  72394. numberOfBricksWidth: number;
  72395. jointColor: BABYLON.Color3;
  72396. brickColor: BABYLON.Color3;
  72397. /**
  72398. * Serializes this brick procedural texture
  72399. * @returns a serialized brick procedural texture object
  72400. */
  72401. serialize(): any;
  72402. /**
  72403. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  72404. * @param parsedTexture defines parsed texture data
  72405. * @param scene defines the current scene
  72406. * @param rootUrl defines the root URL containing brick procedural texture information
  72407. * @returns a parsed Brick Procedural BABYLON.Texture
  72408. */
  72409. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  72410. }
  72411. }
  72412. declare module BABYLON {
  72413. /** @hidden */
  72414. export var cloudProceduralTexturePixelShader: {
  72415. name: string;
  72416. shader: string;
  72417. };
  72418. }
  72419. declare module BABYLON {
  72420. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  72421. private _skyColor;
  72422. private _cloudColor;
  72423. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72424. updateShaderUniforms(): void;
  72425. skyColor: BABYLON.Color4;
  72426. cloudColor: BABYLON.Color4;
  72427. /**
  72428. * Serializes this cloud procedural texture
  72429. * @returns a serialized cloud procedural texture object
  72430. */
  72431. serialize(): any;
  72432. /**
  72433. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  72434. * @param parsedTexture defines parsed texture data
  72435. * @param scene defines the current scene
  72436. * @param rootUrl defines the root URL containing cloud procedural texture information
  72437. * @returns a parsed Cloud Procedural BABYLON.Texture
  72438. */
  72439. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  72440. }
  72441. }
  72442. declare module BABYLON {
  72443. /** @hidden */
  72444. export var fireProceduralTexturePixelShader: {
  72445. name: string;
  72446. shader: string;
  72447. };
  72448. }
  72449. declare module BABYLON {
  72450. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  72451. private _time;
  72452. private _speed;
  72453. private _autoGenerateTime;
  72454. private _fireColors;
  72455. private _alphaThreshold;
  72456. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72457. updateShaderUniforms(): void;
  72458. render(useCameraPostProcess?: boolean): void;
  72459. static readonly PurpleFireColors: BABYLON.Color3[];
  72460. static readonly GreenFireColors: BABYLON.Color3[];
  72461. static readonly RedFireColors: BABYLON.Color3[];
  72462. static readonly BlueFireColors: BABYLON.Color3[];
  72463. autoGenerateTime: boolean;
  72464. fireColors: BABYLON.Color3[];
  72465. time: number;
  72466. speed: BABYLON.Vector2;
  72467. alphaThreshold: number;
  72468. /**
  72469. * Serializes this fire procedural texture
  72470. * @returns a serialized fire procedural texture object
  72471. */
  72472. serialize(): any;
  72473. /**
  72474. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  72475. * @param parsedTexture defines parsed texture data
  72476. * @param scene defines the current scene
  72477. * @param rootUrl defines the root URL containing fire procedural texture information
  72478. * @returns a parsed Fire Procedural BABYLON.Texture
  72479. */
  72480. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  72481. }
  72482. }
  72483. declare module BABYLON {
  72484. /** @hidden */
  72485. export var grassProceduralTexturePixelShader: {
  72486. name: string;
  72487. shader: string;
  72488. };
  72489. }
  72490. declare module BABYLON {
  72491. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  72492. private _grassColors;
  72493. private _groundColor;
  72494. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72495. updateShaderUniforms(): void;
  72496. grassColors: BABYLON.Color3[];
  72497. groundColor: BABYLON.Color3;
  72498. /**
  72499. * Serializes this grass procedural texture
  72500. * @returns a serialized grass procedural texture object
  72501. */
  72502. serialize(): any;
  72503. /**
  72504. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  72505. * @param parsedTexture defines parsed texture data
  72506. * @param scene defines the current scene
  72507. * @param rootUrl defines the root URL containing grass procedural texture information
  72508. * @returns a parsed Grass Procedural BABYLON.Texture
  72509. */
  72510. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  72511. }
  72512. }
  72513. declare module BABYLON {
  72514. /** @hidden */
  72515. export var marbleProceduralTexturePixelShader: {
  72516. name: string;
  72517. shader: string;
  72518. };
  72519. }
  72520. declare module BABYLON {
  72521. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  72522. private _numberOfTilesHeight;
  72523. private _numberOfTilesWidth;
  72524. private _amplitude;
  72525. private _jointColor;
  72526. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72527. updateShaderUniforms(): void;
  72528. numberOfTilesHeight: number;
  72529. amplitude: number;
  72530. numberOfTilesWidth: number;
  72531. jointColor: BABYLON.Color3;
  72532. /**
  72533. * Serializes this marble procedural texture
  72534. * @returns a serialized marble procedural texture object
  72535. */
  72536. serialize(): any;
  72537. /**
  72538. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  72539. * @param parsedTexture defines parsed texture data
  72540. * @param scene defines the current scene
  72541. * @param rootUrl defines the root URL containing marble procedural texture information
  72542. * @returns a parsed Marble Procedural BABYLON.Texture
  72543. */
  72544. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  72545. }
  72546. }
  72547. declare module BABYLON {
  72548. /** @hidden */
  72549. export var normalMapProceduralTexturePixelShader: {
  72550. name: string;
  72551. shader: string;
  72552. };
  72553. }
  72554. declare module BABYLON {
  72555. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  72556. private _baseTexture;
  72557. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72558. updateShaderUniforms(): void;
  72559. render(useCameraPostProcess?: boolean): void;
  72560. resize(size: any, generateMipMaps: any): void;
  72561. baseTexture: BABYLON.Texture;
  72562. /**
  72563. * Serializes this normal map procedural texture
  72564. * @returns a serialized normal map procedural texture object
  72565. */
  72566. serialize(): any;
  72567. /**
  72568. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  72569. * @param parsedTexture defines parsed texture data
  72570. * @param scene defines the current scene
  72571. * @param rootUrl defines the root URL containing normal map procedural texture information
  72572. * @returns a parsed Normal Map Procedural BABYLON.Texture
  72573. */
  72574. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  72575. }
  72576. }
  72577. declare module BABYLON {
  72578. /** @hidden */
  72579. export var perlinNoiseProceduralTexturePixelShader: {
  72580. name: string;
  72581. shader: string;
  72582. };
  72583. }
  72584. declare module BABYLON {
  72585. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  72586. time: number;
  72587. timeScale: number;
  72588. translationSpeed: number;
  72589. private _currentTranslation;
  72590. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72591. updateShaderUniforms(): void;
  72592. render(useCameraPostProcess?: boolean): void;
  72593. resize(size: any, generateMipMaps: any): void;
  72594. /**
  72595. * Serializes this perlin noise procedural texture
  72596. * @returns a serialized perlin noise procedural texture object
  72597. */
  72598. serialize(): any;
  72599. /**
  72600. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  72601. * @param parsedTexture defines parsed texture data
  72602. * @param scene defines the current scene
  72603. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  72604. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  72605. */
  72606. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  72607. }
  72608. }
  72609. declare module BABYLON {
  72610. /** @hidden */
  72611. export var roadProceduralTexturePixelShader: {
  72612. name: string;
  72613. shader: string;
  72614. };
  72615. }
  72616. declare module BABYLON {
  72617. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  72618. private _roadColor;
  72619. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72620. updateShaderUniforms(): void;
  72621. roadColor: BABYLON.Color3;
  72622. /**
  72623. * Serializes this road procedural texture
  72624. * @returns a serialized road procedural texture object
  72625. */
  72626. serialize(): any;
  72627. /**
  72628. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  72629. * @param parsedTexture defines parsed texture data
  72630. * @param scene defines the current scene
  72631. * @param rootUrl defines the root URL containing road procedural texture information
  72632. * @returns a parsed Road Procedural BABYLON.Texture
  72633. */
  72634. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  72635. }
  72636. }
  72637. declare module BABYLON {
  72638. /** @hidden */
  72639. export var starfieldProceduralTexturePixelShader: {
  72640. name: string;
  72641. shader: string;
  72642. };
  72643. }
  72644. declare module BABYLON {
  72645. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  72646. private _time;
  72647. private _alpha;
  72648. private _beta;
  72649. private _zoom;
  72650. private _formuparam;
  72651. private _stepsize;
  72652. private _tile;
  72653. private _brightness;
  72654. private _darkmatter;
  72655. private _distfading;
  72656. private _saturation;
  72657. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72658. updateShaderUniforms(): void;
  72659. time: number;
  72660. alpha: number;
  72661. beta: number;
  72662. formuparam: number;
  72663. stepsize: number;
  72664. zoom: number;
  72665. tile: number;
  72666. brightness: number;
  72667. darkmatter: number;
  72668. distfading: number;
  72669. saturation: number;
  72670. /**
  72671. * Serializes this starfield procedural texture
  72672. * @returns a serialized starfield procedural texture object
  72673. */
  72674. serialize(): any;
  72675. /**
  72676. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  72677. * @param parsedTexture defines parsed texture data
  72678. * @param scene defines the current scene
  72679. * @param rootUrl defines the root URL containing startfield procedural texture information
  72680. * @returns a parsed Starfield Procedural BABYLON.Texture
  72681. */
  72682. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  72683. }
  72684. }
  72685. declare module BABYLON {
  72686. /** @hidden */
  72687. export var woodProceduralTexturePixelShader: {
  72688. name: string;
  72689. shader: string;
  72690. };
  72691. }
  72692. declare module BABYLON {
  72693. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  72694. private _ampScale;
  72695. private _woodColor;
  72696. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72697. updateShaderUniforms(): void;
  72698. ampScale: number;
  72699. woodColor: BABYLON.Color3;
  72700. /**
  72701. * Serializes this wood procedural texture
  72702. * @returns a serialized wood procedural texture object
  72703. */
  72704. serialize(): any;
  72705. /**
  72706. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  72707. * @param parsedTexture defines parsed texture data
  72708. * @param scene defines the current scene
  72709. * @param rootUrl defines the root URL containing wood procedural texture information
  72710. * @returns a parsed Wood Procedural BABYLON.Texture
  72711. */
  72712. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  72713. }
  72714. }