babylon.gui.js 672 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory(require("babylonjs"));
  4. else if(typeof define === 'function' && define.amd)
  5. define("babylonjs-gui", ["babylonjs"], factory);
  6. else if(typeof exports === 'object')
  7. exports["babylonjs-gui"] = factory(require("babylonjs"));
  8. else
  9. root["BABYLON"] = root["BABYLON"] || {}, root["BABYLON"]["GUI"] = factory(root["BABYLON"]);
  10. })(window, function(__WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_observable__) {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  50. /******/ }
  51. /******/ };
  52. /******/
  53. /******/ // define __esModule on exports
  54. /******/ __webpack_require__.r = function(exports) {
  55. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  56. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  57. /******/ }
  58. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  59. /******/ };
  60. /******/
  61. /******/ // create a fake namespace object
  62. /******/ // mode & 1: value is a module id, require it
  63. /******/ // mode & 2: merge all properties of value into the ns
  64. /******/ // mode & 4: return value when already ns object
  65. /******/ // mode & 8|1: behave like require
  66. /******/ __webpack_require__.t = function(value, mode) {
  67. /******/ if(mode & 1) value = __webpack_require__(value);
  68. /******/ if(mode & 8) return value;
  69. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  70. /******/ var ns = Object.create(null);
  71. /******/ __webpack_require__.r(ns);
  72. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  73. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  74. /******/ return ns;
  75. /******/ };
  76. /******/
  77. /******/ // getDefaultExport function for compatibility with non-harmony modules
  78. /******/ __webpack_require__.n = function(module) {
  79. /******/ var getter = module && module.__esModule ?
  80. /******/ function getDefault() { return module['default']; } :
  81. /******/ function getModuleExports() { return module; };
  82. /******/ __webpack_require__.d(getter, 'a', getter);
  83. /******/ return getter;
  84. /******/ };
  85. /******/
  86. /******/ // Object.prototype.hasOwnProperty.call
  87. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  88. /******/
  89. /******/ // __webpack_public_path__
  90. /******/ __webpack_require__.p = "";
  91. /******/
  92. /******/
  93. /******/ // Load entry module and return exports
  94. /******/ return __webpack_require__(__webpack_require__.s = "./legacy/legacy.ts");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "../../node_modules/tslib/tslib.es6.js":
  99. /*!***********************************************************!*\
  100. !*** D:/Repos/Babylon.js/node_modules/tslib/tslib.es6.js ***!
  101. \***********************************************************/
  102. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __exportStar, __values, __read, __spread, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault */
  103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104. "use strict";
  105. __webpack_require__.r(__webpack_exports__);
  106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
  107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
  109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
  110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
  111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
  112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
  113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
  114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  125. /*! *****************************************************************************
  126. Copyright (c) Microsoft Corporation. All rights reserved.
  127. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  128. this file except in compliance with the License. You may obtain a copy of the
  129. License at http://www.apache.org/licenses/LICENSE-2.0
  130. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  131. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  132. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  133. MERCHANTABLITY OR NON-INFRINGEMENT.
  134. See the Apache Version 2.0 License for specific language governing permissions
  135. and limitations under the License.
  136. ***************************************************************************** */
  137. /* global Reflect, Promise */
  138. var extendStatics = function(d, b) {
  139. extendStatics = Object.setPrototypeOf ||
  140. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  141. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  142. return extendStatics(d, b);
  143. };
  144. function __extends(d, b) {
  145. extendStatics(d, b);
  146. function __() { this.constructor = d; }
  147. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  148. }
  149. var __assign = function() {
  150. __assign = Object.assign || function __assign(t) {
  151. for (var s, i = 1, n = arguments.length; i < n; i++) {
  152. s = arguments[i];
  153. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  154. }
  155. return t;
  156. }
  157. return __assign.apply(this, arguments);
  158. }
  159. function __rest(s, e) {
  160. var t = {};
  161. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  162. t[p] = s[p];
  163. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  164. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
  165. t[p[i]] = s[p[i]];
  166. return t;
  167. }
  168. function __decorate(decorators, target, key, desc) {
  169. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  170. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  171. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  172. return c > 3 && r && Object.defineProperty(target, key, r), r;
  173. }
  174. function __param(paramIndex, decorator) {
  175. return function (target, key) { decorator(target, key, paramIndex); }
  176. }
  177. function __metadata(metadataKey, metadataValue) {
  178. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  179. }
  180. function __awaiter(thisArg, _arguments, P, generator) {
  181. return new (P || (P = Promise))(function (resolve, reject) {
  182. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  183. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  184. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  185. step((generator = generator.apply(thisArg, _arguments || [])).next());
  186. });
  187. }
  188. function __generator(thisArg, body) {
  189. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  190. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  191. function verb(n) { return function (v) { return step([n, v]); }; }
  192. function step(op) {
  193. if (f) throw new TypeError("Generator is already executing.");
  194. while (_) try {
  195. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  196. if (y = 0, t) op = [op[0] & 2, t.value];
  197. switch (op[0]) {
  198. case 0: case 1: t = op; break;
  199. case 4: _.label++; return { value: op[1], done: false };
  200. case 5: _.label++; y = op[1]; op = [0]; continue;
  201. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  202. default:
  203. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  204. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  205. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  206. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  207. if (t[2]) _.ops.pop();
  208. _.trys.pop(); continue;
  209. }
  210. op = body.call(thisArg, _);
  211. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  212. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  213. }
  214. }
  215. function __exportStar(m, exports) {
  216. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  217. }
  218. function __values(o) {
  219. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  220. if (m) return m.call(o);
  221. return {
  222. next: function () {
  223. if (o && i >= o.length) o = void 0;
  224. return { value: o && o[i++], done: !o };
  225. }
  226. };
  227. }
  228. function __read(o, n) {
  229. var m = typeof Symbol === "function" && o[Symbol.iterator];
  230. if (!m) return o;
  231. var i = m.call(o), r, ar = [], e;
  232. try {
  233. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  234. }
  235. catch (error) { e = { error: error }; }
  236. finally {
  237. try {
  238. if (r && !r.done && (m = i["return"])) m.call(i);
  239. }
  240. finally { if (e) throw e.error; }
  241. }
  242. return ar;
  243. }
  244. function __spread() {
  245. for (var ar = [], i = 0; i < arguments.length; i++)
  246. ar = ar.concat(__read(arguments[i]));
  247. return ar;
  248. }
  249. function __await(v) {
  250. return this instanceof __await ? (this.v = v, this) : new __await(v);
  251. }
  252. function __asyncGenerator(thisArg, _arguments, generator) {
  253. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  254. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  255. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  256. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  257. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  258. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  259. function fulfill(value) { resume("next", value); }
  260. function reject(value) { resume("throw", value); }
  261. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  262. }
  263. function __asyncDelegator(o) {
  264. var i, p;
  265. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  266. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  267. }
  268. function __asyncValues(o) {
  269. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  270. var m = o[Symbol.asyncIterator], i;
  271. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  272. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  273. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  274. }
  275. function __makeTemplateObject(cooked, raw) {
  276. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  277. return cooked;
  278. };
  279. function __importStar(mod) {
  280. if (mod && mod.__esModule) return mod;
  281. var result = {};
  282. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  283. result.default = mod;
  284. return result;
  285. }
  286. function __importDefault(mod) {
  287. return (mod && mod.__esModule) ? mod : { default: mod };
  288. }
  289. /***/ }),
  290. /***/ "../../node_modules/webpack/buildin/global.js":
  291. /*!***********************************!*\
  292. !*** (webpack)/buildin/global.js ***!
  293. \***********************************/
  294. /*! no static exports found */
  295. /***/ (function(module, exports) {
  296. var g;
  297. // This works in non-strict mode
  298. g = (function() {
  299. return this;
  300. })();
  301. try {
  302. // This works if eval is allowed (see CSP)
  303. g = g || new Function("return this")();
  304. } catch (e) {
  305. // This works if the window reference is available
  306. if (typeof window === "object") g = window;
  307. }
  308. // g can still be undefined, but nothing to do about it...
  309. // We return undefined, instead of nothing here, so it's
  310. // easier to handle this case. if(!global) { ...}
  311. module.exports = g;
  312. /***/ }),
  313. /***/ "./2D/adtInstrumentation.ts":
  314. /*!**********************************!*\
  315. !*** ./2D/adtInstrumentation.ts ***!
  316. \**********************************/
  317. /*! exports provided: AdvancedDynamicTextureInstrumentation */
  318. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  319. "use strict";
  320. __webpack_require__.r(__webpack_exports__);
  321. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return AdvancedDynamicTextureInstrumentation; });
  322. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  323. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__);
  324. /**
  325. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  326. */
  327. var AdvancedDynamicTextureInstrumentation = /** @class */ (function () {
  328. /**
  329. * Instantiates a new advanced dynamic texture instrumentation.
  330. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  331. * @param texture Defines the AdvancedDynamicTexture to instrument
  332. */
  333. function AdvancedDynamicTextureInstrumentation(
  334. /**
  335. * Define the instrumented AdvancedDynamicTexture.
  336. */
  337. texture) {
  338. this.texture = texture;
  339. this._captureRenderTime = false;
  340. this._renderTime = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  341. this._captureLayoutTime = false;
  342. this._layoutTime = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  343. // Observers
  344. this._onBeginRenderObserver = null;
  345. this._onEndRenderObserver = null;
  346. this._onBeginLayoutObserver = null;
  347. this._onEndLayoutObserver = null;
  348. }
  349. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "renderTimeCounter", {
  350. // Properties
  351. /**
  352. * Gets the perf counter used to capture render time
  353. */
  354. get: function () {
  355. return this._renderTime;
  356. },
  357. enumerable: true,
  358. configurable: true
  359. });
  360. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "layoutTimeCounter", {
  361. /**
  362. * Gets the perf counter used to capture layout time
  363. */
  364. get: function () {
  365. return this._layoutTime;
  366. },
  367. enumerable: true,
  368. configurable: true
  369. });
  370. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureRenderTime", {
  371. /**
  372. * Enable or disable the render time capture
  373. */
  374. get: function () {
  375. return this._captureRenderTime;
  376. },
  377. set: function (value) {
  378. var _this = this;
  379. if (value === this._captureRenderTime) {
  380. return;
  381. }
  382. this._captureRenderTime = value;
  383. if (value) {
  384. this._onBeginRenderObserver = this.texture.onBeginRenderObservable.add(function () {
  385. _this._renderTime.beginMonitoring();
  386. });
  387. this._onEndRenderObserver = this.texture.onEndRenderObservable.add(function () {
  388. _this._renderTime.endMonitoring(true);
  389. });
  390. }
  391. else {
  392. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  393. this._onBeginRenderObserver = null;
  394. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  395. this._onEndRenderObserver = null;
  396. }
  397. },
  398. enumerable: true,
  399. configurable: true
  400. });
  401. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureLayoutTime", {
  402. /**
  403. * Enable or disable the layout time capture
  404. */
  405. get: function () {
  406. return this._captureLayoutTime;
  407. },
  408. set: function (value) {
  409. var _this = this;
  410. if (value === this._captureLayoutTime) {
  411. return;
  412. }
  413. this._captureLayoutTime = value;
  414. if (value) {
  415. this._onBeginLayoutObserver = this.texture.onBeginLayoutObservable.add(function () {
  416. _this._layoutTime.beginMonitoring();
  417. });
  418. this._onEndLayoutObserver = this.texture.onEndLayoutObservable.add(function () {
  419. _this._layoutTime.endMonitoring(true);
  420. });
  421. }
  422. else {
  423. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  424. this._onBeginLayoutObserver = null;
  425. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  426. this._onEndLayoutObserver = null;
  427. }
  428. },
  429. enumerable: true,
  430. configurable: true
  431. });
  432. /**
  433. * Dispose and release associated resources.
  434. */
  435. AdvancedDynamicTextureInstrumentation.prototype.dispose = function () {
  436. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  437. this._onBeginRenderObserver = null;
  438. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  439. this._onEndRenderObserver = null;
  440. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  441. this._onBeginLayoutObserver = null;
  442. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  443. this._onEndLayoutObserver = null;
  444. this.texture = null;
  445. };
  446. return AdvancedDynamicTextureInstrumentation;
  447. }());
  448. /***/ }),
  449. /***/ "./2D/advancedDynamicTexture.ts":
  450. /*!**************************************!*\
  451. !*** ./2D/advancedDynamicTexture.ts ***!
  452. \**************************************/
  453. /*! exports provided: AdvancedDynamicTexture */
  454. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  455. "use strict";
  456. __webpack_require__.r(__webpack_exports__);
  457. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return AdvancedDynamicTexture; });
  458. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  459. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  460. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  461. /* harmony import */ var _controls_container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./controls/container */ "./2D/controls/container.ts");
  462. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  463. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  464. /**
  465. * Class used to create texture to support 2D GUI elements
  466. * @see http://doc.babylonjs.com/how_to/gui
  467. */
  468. var AdvancedDynamicTexture = /** @class */ (function (_super) {
  469. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AdvancedDynamicTexture, _super);
  470. /**
  471. * Creates a new AdvancedDynamicTexture
  472. * @param name defines the name of the texture
  473. * @param width defines the width of the texture
  474. * @param height defines the height of the texture
  475. * @param scene defines the hosting scene
  476. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  477. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  478. */
  479. function AdvancedDynamicTexture(name, width, height, scene, generateMipMaps, samplingMode) {
  480. if (width === void 0) { width = 0; }
  481. if (height === void 0) { height = 0; }
  482. if (generateMipMaps === void 0) { generateMipMaps = false; }
  483. if (samplingMode === void 0) { samplingMode = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].NEAREST_SAMPLINGMODE; }
  484. var _this = _super.call(this, name, { width: width, height: height }, scene, generateMipMaps, samplingMode, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Engine"].TEXTUREFORMAT_RGBA) || this;
  485. _this._isDirty = false;
  486. /** @hidden */
  487. _this._rootContainer = new _controls_container__WEBPACK_IMPORTED_MODULE_2__["Container"]("root");
  488. /** @hidden */
  489. _this._lastControlOver = {};
  490. /** @hidden */
  491. _this._lastControlDown = {};
  492. /** @hidden */
  493. _this._capturingControl = {};
  494. /** @hidden */
  495. _this._linkedControls = new Array();
  496. _this._isFullscreen = false;
  497. _this._fullscreenViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 1, 1);
  498. _this._idealWidth = 0;
  499. _this._idealHeight = 0;
  500. _this._useSmallestIdeal = false;
  501. _this._renderAtIdealSize = false;
  502. _this._blockNextFocusCheck = false;
  503. _this._renderScale = 1;
  504. /**
  505. * Define type to string to ensure compatibility across browsers
  506. * Safari doesn't support DataTransfer constructor
  507. */
  508. _this._clipboardData = "";
  509. /**
  510. * Observable event triggered each time an clipboard event is received from the rendering canvas
  511. */
  512. _this.onClipboardObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  513. /**
  514. * Observable event triggered each time a pointer down is intercepted by a control
  515. */
  516. _this.onControlPickedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  517. /**
  518. * Observable event triggered before layout is evaluated
  519. */
  520. _this.onBeginLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  521. /**
  522. * Observable event triggered after the layout was evaluated
  523. */
  524. _this.onEndLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  525. /**
  526. * Observable event triggered before the texture is rendered
  527. */
  528. _this.onBeginRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  529. /**
  530. * Observable event triggered after the texture was rendered
  531. */
  532. _this.onEndRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  533. /**
  534. * Gets or sets a boolean defining if alpha is stored as premultiplied
  535. */
  536. _this.premulAlpha = false;
  537. _this._useInvalidateRectOptimization = true;
  538. // Invalidated rectangle which is the combination of all invalidated controls after they have been rotated into absolute position
  539. _this._invalidatedRectangle = null;
  540. _this._clearMeasure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, 0, 0);
  541. /** @hidden */
  542. _this.onClipboardCopy = function (rawEvt) {
  543. var evt = rawEvt;
  544. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY, evt);
  545. _this.onClipboardObservable.notifyObservers(ev);
  546. evt.preventDefault();
  547. };
  548. /** @hidden */
  549. _this.onClipboardCut = function (rawEvt) {
  550. var evt = rawEvt;
  551. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT, evt);
  552. _this.onClipboardObservable.notifyObservers(ev);
  553. evt.preventDefault();
  554. };
  555. /** @hidden */
  556. _this.onClipboardPaste = function (rawEvt) {
  557. var evt = rawEvt;
  558. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE, evt);
  559. _this.onClipboardObservable.notifyObservers(ev);
  560. evt.preventDefault();
  561. };
  562. scene = _this.getScene();
  563. if (!scene || !_this._texture) {
  564. return _this;
  565. }
  566. _this._rootCanvas = scene.getEngine().getRenderingCanvas();
  567. _this._renderObserver = scene.onBeforeCameraRenderObservable.add(function (camera) { return _this._checkUpdate(camera); });
  568. _this._preKeyboardObserver = scene.onPreKeyboardObservable.add(function (info) {
  569. if (!_this._focusedControl) {
  570. return;
  571. }
  572. if (info.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["KeyboardEventTypes"].KEYDOWN) {
  573. _this._focusedControl.processKeyboard(info.event);
  574. }
  575. info.skipOnPointerObservable = true;
  576. });
  577. _this._rootContainer._link(_this);
  578. _this.hasAlpha = true;
  579. if (!width || !height) {
  580. _this._resizeObserver = scene.getEngine().onResizeObservable.add(function () { return _this._onResize(); });
  581. _this._onResize();
  582. }
  583. _this._texture.isReady = true;
  584. return _this;
  585. }
  586. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderScale", {
  587. /**
  588. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  589. * Useful when you want more antialiasing
  590. */
  591. get: function () {
  592. return this._renderScale;
  593. },
  594. set: function (value) {
  595. if (value === this._renderScale) {
  596. return;
  597. }
  598. this._renderScale = value;
  599. this._onResize();
  600. },
  601. enumerable: true,
  602. configurable: true
  603. });
  604. Object.defineProperty(AdvancedDynamicTexture.prototype, "background", {
  605. /** Gets or sets the background color */
  606. get: function () {
  607. return this._background;
  608. },
  609. set: function (value) {
  610. if (this._background === value) {
  611. return;
  612. }
  613. this._background = value;
  614. this.markAsDirty();
  615. },
  616. enumerable: true,
  617. configurable: true
  618. });
  619. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealWidth", {
  620. /**
  621. * Gets or sets the ideal width used to design controls.
  622. * The GUI will then rescale everything accordingly
  623. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  624. */
  625. get: function () {
  626. return this._idealWidth;
  627. },
  628. set: function (value) {
  629. if (this._idealWidth === value) {
  630. return;
  631. }
  632. this._idealWidth = value;
  633. this.markAsDirty();
  634. this._rootContainer._markAllAsDirty();
  635. },
  636. enumerable: true,
  637. configurable: true
  638. });
  639. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealHeight", {
  640. /**
  641. * Gets or sets the ideal height used to design controls.
  642. * The GUI will then rescale everything accordingly
  643. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  644. */
  645. get: function () {
  646. return this._idealHeight;
  647. },
  648. set: function (value) {
  649. if (this._idealHeight === value) {
  650. return;
  651. }
  652. this._idealHeight = value;
  653. this.markAsDirty();
  654. this._rootContainer._markAllAsDirty();
  655. },
  656. enumerable: true,
  657. configurable: true
  658. });
  659. Object.defineProperty(AdvancedDynamicTexture.prototype, "useSmallestIdeal", {
  660. /**
  661. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  662. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  663. */
  664. get: function () {
  665. return this._useSmallestIdeal;
  666. },
  667. set: function (value) {
  668. if (this._useSmallestIdeal === value) {
  669. return;
  670. }
  671. this._useSmallestIdeal = value;
  672. this.markAsDirty();
  673. this._rootContainer._markAllAsDirty();
  674. },
  675. enumerable: true,
  676. configurable: true
  677. });
  678. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderAtIdealSize", {
  679. /**
  680. * Gets or sets a boolean indicating if adaptive scaling must be used
  681. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  682. */
  683. get: function () {
  684. return this._renderAtIdealSize;
  685. },
  686. set: function (value) {
  687. if (this._renderAtIdealSize === value) {
  688. return;
  689. }
  690. this._renderAtIdealSize = value;
  691. this._onResize();
  692. },
  693. enumerable: true,
  694. configurable: true
  695. });
  696. Object.defineProperty(AdvancedDynamicTexture.prototype, "layer", {
  697. /**
  698. * Gets the underlying layer used to render the texture when in fullscreen mode
  699. */
  700. get: function () {
  701. return this._layerToDispose;
  702. },
  703. enumerable: true,
  704. configurable: true
  705. });
  706. Object.defineProperty(AdvancedDynamicTexture.prototype, "rootContainer", {
  707. /**
  708. * Gets the root container control
  709. */
  710. get: function () {
  711. return this._rootContainer;
  712. },
  713. enumerable: true,
  714. configurable: true
  715. });
  716. /**
  717. * Returns an array containing the root container.
  718. * This is mostly used to let the Inspector introspects the ADT
  719. * @returns an array containing the rootContainer
  720. */
  721. AdvancedDynamicTexture.prototype.getChildren = function () {
  722. return [this._rootContainer];
  723. };
  724. /**
  725. * Will return all controls that are inside this texture
  726. * @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
  727. * @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
  728. * @return all child controls
  729. */
  730. AdvancedDynamicTexture.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  731. return this._rootContainer.getDescendants(directDescendantsOnly, predicate);
  732. };
  733. Object.defineProperty(AdvancedDynamicTexture.prototype, "focusedControl", {
  734. /**
  735. * Gets or sets the current focused control
  736. */
  737. get: function () {
  738. return this._focusedControl;
  739. },
  740. set: function (control) {
  741. if (this._focusedControl == control) {
  742. return;
  743. }
  744. if (this._focusedControl) {
  745. this._focusedControl.onBlur();
  746. }
  747. if (control) {
  748. control.onFocus();
  749. }
  750. this._focusedControl = control;
  751. },
  752. enumerable: true,
  753. configurable: true
  754. });
  755. Object.defineProperty(AdvancedDynamicTexture.prototype, "isForeground", {
  756. /**
  757. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  758. */
  759. get: function () {
  760. if (!this.layer) {
  761. return true;
  762. }
  763. return (!this.layer.isBackground);
  764. },
  765. set: function (value) {
  766. if (!this.layer) {
  767. return;
  768. }
  769. if (this.layer.isBackground === !value) {
  770. return;
  771. }
  772. this.layer.isBackground = !value;
  773. },
  774. enumerable: true,
  775. configurable: true
  776. });
  777. Object.defineProperty(AdvancedDynamicTexture.prototype, "clipboardData", {
  778. /**
  779. * Gets or set information about clipboardData
  780. */
  781. get: function () {
  782. return this._clipboardData;
  783. },
  784. set: function (value) {
  785. this._clipboardData = value;
  786. },
  787. enumerable: true,
  788. configurable: true
  789. });
  790. /**
  791. * Get the current class name of the texture useful for serialization or dynamic coding.
  792. * @returns "AdvancedDynamicTexture"
  793. */
  794. AdvancedDynamicTexture.prototype.getClassName = function () {
  795. return "AdvancedDynamicTexture";
  796. };
  797. /**
  798. * Function used to execute a function on all controls
  799. * @param func defines the function to execute
  800. * @param container defines the container where controls belong. If null the root container will be used
  801. */
  802. AdvancedDynamicTexture.prototype.executeOnAllControls = function (func, container) {
  803. if (!container) {
  804. container = this._rootContainer;
  805. }
  806. func(container);
  807. for (var _i = 0, _a = container.children; _i < _a.length; _i++) {
  808. var child = _a[_i];
  809. if (child.children) {
  810. this.executeOnAllControls(func, child);
  811. continue;
  812. }
  813. func(child);
  814. }
  815. };
  816. Object.defineProperty(AdvancedDynamicTexture.prototype, "useInvalidateRectOptimization", {
  817. /**
  818. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  819. */
  820. get: function () {
  821. return this._useInvalidateRectOptimization;
  822. },
  823. set: function (value) {
  824. this._useInvalidateRectOptimization = value;
  825. },
  826. enumerable: true,
  827. configurable: true
  828. });
  829. /**
  830. * Invalidates a rectangle area on the gui texture
  831. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  832. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  833. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  834. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  835. */
  836. AdvancedDynamicTexture.prototype.invalidateRect = function (invalidMinX, invalidMinY, invalidMaxX, invalidMaxY) {
  837. if (!this._useInvalidateRectOptimization) {
  838. return;
  839. }
  840. if (!this._invalidatedRectangle) {
  841. this._invalidatedRectangle = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](invalidMinX, invalidMinY, invalidMaxX - invalidMinX + 1, invalidMaxY - invalidMinY + 1);
  842. }
  843. else {
  844. // Compute intersection
  845. var maxX = Math.ceil(Math.max(this._invalidatedRectangle.left + this._invalidatedRectangle.width - 1, invalidMaxX));
  846. var maxY = Math.ceil(Math.max(this._invalidatedRectangle.top + this._invalidatedRectangle.height - 1, invalidMaxY));
  847. this._invalidatedRectangle.left = Math.floor(Math.min(this._invalidatedRectangle.left, invalidMinX));
  848. this._invalidatedRectangle.top = Math.floor(Math.min(this._invalidatedRectangle.top, invalidMinY));
  849. this._invalidatedRectangle.width = maxX - this._invalidatedRectangle.left + 1;
  850. this._invalidatedRectangle.height = maxY - this._invalidatedRectangle.top + 1;
  851. }
  852. };
  853. /**
  854. * Marks the texture as dirty forcing a complete update
  855. */
  856. AdvancedDynamicTexture.prototype.markAsDirty = function () {
  857. this._isDirty = true;
  858. };
  859. /**
  860. * Helper function used to create a new style
  861. * @returns a new style
  862. * @see http://doc.babylonjs.com/how_to/gui#styles
  863. */
  864. AdvancedDynamicTexture.prototype.createStyle = function () {
  865. return new _style__WEBPACK_IMPORTED_MODULE_3__["Style"](this);
  866. };
  867. /**
  868. * Adds a new control to the root container
  869. * @param control defines the control to add
  870. * @returns the current texture
  871. */
  872. AdvancedDynamicTexture.prototype.addControl = function (control) {
  873. this._rootContainer.addControl(control);
  874. return this;
  875. };
  876. /**
  877. * Removes a control from the root container
  878. * @param control defines the control to remove
  879. * @returns the current texture
  880. */
  881. AdvancedDynamicTexture.prototype.removeControl = function (control) {
  882. this._rootContainer.removeControl(control);
  883. return this;
  884. };
  885. /**
  886. * Release all resources
  887. */
  888. AdvancedDynamicTexture.prototype.dispose = function () {
  889. var scene = this.getScene();
  890. if (!scene) {
  891. return;
  892. }
  893. this._rootCanvas = null;
  894. scene.onBeforeCameraRenderObservable.remove(this._renderObserver);
  895. if (this._resizeObserver) {
  896. scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  897. }
  898. if (this._pointerMoveObserver) {
  899. scene.onPrePointerObservable.remove(this._pointerMoveObserver);
  900. }
  901. if (this._pointerObserver) {
  902. scene.onPointerObservable.remove(this._pointerObserver);
  903. }
  904. if (this._preKeyboardObserver) {
  905. scene.onPreKeyboardObservable.remove(this._preKeyboardObserver);
  906. }
  907. if (this._canvasPointerOutObserver) {
  908. scene.getEngine().onCanvasPointerOutObservable.remove(this._canvasPointerOutObserver);
  909. }
  910. if (this._layerToDispose) {
  911. this._layerToDispose.texture = null;
  912. this._layerToDispose.dispose();
  913. this._layerToDispose = null;
  914. }
  915. this._rootContainer.dispose();
  916. this.onClipboardObservable.clear();
  917. this.onControlPickedObservable.clear();
  918. this.onBeginRenderObservable.clear();
  919. this.onEndRenderObservable.clear();
  920. this.onBeginLayoutObservable.clear();
  921. this.onEndLayoutObservable.clear();
  922. _super.prototype.dispose.call(this);
  923. };
  924. AdvancedDynamicTexture.prototype._onResize = function () {
  925. var scene = this.getScene();
  926. if (!scene) {
  927. return;
  928. }
  929. // Check size
  930. var engine = scene.getEngine();
  931. var textureSize = this.getSize();
  932. var renderWidth = engine.getRenderWidth() * this._renderScale;
  933. var renderHeight = engine.getRenderHeight() * this._renderScale;
  934. if (this._renderAtIdealSize) {
  935. if (this._idealWidth) {
  936. renderHeight = (renderHeight * this._idealWidth) / renderWidth;
  937. renderWidth = this._idealWidth;
  938. }
  939. else if (this._idealHeight) {
  940. renderWidth = (renderWidth * this._idealHeight) / renderHeight;
  941. renderHeight = this._idealHeight;
  942. }
  943. }
  944. if (textureSize.width !== renderWidth || textureSize.height !== renderHeight) {
  945. this.scaleTo(renderWidth, renderHeight);
  946. this.markAsDirty();
  947. if (this._idealWidth || this._idealHeight) {
  948. this._rootContainer._markAllAsDirty();
  949. }
  950. }
  951. this.invalidateRect(0, 0, textureSize.width - 1, textureSize.height - 1);
  952. };
  953. /** @hidden */
  954. AdvancedDynamicTexture.prototype._getGlobalViewport = function (scene) {
  955. var engine = scene.getEngine();
  956. return this._fullscreenViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  957. };
  958. /**
  959. * Get screen coordinates for a vector3
  960. * @param position defines the position to project
  961. * @param worldMatrix defines the world matrix to use
  962. * @returns the projected position
  963. */
  964. AdvancedDynamicTexture.prototype.getProjectedPosition = function (position, worldMatrix) {
  965. var scene = this.getScene();
  966. if (!scene) {
  967. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  968. }
  969. var globalViewport = this._getGlobalViewport(scene);
  970. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, worldMatrix, scene.getTransformMatrix(), globalViewport);
  971. projectedPosition.scaleInPlace(this.renderScale);
  972. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"](projectedPosition.x, projectedPosition.y);
  973. };
  974. AdvancedDynamicTexture.prototype._checkUpdate = function (camera) {
  975. if (this._layerToDispose) {
  976. if ((camera.layerMask & this._layerToDispose.layerMask) === 0) {
  977. return;
  978. }
  979. }
  980. if (this._isFullscreen && this._linkedControls.length) {
  981. var scene = this.getScene();
  982. if (!scene) {
  983. return;
  984. }
  985. var globalViewport = this._getGlobalViewport(scene);
  986. for (var _i = 0, _a = this._linkedControls; _i < _a.length; _i++) {
  987. var control = _a[_i];
  988. if (!control.isVisible) {
  989. continue;
  990. }
  991. var mesh = control._linkedMesh;
  992. if (!mesh || mesh.isDisposed()) {
  993. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  994. control.linkWithMesh(null);
  995. });
  996. continue;
  997. }
  998. var position = mesh.getBoundingInfo().boundingSphere.center;
  999. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, mesh.getWorldMatrix(), scene.getTransformMatrix(), globalViewport);
  1000. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  1001. control.notRenderable = true;
  1002. continue;
  1003. }
  1004. control.notRenderable = false;
  1005. // Account for RenderScale.
  1006. projectedPosition.scaleInPlace(this.renderScale);
  1007. control._moveToProjectedPosition(projectedPosition);
  1008. }
  1009. }
  1010. if (!this._isDirty && !this._rootContainer.isDirty) {
  1011. return;
  1012. }
  1013. this._isDirty = false;
  1014. this._render();
  1015. this.update(true, this.premulAlpha);
  1016. };
  1017. AdvancedDynamicTexture.prototype._render = function () {
  1018. var textureSize = this.getSize();
  1019. var renderWidth = textureSize.width;
  1020. var renderHeight = textureSize.height;
  1021. var context = this.getContext();
  1022. context.font = "18px Arial";
  1023. context.strokeStyle = "white";
  1024. // Layout
  1025. this.onBeginLayoutObservable.notifyObservers(this);
  1026. var measure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, renderWidth, renderHeight);
  1027. this._rootContainer._layout(measure, context);
  1028. this.onEndLayoutObservable.notifyObservers(this);
  1029. this._isDirty = false; // Restoring the dirty state that could have been set by controls during layout processing
  1030. // Clear
  1031. if (this._invalidatedRectangle) {
  1032. this._clearMeasure.copyFrom(this._invalidatedRectangle);
  1033. }
  1034. else {
  1035. this._clearMeasure.copyFromFloats(0, 0, renderWidth, renderHeight);
  1036. }
  1037. context.clearRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1038. if (this._background) {
  1039. context.save();
  1040. context.fillStyle = this._background;
  1041. context.fillRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1042. context.restore();
  1043. }
  1044. // Render
  1045. this.onBeginRenderObservable.notifyObservers(this);
  1046. this._rootContainer._render(context, this._invalidatedRectangle);
  1047. this.onEndRenderObservable.notifyObservers(this);
  1048. this._invalidatedRectangle = null;
  1049. };
  1050. /** @hidden */
  1051. AdvancedDynamicTexture.prototype._changeCursor = function (cursor) {
  1052. if (this._rootCanvas) {
  1053. this._rootCanvas.style.cursor = cursor;
  1054. }
  1055. };
  1056. /** @hidden */
  1057. AdvancedDynamicTexture.prototype._registerLastControlDown = function (control, pointerId) {
  1058. this._lastControlDown[pointerId] = control;
  1059. this.onControlPickedObservable.notifyObservers(control);
  1060. };
  1061. AdvancedDynamicTexture.prototype._doPicking = function (x, y, type, pointerId, buttonIndex) {
  1062. var scene = this.getScene();
  1063. if (!scene) {
  1064. return;
  1065. }
  1066. var engine = scene.getEngine();
  1067. var textureSize = this.getSize();
  1068. if (this._isFullscreen) {
  1069. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1070. var viewport = camera.viewport;
  1071. x = x * (textureSize.width / (engine.getRenderWidth() * viewport.width));
  1072. y = y * (textureSize.height / (engine.getRenderHeight() * viewport.height));
  1073. }
  1074. if (this._capturingControl[pointerId]) {
  1075. this._capturingControl[pointerId]._processObservables(type, x, y, pointerId, buttonIndex);
  1076. return;
  1077. }
  1078. if (!this._rootContainer._processPicking(x, y, type, pointerId, buttonIndex)) {
  1079. this._changeCursor("");
  1080. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1081. if (this._lastControlOver[pointerId]) {
  1082. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  1083. delete this._lastControlOver[pointerId];
  1084. }
  1085. }
  1086. }
  1087. this._manageFocus();
  1088. };
  1089. /** @hidden */
  1090. AdvancedDynamicTexture.prototype._cleanControlAfterRemovalFromList = function (list, control) {
  1091. for (var pointerId in list) {
  1092. if (!list.hasOwnProperty(pointerId)) {
  1093. continue;
  1094. }
  1095. var lastControlOver = list[pointerId];
  1096. if (lastControlOver === control) {
  1097. delete list[pointerId];
  1098. }
  1099. }
  1100. };
  1101. /** @hidden */
  1102. AdvancedDynamicTexture.prototype._cleanControlAfterRemoval = function (control) {
  1103. this._cleanControlAfterRemovalFromList(this._lastControlDown, control);
  1104. this._cleanControlAfterRemovalFromList(this._lastControlOver, control);
  1105. };
  1106. /** Attach to all scene events required to support pointer events */
  1107. AdvancedDynamicTexture.prototype.attach = function () {
  1108. var _this = this;
  1109. var scene = this.getScene();
  1110. if (!scene) {
  1111. return;
  1112. }
  1113. var tempViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0, 0);
  1114. this._pointerMoveObserver = scene.onPrePointerObservable.add(function (pi, state) {
  1115. if (scene.isPointerCaptured((pi.event).pointerId)) {
  1116. return;
  1117. }
  1118. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1119. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1120. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1121. return;
  1122. }
  1123. if (!scene) {
  1124. return;
  1125. }
  1126. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1127. var engine = scene.getEngine();
  1128. if (!camera) {
  1129. tempViewport.x = 0;
  1130. tempViewport.y = 0;
  1131. tempViewport.width = engine.getRenderWidth();
  1132. tempViewport.height = engine.getRenderHeight();
  1133. }
  1134. else {
  1135. camera.viewport.toGlobalToRef(engine.getRenderWidth(), engine.getRenderHeight(), tempViewport);
  1136. }
  1137. var x = scene.pointerX / engine.getHardwareScalingLevel() - tempViewport.x;
  1138. var y = scene.pointerY / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - tempViewport.y - tempViewport.height);
  1139. _this._shouldBlockPointer = false;
  1140. // Do picking modifies _shouldBlockPointer
  1141. _this._doPicking(x, y, pi.type, pi.event.pointerId || 0, pi.event.button);
  1142. // Avoid overwriting a true skipOnPointerObservable to false
  1143. if (_this._shouldBlockPointer) {
  1144. pi.skipOnPointerObservable = _this._shouldBlockPointer;
  1145. }
  1146. });
  1147. this._attachToOnPointerOut(scene);
  1148. };
  1149. /**
  1150. * Register the clipboard Events onto the canvas
  1151. */
  1152. AdvancedDynamicTexture.prototype.registerClipboardEvents = function () {
  1153. self.addEventListener("copy", this.onClipboardCopy, false);
  1154. self.addEventListener("cut", this.onClipboardCut, false);
  1155. self.addEventListener("paste", this.onClipboardPaste, false);
  1156. };
  1157. /**
  1158. * Unregister the clipboard Events from the canvas
  1159. */
  1160. AdvancedDynamicTexture.prototype.unRegisterClipboardEvents = function () {
  1161. self.removeEventListener("copy", this.onClipboardCopy);
  1162. self.removeEventListener("cut", this.onClipboardCut);
  1163. self.removeEventListener("paste", this.onClipboardPaste);
  1164. };
  1165. /**
  1166. * Connect the texture to a hosting mesh to enable interactions
  1167. * @param mesh defines the mesh to attach to
  1168. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  1169. */
  1170. AdvancedDynamicTexture.prototype.attachToMesh = function (mesh, supportPointerMove) {
  1171. var _this = this;
  1172. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1173. var scene = this.getScene();
  1174. if (!scene) {
  1175. return;
  1176. }
  1177. this._pointerObserver = scene.onPointerObservable.add(function (pi, state) {
  1178. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1179. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1180. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1181. return;
  1182. }
  1183. var pointerId = pi.event.pointerId || 0;
  1184. if (pi.pickInfo && pi.pickInfo.hit && pi.pickInfo.pickedMesh === mesh) {
  1185. var uv = pi.pickInfo.getTextureCoordinates();
  1186. if (uv) {
  1187. var size = _this.getSize();
  1188. _this._doPicking(uv.x * size.width, (1.0 - uv.y) * size.height, pi.type, pointerId, pi.event.button);
  1189. }
  1190. }
  1191. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  1192. if (_this._lastControlDown[pointerId]) {
  1193. _this._lastControlDown[pointerId]._forcePointerUp(pointerId);
  1194. }
  1195. delete _this._lastControlDown[pointerId];
  1196. if (_this.focusedControl) {
  1197. var friendlyControls = _this.focusedControl.keepsFocusWith();
  1198. var canMoveFocus = true;
  1199. if (friendlyControls) {
  1200. for (var _i = 0, friendlyControls_1 = friendlyControls; _i < friendlyControls_1.length; _i++) {
  1201. var control = friendlyControls_1[_i];
  1202. // Same host, no need to keep the focus
  1203. if (_this === control._host) {
  1204. continue;
  1205. }
  1206. // Different hosts
  1207. var otherHost = control._host;
  1208. if (otherHost._lastControlOver[pointerId] && otherHost._lastControlOver[pointerId].isAscendant(control)) {
  1209. canMoveFocus = false;
  1210. break;
  1211. }
  1212. }
  1213. }
  1214. if (canMoveFocus) {
  1215. _this.focusedControl = null;
  1216. }
  1217. }
  1218. }
  1219. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1220. if (_this._lastControlOver[pointerId]) {
  1221. _this._lastControlOver[pointerId]._onPointerOut(_this._lastControlOver[pointerId]);
  1222. }
  1223. delete _this._lastControlOver[pointerId];
  1224. }
  1225. });
  1226. mesh.enablePointerMoveEvents = supportPointerMove;
  1227. this._attachToOnPointerOut(scene);
  1228. };
  1229. /**
  1230. * Move the focus to a specific control
  1231. * @param control defines the control which will receive the focus
  1232. */
  1233. AdvancedDynamicTexture.prototype.moveFocusToControl = function (control) {
  1234. this.focusedControl = control;
  1235. this._lastPickedControl = control;
  1236. this._blockNextFocusCheck = true;
  1237. };
  1238. AdvancedDynamicTexture.prototype._manageFocus = function () {
  1239. if (this._blockNextFocusCheck) {
  1240. this._blockNextFocusCheck = false;
  1241. this._lastPickedControl = this._focusedControl;
  1242. return;
  1243. }
  1244. // Focus management
  1245. if (this._focusedControl) {
  1246. if (this._focusedControl !== this._lastPickedControl) {
  1247. if (this._lastPickedControl.isFocusInvisible) {
  1248. return;
  1249. }
  1250. this.focusedControl = null;
  1251. }
  1252. }
  1253. };
  1254. AdvancedDynamicTexture.prototype._attachToOnPointerOut = function (scene) {
  1255. var _this = this;
  1256. this._canvasPointerOutObserver = scene.getEngine().onCanvasPointerOutObservable.add(function (pointerEvent) {
  1257. if (_this._lastControlOver[pointerEvent.pointerId]) {
  1258. _this._lastControlOver[pointerEvent.pointerId]._onPointerOut(_this._lastControlOver[pointerEvent.pointerId]);
  1259. }
  1260. delete _this._lastControlOver[pointerEvent.pointerId];
  1261. if (_this._lastControlDown[pointerEvent.pointerId] && _this._lastControlDown[pointerEvent.pointerId] !== _this._capturingControl[pointerEvent.pointerId]) {
  1262. _this._lastControlDown[pointerEvent.pointerId]._forcePointerUp();
  1263. delete _this._lastControlDown[pointerEvent.pointerId];
  1264. }
  1265. });
  1266. };
  1267. // Statics
  1268. /**
  1269. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  1270. * @param mesh defines the mesh which will receive the texture
  1271. * @param width defines the texture width (1024 by default)
  1272. * @param height defines the texture height (1024 by default)
  1273. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  1274. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  1275. * @returns a new AdvancedDynamicTexture
  1276. */
  1277. AdvancedDynamicTexture.CreateForMesh = function (mesh, width, height, supportPointerMove, onlyAlphaTesting) {
  1278. if (width === void 0) { width = 1024; }
  1279. if (height === void 0) { height = 1024; }
  1280. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1281. if (onlyAlphaTesting === void 0) { onlyAlphaTesting = false; }
  1282. var result = new AdvancedDynamicTexture(mesh.name + " AdvancedDynamicTexture", width, height, mesh.getScene(), true, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE);
  1283. var material = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("AdvancedDynamicTextureMaterial", mesh.getScene());
  1284. material.backFaceCulling = false;
  1285. material.diffuseColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1286. material.specularColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1287. if (onlyAlphaTesting) {
  1288. material.diffuseTexture = result;
  1289. material.emissiveTexture = result;
  1290. result.hasAlpha = true;
  1291. }
  1292. else {
  1293. material.emissiveTexture = result;
  1294. material.opacityTexture = result;
  1295. }
  1296. mesh.material = material;
  1297. result.attachToMesh(mesh, supportPointerMove);
  1298. return result;
  1299. };
  1300. /**
  1301. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  1302. * In this mode the texture will rely on a layer for its rendering.
  1303. * This allows it to be treated like any other layer.
  1304. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  1305. * LayerMask is set through advancedTexture.layer.layerMask
  1306. * @param name defines name for the texture
  1307. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  1308. * @param scene defines the hsoting scene
  1309. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  1310. * @returns a new AdvancedDynamicTexture
  1311. */
  1312. AdvancedDynamicTexture.CreateFullscreenUI = function (name, foreground, scene, sampling) {
  1313. if (foreground === void 0) { foreground = true; }
  1314. if (scene === void 0) { scene = null; }
  1315. if (sampling === void 0) { sampling = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  1316. var result = new AdvancedDynamicTexture(name, 0, 0, scene, false, sampling);
  1317. // Display
  1318. var layer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Layer"](name + "_layer", null, scene, !foreground);
  1319. layer.texture = result;
  1320. result._layerToDispose = layer;
  1321. result._isFullscreen = true;
  1322. // Attach
  1323. result.attach();
  1324. return result;
  1325. };
  1326. return AdvancedDynamicTexture;
  1327. }(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["DynamicTexture"]));
  1328. /***/ }),
  1329. /***/ "./2D/controls/button.ts":
  1330. /*!*******************************!*\
  1331. !*** ./2D/controls/button.ts ***!
  1332. \*******************************/
  1333. /*! exports provided: Button */
  1334. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1335. "use strict";
  1336. __webpack_require__.r(__webpack_exports__);
  1337. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return Button; });
  1338. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1339. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1340. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1341. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1342. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  1343. /**
  1344. * Class used to create 2D buttons
  1345. */
  1346. var Button = /** @class */ (function (_super) {
  1347. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Button, _super);
  1348. /**
  1349. * Creates a new Button
  1350. * @param name defines the name of the button
  1351. */
  1352. function Button(name) {
  1353. var _this = _super.call(this, name) || this;
  1354. _this.name = name;
  1355. _this.thickness = 1;
  1356. _this.isPointerBlocker = true;
  1357. var alphaStore = null;
  1358. _this.pointerEnterAnimation = function () {
  1359. alphaStore = _this.alpha;
  1360. _this.alpha -= 0.1;
  1361. };
  1362. _this.pointerOutAnimation = function () {
  1363. if (alphaStore !== null) {
  1364. _this.alpha = alphaStore;
  1365. }
  1366. };
  1367. _this.pointerDownAnimation = function () {
  1368. _this.scaleX -= 0.05;
  1369. _this.scaleY -= 0.05;
  1370. };
  1371. _this.pointerUpAnimation = function () {
  1372. _this.scaleX += 0.05;
  1373. _this.scaleY += 0.05;
  1374. };
  1375. return _this;
  1376. }
  1377. Object.defineProperty(Button.prototype, "image", {
  1378. /**
  1379. * Returns the image part of the button (if any)
  1380. */
  1381. get: function () {
  1382. return this._image;
  1383. },
  1384. enumerable: true,
  1385. configurable: true
  1386. });
  1387. Object.defineProperty(Button.prototype, "textBlock", {
  1388. /**
  1389. * Returns the image part of the button (if any)
  1390. */
  1391. get: function () {
  1392. return this._textBlock;
  1393. },
  1394. enumerable: true,
  1395. configurable: true
  1396. });
  1397. Button.prototype._getTypeName = function () {
  1398. return "Button";
  1399. };
  1400. // While being a container, the button behaves like a control.
  1401. /** @hidden */
  1402. Button.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  1403. if (!this.isHitTestVisible || !this.isVisible || this.notRenderable) {
  1404. return false;
  1405. }
  1406. if (!_super.prototype.contains.call(this, x, y)) {
  1407. return false;
  1408. }
  1409. this._processObservables(type, x, y, pointerId, buttonIndex);
  1410. return true;
  1411. };
  1412. /** @hidden */
  1413. Button.prototype._onPointerEnter = function (target) {
  1414. if (!_super.prototype._onPointerEnter.call(this, target)) {
  1415. return false;
  1416. }
  1417. if (this.pointerEnterAnimation) {
  1418. this.pointerEnterAnimation();
  1419. }
  1420. return true;
  1421. };
  1422. /** @hidden */
  1423. Button.prototype._onPointerOut = function (target) {
  1424. if (this.pointerOutAnimation) {
  1425. this.pointerOutAnimation();
  1426. }
  1427. _super.prototype._onPointerOut.call(this, target);
  1428. };
  1429. /** @hidden */
  1430. Button.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1431. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1432. return false;
  1433. }
  1434. if (this.pointerDownAnimation) {
  1435. this.pointerDownAnimation();
  1436. }
  1437. return true;
  1438. };
  1439. /** @hidden */
  1440. Button.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  1441. if (this.pointerUpAnimation) {
  1442. this.pointerUpAnimation();
  1443. }
  1444. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  1445. };
  1446. // Statics
  1447. /**
  1448. * Creates a new button made with an image and a text
  1449. * @param name defines the name of the button
  1450. * @param text defines the text of the button
  1451. * @param imageUrl defines the url of the image
  1452. * @returns a new Button
  1453. */
  1454. Button.CreateImageButton = function (name, text, imageUrl) {
  1455. var result = new Button(name);
  1456. // Adding text
  1457. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1458. textBlock.textWrapping = true;
  1459. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1460. textBlock.paddingLeft = "20%";
  1461. result.addControl(textBlock);
  1462. // Adding image
  1463. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1464. iconImage.width = "20%";
  1465. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_UNIFORM;
  1466. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1467. result.addControl(iconImage);
  1468. // Store
  1469. result._image = iconImage;
  1470. result._textBlock = textBlock;
  1471. return result;
  1472. };
  1473. /**
  1474. * Creates a new button made with an image
  1475. * @param name defines the name of the button
  1476. * @param imageUrl defines the url of the image
  1477. * @returns a new Button
  1478. */
  1479. Button.CreateImageOnlyButton = function (name, imageUrl) {
  1480. var result = new Button(name);
  1481. // Adding image
  1482. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1483. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1484. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1485. result.addControl(iconImage);
  1486. // Store
  1487. result._image = iconImage;
  1488. return result;
  1489. };
  1490. /**
  1491. * Creates a new button made with a text
  1492. * @param name defines the name of the button
  1493. * @param text defines the text of the button
  1494. * @returns a new Button
  1495. */
  1496. Button.CreateSimpleButton = function (name, text) {
  1497. var result = new Button(name);
  1498. // Adding text
  1499. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1500. textBlock.textWrapping = true;
  1501. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1502. result.addControl(textBlock);
  1503. // Store
  1504. result._textBlock = textBlock;
  1505. return result;
  1506. };
  1507. /**
  1508. * Creates a new button made with an image and a centered text
  1509. * @param name defines the name of the button
  1510. * @param text defines the text of the button
  1511. * @param imageUrl defines the url of the image
  1512. * @returns a new Button
  1513. */
  1514. Button.CreateImageWithCenterTextButton = function (name, text, imageUrl) {
  1515. var result = new Button(name);
  1516. // Adding image
  1517. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1518. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1519. result.addControl(iconImage);
  1520. // Adding text
  1521. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1522. textBlock.textWrapping = true;
  1523. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1524. result.addControl(textBlock);
  1525. // Store
  1526. result._image = iconImage;
  1527. result._textBlock = textBlock;
  1528. return result;
  1529. };
  1530. return Button;
  1531. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  1532. /***/ }),
  1533. /***/ "./2D/controls/checkbox.ts":
  1534. /*!*********************************!*\
  1535. !*** ./2D/controls/checkbox.ts ***!
  1536. \*********************************/
  1537. /*! exports provided: Checkbox */
  1538. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1539. "use strict";
  1540. __webpack_require__.r(__webpack_exports__);
  1541. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return Checkbox; });
  1542. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1543. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  1544. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1545. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1546. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  1547. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1548. /**
  1549. * Class used to represent a 2D checkbox
  1550. */
  1551. var Checkbox = /** @class */ (function (_super) {
  1552. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Checkbox, _super);
  1553. /**
  1554. * Creates a new CheckBox
  1555. * @param name defines the control name
  1556. */
  1557. function Checkbox(name) {
  1558. var _this = _super.call(this, name) || this;
  1559. _this.name = name;
  1560. _this._isChecked = false;
  1561. _this._background = "black";
  1562. _this._checkSizeRatio = 0.8;
  1563. _this._thickness = 1;
  1564. /**
  1565. * Observable raised when isChecked property changes
  1566. */
  1567. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1568. _this.isPointerBlocker = true;
  1569. return _this;
  1570. }
  1571. Object.defineProperty(Checkbox.prototype, "thickness", {
  1572. /** Gets or sets border thickness */
  1573. get: function () {
  1574. return this._thickness;
  1575. },
  1576. set: function (value) {
  1577. if (this._thickness === value) {
  1578. return;
  1579. }
  1580. this._thickness = value;
  1581. this._markAsDirty();
  1582. },
  1583. enumerable: true,
  1584. configurable: true
  1585. });
  1586. Object.defineProperty(Checkbox.prototype, "checkSizeRatio", {
  1587. /** Gets or sets a value indicating the ratio between overall size and check size */
  1588. get: function () {
  1589. return this._checkSizeRatio;
  1590. },
  1591. set: function (value) {
  1592. value = Math.max(Math.min(1, value), 0);
  1593. if (this._checkSizeRatio === value) {
  1594. return;
  1595. }
  1596. this._checkSizeRatio = value;
  1597. this._markAsDirty();
  1598. },
  1599. enumerable: true,
  1600. configurable: true
  1601. });
  1602. Object.defineProperty(Checkbox.prototype, "background", {
  1603. /** Gets or sets background color */
  1604. get: function () {
  1605. return this._background;
  1606. },
  1607. set: function (value) {
  1608. if (this._background === value) {
  1609. return;
  1610. }
  1611. this._background = value;
  1612. this._markAsDirty();
  1613. },
  1614. enumerable: true,
  1615. configurable: true
  1616. });
  1617. Object.defineProperty(Checkbox.prototype, "isChecked", {
  1618. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1619. get: function () {
  1620. return this._isChecked;
  1621. },
  1622. set: function (value) {
  1623. if (this._isChecked === value) {
  1624. return;
  1625. }
  1626. this._isChecked = value;
  1627. this._markAsDirty();
  1628. this.onIsCheckedChangedObservable.notifyObservers(value);
  1629. },
  1630. enumerable: true,
  1631. configurable: true
  1632. });
  1633. Checkbox.prototype._getTypeName = function () {
  1634. return "Checkbox";
  1635. };
  1636. /** @hidden */
  1637. Checkbox.prototype._draw = function (context) {
  1638. context.save();
  1639. this._applyStates(context);
  1640. var actualWidth = this._currentMeasure.width - this._thickness;
  1641. var actualHeight = this._currentMeasure.height - this._thickness;
  1642. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1643. context.shadowColor = this.shadowColor;
  1644. context.shadowBlur = this.shadowBlur;
  1645. context.shadowOffsetX = this.shadowOffsetX;
  1646. context.shadowOffsetY = this.shadowOffsetY;
  1647. }
  1648. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  1649. context.fillRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1650. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1651. context.shadowBlur = 0;
  1652. context.shadowOffsetX = 0;
  1653. context.shadowOffsetY = 0;
  1654. }
  1655. if (this._isChecked) {
  1656. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  1657. var offsetWidth = actualWidth * this._checkSizeRatio;
  1658. var offseHeight = actualHeight * this._checkSizeRatio;
  1659. context.fillRect(this._currentMeasure.left + this._thickness / 2 + (actualWidth - offsetWidth) / 2, this._currentMeasure.top + this._thickness / 2 + (actualHeight - offseHeight) / 2, offsetWidth, offseHeight);
  1660. }
  1661. context.strokeStyle = this.color;
  1662. context.lineWidth = this._thickness;
  1663. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1664. context.restore();
  1665. };
  1666. // Events
  1667. /** @hidden */
  1668. Checkbox.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1669. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1670. return false;
  1671. }
  1672. this.isChecked = !this.isChecked;
  1673. return true;
  1674. };
  1675. /**
  1676. * Utility function to easily create a checkbox with a header
  1677. * @param title defines the label to use for the header
  1678. * @param onValueChanged defines the callback to call when value changes
  1679. * @returns a StackPanel containing the checkbox and a textBlock
  1680. */
  1681. Checkbox.AddCheckBoxWithHeader = function (title, onValueChanged) {
  1682. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  1683. panel.isVertical = false;
  1684. panel.height = "30px";
  1685. var checkbox = new Checkbox();
  1686. checkbox.width = "20px";
  1687. checkbox.height = "20px";
  1688. checkbox.isChecked = true;
  1689. checkbox.color = "green";
  1690. checkbox.onIsCheckedChangedObservable.add(onValueChanged);
  1691. panel.addControl(checkbox);
  1692. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  1693. header.text = title;
  1694. header.width = "180px";
  1695. header.paddingLeft = "5px";
  1696. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1697. header.color = "white";
  1698. panel.addControl(header);
  1699. return panel;
  1700. };
  1701. return Checkbox;
  1702. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  1703. /***/ }),
  1704. /***/ "./2D/controls/colorpicker.ts":
  1705. /*!************************************!*\
  1706. !*** ./2D/controls/colorpicker.ts ***!
  1707. \************************************/
  1708. /*! exports provided: ColorPicker */
  1709. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1710. "use strict";
  1711. __webpack_require__.r(__webpack_exports__);
  1712. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return ColorPicker; });
  1713. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1714. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  1715. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1716. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1717. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  1718. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1719. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  1720. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  1721. /* harmony import */ var _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../controls/textBlock */ "./2D/controls/textBlock.ts");
  1722. /** Class used to create color pickers */
  1723. var ColorPicker = /** @class */ (function (_super) {
  1724. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorPicker, _super);
  1725. /**
  1726. * Creates a new ColorPicker
  1727. * @param name defines the control name
  1728. */
  1729. function ColorPicker(name) {
  1730. var _this = _super.call(this, name) || this;
  1731. _this.name = name;
  1732. _this._value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  1733. _this._tmpColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]();
  1734. _this._pointerStartedOnSquare = false;
  1735. _this._pointerStartedOnWheel = false;
  1736. _this._squareLeft = 0;
  1737. _this._squareTop = 0;
  1738. _this._squareSize = 0;
  1739. _this._h = 360;
  1740. _this._s = 1;
  1741. _this._v = 1;
  1742. /**
  1743. * Observable raised when the value changes
  1744. */
  1745. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1746. // Events
  1747. _this._pointerIsDown = false;
  1748. _this.value = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](.88, .1, .1);
  1749. _this.size = "200px";
  1750. _this.isPointerBlocker = true;
  1751. return _this;
  1752. }
  1753. Object.defineProperty(ColorPicker.prototype, "value", {
  1754. /** Gets or sets the color of the color picker */
  1755. get: function () {
  1756. return this._value;
  1757. },
  1758. set: function (value) {
  1759. if (this._value.equals(value)) {
  1760. return;
  1761. }
  1762. this._value.copyFrom(value);
  1763. this._RGBtoHSV(this._value, this._tmpColor);
  1764. this._h = this._tmpColor.r;
  1765. this._s = Math.max(this._tmpColor.g, 0.00001);
  1766. this._v = Math.max(this._tmpColor.b, 0.00001);
  1767. this._markAsDirty();
  1768. if (this._value.r <= ColorPicker._Epsilon) {
  1769. this._value.r = 0;
  1770. }
  1771. if (this._value.g <= ColorPicker._Epsilon) {
  1772. this._value.g = 0;
  1773. }
  1774. if (this._value.b <= ColorPicker._Epsilon) {
  1775. this._value.b = 0;
  1776. }
  1777. if (this._value.r >= 1.0 - ColorPicker._Epsilon) {
  1778. this._value.r = 1.0;
  1779. }
  1780. if (this._value.g >= 1.0 - ColorPicker._Epsilon) {
  1781. this._value.g = 1.0;
  1782. }
  1783. if (this._value.b >= 1.0 - ColorPicker._Epsilon) {
  1784. this._value.b = 1.0;
  1785. }
  1786. this.onValueChangedObservable.notifyObservers(this._value);
  1787. },
  1788. enumerable: true,
  1789. configurable: true
  1790. });
  1791. Object.defineProperty(ColorPicker.prototype, "width", {
  1792. /**
  1793. * Gets or sets control width
  1794. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1795. */
  1796. get: function () {
  1797. return this._width.toString(this._host);
  1798. },
  1799. set: function (value) {
  1800. if (this._width.toString(this._host) === value) {
  1801. return;
  1802. }
  1803. if (this._width.fromString(value)) {
  1804. this._height.fromString(value);
  1805. this._markAsDirty();
  1806. }
  1807. },
  1808. enumerable: true,
  1809. configurable: true
  1810. });
  1811. Object.defineProperty(ColorPicker.prototype, "height", {
  1812. /**
  1813. * Gets or sets control height
  1814. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1815. */
  1816. get: function () {
  1817. return this._height.toString(this._host);
  1818. },
  1819. /** Gets or sets control height */
  1820. set: function (value) {
  1821. if (this._height.toString(this._host) === value) {
  1822. return;
  1823. }
  1824. if (this._height.fromString(value)) {
  1825. this._width.fromString(value);
  1826. this._markAsDirty();
  1827. }
  1828. },
  1829. enumerable: true,
  1830. configurable: true
  1831. });
  1832. Object.defineProperty(ColorPicker.prototype, "size", {
  1833. /** Gets or sets control size */
  1834. get: function () {
  1835. return this.width;
  1836. },
  1837. set: function (value) {
  1838. this.width = value;
  1839. },
  1840. enumerable: true,
  1841. configurable: true
  1842. });
  1843. ColorPicker.prototype._getTypeName = function () {
  1844. return "ColorPicker";
  1845. };
  1846. /** @hidden */
  1847. ColorPicker.prototype._preMeasure = function (parentMeasure, context) {
  1848. if (parentMeasure.width < parentMeasure.height) {
  1849. this._currentMeasure.height = parentMeasure.width;
  1850. }
  1851. else {
  1852. this._currentMeasure.width = parentMeasure.height;
  1853. }
  1854. };
  1855. ColorPicker.prototype._updateSquareProps = function () {
  1856. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1857. var wheelThickness = radius * .2;
  1858. var innerDiameter = (radius - wheelThickness) * 2;
  1859. var squareSize = innerDiameter / (Math.sqrt(2));
  1860. var offset = radius - squareSize * .5;
  1861. this._squareLeft = this._currentMeasure.left + offset;
  1862. this._squareTop = this._currentMeasure.top + offset;
  1863. this._squareSize = squareSize;
  1864. };
  1865. ColorPicker.prototype._drawGradientSquare = function (hueValue, left, top, width, height, context) {
  1866. var lgh = context.createLinearGradient(left, top, width + left, top);
  1867. lgh.addColorStop(0, '#fff');
  1868. lgh.addColorStop(1, 'hsl(' + hueValue + ', 100%, 50%)');
  1869. context.fillStyle = lgh;
  1870. context.fillRect(left, top, width, height);
  1871. var lgv = context.createLinearGradient(left, top, left, height + top);
  1872. lgv.addColorStop(0, 'rgba(0,0,0,0)');
  1873. lgv.addColorStop(1, '#000');
  1874. context.fillStyle = lgv;
  1875. context.fillRect(left, top, width, height);
  1876. };
  1877. ColorPicker.prototype._drawCircle = function (centerX, centerY, radius, context) {
  1878. context.beginPath();
  1879. context.arc(centerX, centerY, radius + 1, 0, 2 * Math.PI, false);
  1880. context.lineWidth = 3;
  1881. context.strokeStyle = '#333333';
  1882. context.stroke();
  1883. context.beginPath();
  1884. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  1885. context.lineWidth = 3;
  1886. context.strokeStyle = '#ffffff';
  1887. context.stroke();
  1888. };
  1889. ColorPicker.prototype._createColorWheelCanvas = function (radius, thickness) {
  1890. var canvas = document.createElement("canvas");
  1891. canvas.width = radius * 2;
  1892. canvas.height = radius * 2;
  1893. var context = canvas.getContext("2d");
  1894. var image = context.getImageData(0, 0, radius * 2, radius * 2);
  1895. var data = image.data;
  1896. var color = this._tmpColor;
  1897. var maxDistSq = radius * radius;
  1898. var innerRadius = radius - thickness;
  1899. var minDistSq = innerRadius * innerRadius;
  1900. for (var x = -radius; x < radius; x++) {
  1901. for (var y = -radius; y < radius; y++) {
  1902. var distSq = x * x + y * y;
  1903. if (distSq > maxDistSq || distSq < minDistSq) {
  1904. continue;
  1905. }
  1906. var dist = Math.sqrt(distSq);
  1907. var ang = Math.atan2(y, x);
  1908. this._HSVtoRGB(ang * 180 / Math.PI + 180, dist / radius, 1, color);
  1909. var index = ((x + radius) + ((y + radius) * 2 * radius)) * 4;
  1910. data[index] = color.r * 255;
  1911. data[index + 1] = color.g * 255;
  1912. data[index + 2] = color.b * 255;
  1913. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  1914. //apply less alpha to bigger color pickers
  1915. var alphaAmount = .2;
  1916. var maxAlpha = .2;
  1917. var minAlpha = .04;
  1918. var lowerRadius = 50;
  1919. var upperRadius = 150;
  1920. if (radius < lowerRadius) {
  1921. alphaAmount = maxAlpha;
  1922. }
  1923. else if (radius > upperRadius) {
  1924. alphaAmount = minAlpha;
  1925. }
  1926. else {
  1927. alphaAmount = (minAlpha - maxAlpha) * (radius - lowerRadius) / (upperRadius - lowerRadius) + maxAlpha;
  1928. }
  1929. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  1930. if (alphaRatio < alphaAmount) {
  1931. data[index + 3] = 255 * (alphaRatio / alphaAmount);
  1932. }
  1933. else if (alphaRatio > 1 - alphaAmount) {
  1934. data[index + 3] = 255 * (1.0 - ((alphaRatio - (1 - alphaAmount)) / alphaAmount));
  1935. }
  1936. else {
  1937. data[index + 3] = 255;
  1938. }
  1939. }
  1940. }
  1941. context.putImageData(image, 0, 0);
  1942. return canvas;
  1943. };
  1944. ColorPicker.prototype._RGBtoHSV = function (color, result) {
  1945. var r = color.r;
  1946. var g = color.g;
  1947. var b = color.b;
  1948. var max = Math.max(r, g, b);
  1949. var min = Math.min(r, g, b);
  1950. var h = 0;
  1951. var s = 0;
  1952. var v = max;
  1953. var dm = max - min;
  1954. if (max !== 0) {
  1955. s = dm / max;
  1956. }
  1957. if (max != min) {
  1958. if (max == r) {
  1959. h = (g - b) / dm;
  1960. if (g < b) {
  1961. h += 6;
  1962. }
  1963. }
  1964. else if (max == g) {
  1965. h = (b - r) / dm + 2;
  1966. }
  1967. else if (max == b) {
  1968. h = (r - g) / dm + 4;
  1969. }
  1970. h *= 60;
  1971. }
  1972. result.r = h;
  1973. result.g = s;
  1974. result.b = v;
  1975. };
  1976. ColorPicker.prototype._HSVtoRGB = function (hue, saturation, value, result) {
  1977. var chroma = value * saturation;
  1978. var h = hue / 60;
  1979. var x = chroma * (1 - Math.abs((h % 2) - 1));
  1980. var r = 0;
  1981. var g = 0;
  1982. var b = 0;
  1983. if (h >= 0 && h <= 1) {
  1984. r = chroma;
  1985. g = x;
  1986. }
  1987. else if (h >= 1 && h <= 2) {
  1988. r = x;
  1989. g = chroma;
  1990. }
  1991. else if (h >= 2 && h <= 3) {
  1992. g = chroma;
  1993. b = x;
  1994. }
  1995. else if (h >= 3 && h <= 4) {
  1996. g = x;
  1997. b = chroma;
  1998. }
  1999. else if (h >= 4 && h <= 5) {
  2000. r = x;
  2001. b = chroma;
  2002. }
  2003. else if (h >= 5 && h <= 6) {
  2004. r = chroma;
  2005. b = x;
  2006. }
  2007. var m = value - chroma;
  2008. result.set((r + m), (g + m), (b + m));
  2009. };
  2010. /** @hidden */
  2011. ColorPicker.prototype._draw = function (context) {
  2012. context.save();
  2013. this._applyStates(context);
  2014. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2015. var wheelThickness = radius * .2;
  2016. var left = this._currentMeasure.left;
  2017. var top = this._currentMeasure.top;
  2018. if (!this._colorWheelCanvas || this._colorWheelCanvas.width != radius * 2) {
  2019. this._colorWheelCanvas = this._createColorWheelCanvas(radius, wheelThickness);
  2020. }
  2021. this._updateSquareProps();
  2022. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2023. context.shadowColor = this.shadowColor;
  2024. context.shadowBlur = this.shadowBlur;
  2025. context.shadowOffsetX = this.shadowOffsetX;
  2026. context.shadowOffsetY = this.shadowOffsetY;
  2027. context.fillRect(this._squareLeft, this._squareTop, this._squareSize, this._squareSize);
  2028. }
  2029. context.drawImage(this._colorWheelCanvas, left, top);
  2030. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2031. context.shadowBlur = 0;
  2032. context.shadowOffsetX = 0;
  2033. context.shadowOffsetY = 0;
  2034. }
  2035. this._drawGradientSquare(this._h, this._squareLeft, this._squareTop, this._squareSize, this._squareSize, context);
  2036. var cx = this._squareLeft + this._squareSize * this._s;
  2037. var cy = this._squareTop + this._squareSize * (1 - this._v);
  2038. this._drawCircle(cx, cy, radius * .04, context);
  2039. var dist = radius - wheelThickness * .5;
  2040. cx = left + radius + Math.cos((this._h - 180) * Math.PI / 180) * dist;
  2041. cy = top + radius + Math.sin((this._h - 180) * Math.PI / 180) * dist;
  2042. this._drawCircle(cx, cy, wheelThickness * .35, context);
  2043. context.restore();
  2044. };
  2045. ColorPicker.prototype._updateValueFromPointer = function (x, y) {
  2046. if (this._pointerStartedOnWheel) {
  2047. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2048. var centerX = radius + this._currentMeasure.left;
  2049. var centerY = radius + this._currentMeasure.top;
  2050. this._h = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI + 180;
  2051. }
  2052. else if (this._pointerStartedOnSquare) {
  2053. this._updateSquareProps();
  2054. this._s = (x - this._squareLeft) / this._squareSize;
  2055. this._v = 1 - (y - this._squareTop) / this._squareSize;
  2056. this._s = Math.min(this._s, 1);
  2057. this._s = Math.max(this._s, ColorPicker._Epsilon);
  2058. this._v = Math.min(this._v, 1);
  2059. this._v = Math.max(this._v, ColorPicker._Epsilon);
  2060. }
  2061. this._HSVtoRGB(this._h, this._s, this._v, this._tmpColor);
  2062. this.value = this._tmpColor;
  2063. };
  2064. ColorPicker.prototype._isPointOnSquare = function (x, y) {
  2065. this._updateSquareProps();
  2066. var left = this._squareLeft;
  2067. var top = this._squareTop;
  2068. var size = this._squareSize;
  2069. if (x >= left && x <= left + size &&
  2070. y >= top && y <= top + size) {
  2071. return true;
  2072. }
  2073. return false;
  2074. };
  2075. ColorPicker.prototype._isPointOnWheel = function (x, y) {
  2076. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2077. var centerX = radius + this._currentMeasure.left;
  2078. var centerY = radius + this._currentMeasure.top;
  2079. var wheelThickness = radius * .2;
  2080. var innerRadius = radius - wheelThickness;
  2081. var radiusSq = radius * radius;
  2082. var innerRadiusSq = innerRadius * innerRadius;
  2083. var dx = x - centerX;
  2084. var dy = y - centerY;
  2085. var distSq = dx * dx + dy * dy;
  2086. if (distSq <= radiusSq && distSq >= innerRadiusSq) {
  2087. return true;
  2088. }
  2089. return false;
  2090. };
  2091. ColorPicker.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  2092. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  2093. return false;
  2094. }
  2095. this._pointerIsDown = true;
  2096. this._pointerStartedOnSquare = false;
  2097. this._pointerStartedOnWheel = false;
  2098. // Invert transform
  2099. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2100. var x = this._transformedPosition.x;
  2101. var y = this._transformedPosition.y;
  2102. if (this._isPointOnSquare(x, y)) {
  2103. this._pointerStartedOnSquare = true;
  2104. }
  2105. else if (this._isPointOnWheel(x, y)) {
  2106. this._pointerStartedOnWheel = true;
  2107. }
  2108. this._updateValueFromPointer(x, y);
  2109. this._host._capturingControl[pointerId] = this;
  2110. return true;
  2111. };
  2112. ColorPicker.prototype._onPointerMove = function (target, coordinates) {
  2113. // Invert transform
  2114. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2115. var x = this._transformedPosition.x;
  2116. var y = this._transformedPosition.y;
  2117. if (this._pointerIsDown) {
  2118. this._updateValueFromPointer(x, y);
  2119. }
  2120. _super.prototype._onPointerMove.call(this, target, coordinates);
  2121. };
  2122. ColorPicker.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  2123. this._pointerIsDown = false;
  2124. delete this._host._capturingControl[pointerId];
  2125. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  2126. };
  2127. /**
  2128. * This function expands the color picker by creating a color picker dialog with manual
  2129. * color value input and the ability to save colors into an array to be used later in
  2130. * subsequent launches of the dialogue.
  2131. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  2132. * @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.
  2133. * @returns picked color as a hex string and the saved colors array as hex strings.
  2134. */
  2135. ColorPicker.ShowPickerDialogAsync = function (advancedTexture, options) {
  2136. return new Promise(function (resolve, reject) {
  2137. // Default options
  2138. options.pickerWidth = options.pickerWidth || "640px";
  2139. options.pickerHeight = options.pickerHeight || "400px";
  2140. options.headerHeight = options.headerHeight || "35px";
  2141. options.lastColor = options.lastColor || "#000000";
  2142. options.swatchLimit = options.swatchLimit || 20;
  2143. options.numSwatchesPerLine = options.numSwatchesPerLine || 10;
  2144. // Window size settings
  2145. var drawerMaxRows = options.swatchLimit / options.numSwatchesPerLine;
  2146. var rawSwatchSize = parseFloat(options.pickerWidth) / options.numSwatchesPerLine;
  2147. var gutterSize = Math.floor(rawSwatchSize * 0.25);
  2148. var colGutters = gutterSize * (options.numSwatchesPerLine + 1);
  2149. var swatchSize = Math.floor((parseFloat(options.pickerWidth) - colGutters) / options.numSwatchesPerLine);
  2150. var drawerMaxSize = (swatchSize * drawerMaxRows) + (gutterSize * (drawerMaxRows + 1));
  2151. var containerSize = (parseInt(options.pickerHeight) + drawerMaxSize + Math.floor(swatchSize * 0.25)).toString() + "px";
  2152. // Button Colors
  2153. var buttonColor = "#c0c0c0";
  2154. var buttonBackgroundColor = "#535353";
  2155. var buttonBackgroundHoverColor = "#414141";
  2156. var buttonBackgroundClickColor = "515151";
  2157. var buttonDisabledColor = "#555555";
  2158. var buttonDisabledBackgroundColor = "#454545";
  2159. var currentSwatchesOutlineColor = "#404040";
  2160. var luminanceLimitColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString("#dddddd");
  2161. var luminanceLimit = luminanceLimitColor.r + luminanceLimitColor.g + luminanceLimitColor.b;
  2162. var iconColorDark = "#aaaaaa";
  2163. var iconColorLight = "#ffffff";
  2164. var closeIconColor;
  2165. // Button settings
  2166. var buttonFontSize;
  2167. var butEdit;
  2168. var buttonWidth;
  2169. var buttonHeight;
  2170. // Input Text Colors
  2171. var inputFieldLabels = ["R", "G", "B"];
  2172. var inputTextBackgroundColor = "#454545";
  2173. var inputTextColor = "#f0f0f0";
  2174. // This is the current color as set by either the picker or by entering a value
  2175. var currentColor;
  2176. // This int is used for naming swatches and serves as the index for calling them from the list
  2177. var swatchNumber;
  2178. // Menu Panel options. We need to know if the swatchDrawer exists so we can create it if needed.
  2179. var swatchDrawer;
  2180. var editSwatchMode = false;
  2181. // Color InputText fields that will be updated upon value change
  2182. var picker;
  2183. var rValInt;
  2184. var gValInt;
  2185. var bValInt;
  2186. var rValDec;
  2187. var gValDec;
  2188. var bValDec;
  2189. var hexVal;
  2190. var newSwatch;
  2191. var lastVal;
  2192. var activeField;
  2193. /**
  2194. * Will update all values for InputText and ColorPicker controls based on the BABYLON.Color3 passed to this function.
  2195. * Each InputText control and the ColorPicker control will be tested to see if they are the activeField and if they
  2196. * are will receive no update. This is to prevent the input from the user being overwritten.
  2197. */
  2198. function updateValues(value, inputField) {
  2199. activeField = inputField;
  2200. var pickedColor = value.toHexString();
  2201. newSwatch.background = pickedColor;
  2202. if (rValInt.name != activeField) {
  2203. rValInt.text = Math.floor(value.r * 255).toString();
  2204. }
  2205. if (gValInt.name != activeField) {
  2206. gValInt.text = Math.floor(value.g * 255).toString();
  2207. }
  2208. if (bValInt.name != activeField) {
  2209. bValInt.text = Math.floor(value.b * 255).toString();
  2210. }
  2211. if (rValDec.name != activeField) {
  2212. rValDec.text = value.r.toString();
  2213. }
  2214. if (gValDec.name != activeField) {
  2215. gValDec.text = value.g.toString();
  2216. }
  2217. if (bValDec.name != activeField) {
  2218. bValDec.text = value.b.toString();
  2219. }
  2220. if (hexVal.name != activeField) {
  2221. var minusPound = pickedColor.split("#");
  2222. hexVal.text = minusPound[1];
  2223. }
  2224. if (picker.name != activeField) {
  2225. picker.value = value;
  2226. }
  2227. }
  2228. // When the user enters an integer for R, G, or B we check to make sure it is a valid number and replace if not.
  2229. function updateInt(field, channel) {
  2230. var newValue = field.text;
  2231. var checkVal = /[^0-9]/g.test(newValue);
  2232. if (checkVal) {
  2233. field.text = lastVal;
  2234. return;
  2235. }
  2236. else {
  2237. if (newValue != "") {
  2238. if (Math.floor(parseInt(newValue)) < 0) {
  2239. newValue = "0";
  2240. }
  2241. else if (Math.floor(parseInt(newValue)) > 255) {
  2242. newValue = "255";
  2243. }
  2244. else if (isNaN(parseInt(newValue))) {
  2245. newValue = "0";
  2246. }
  2247. }
  2248. if (activeField == field.name) {
  2249. lastVal = newValue;
  2250. }
  2251. }
  2252. if (newValue != "") {
  2253. newValue = parseInt(newValue).toString();
  2254. field.text = newValue;
  2255. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2256. if (activeField == field.name) {
  2257. if (channel == "r") {
  2258. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]((parseInt(newValue)) / 255, newSwatchRGB.g, newSwatchRGB.b), field.name);
  2259. }
  2260. else if (channel == "g") {
  2261. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, (parseInt(newValue)) / 255, newSwatchRGB.b), field.name);
  2262. }
  2263. else {
  2264. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, (parseInt(newValue)) / 255), field.name);
  2265. }
  2266. }
  2267. }
  2268. }
  2269. // When the user enters a float for R, G, or B we check to make sure it is a valid number and replace if not.
  2270. function updateFloat(field, channel) {
  2271. var newValue = field.text;
  2272. var checkVal = /[^0-9\.]/g.test(newValue);
  2273. if (checkVal) {
  2274. field.text = lastVal;
  2275. return;
  2276. }
  2277. else {
  2278. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2279. if (parseFloat(newValue) < 0.0) {
  2280. newValue = "0.0";
  2281. }
  2282. else if (parseFloat(newValue) > 1.0) {
  2283. newValue = "1.0";
  2284. }
  2285. else if (isNaN(parseFloat(newValue))) {
  2286. newValue = "0.0";
  2287. }
  2288. }
  2289. if (activeField == field.name) {
  2290. lastVal = newValue;
  2291. }
  2292. }
  2293. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2294. newValue = parseFloat(newValue).toString();
  2295. field.text = newValue;
  2296. }
  2297. else {
  2298. newValue = "0.0";
  2299. }
  2300. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2301. if (activeField == field.name) {
  2302. if (channel == "r") {
  2303. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](parseFloat(newValue), newSwatchRGB.g, newSwatchRGB.b), field.name);
  2304. }
  2305. else if (channel == "g") {
  2306. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, parseFloat(newValue), newSwatchRGB.b), field.name);
  2307. }
  2308. else {
  2309. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, parseFloat(newValue)), field.name);
  2310. }
  2311. }
  2312. }
  2313. // Removes the current index from the savedColors array. Drawer can then be regenerated.
  2314. function deleteSwatch(index) {
  2315. if (options.savedColors) {
  2316. options.savedColors.splice(index, 1);
  2317. }
  2318. if (options.savedColors && options.savedColors.length == 0) {
  2319. setEditButtonVisibility(false);
  2320. editSwatchMode = false;
  2321. }
  2322. }
  2323. // Creates and styles an individual swatch when updateSwatches is called.
  2324. function createSwatch() {
  2325. if (options.savedColors && options.savedColors[swatchNumber]) {
  2326. if (editSwatchMode) {
  2327. var icon = "b";
  2328. }
  2329. else {
  2330. var icon = "";
  2331. }
  2332. var swatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("Swatch_" + swatchNumber, icon);
  2333. swatch.fontFamily = "BabylonJSglyphs";
  2334. var swatchColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[swatchNumber]);
  2335. var swatchLuminence = swatchColor.r + swatchColor.g + swatchColor.b;
  2336. // Set color of outline and textBlock based on luminance of the color swatch so feedback always visible
  2337. if (swatchLuminence > luminanceLimit) {
  2338. swatch.color = iconColorDark;
  2339. }
  2340. else {
  2341. swatch.color = iconColorLight;
  2342. }
  2343. swatch.fontSize = Math.floor(swatchSize * 0.7);
  2344. swatch.textBlock.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2345. swatch.height = swatch.width = (swatchSize).toString() + "px";
  2346. swatch.background = options.savedColors[swatchNumber];
  2347. swatch.thickness = 2;
  2348. var metadata_1 = swatchNumber;
  2349. swatch.pointerDownAnimation = function () {
  2350. swatch.thickness = 4;
  2351. };
  2352. swatch.pointerUpAnimation = function () {
  2353. swatch.thickness = 3;
  2354. };
  2355. swatch.pointerEnterAnimation = function () {
  2356. swatch.thickness = 3;
  2357. };
  2358. swatch.pointerOutAnimation = function () {
  2359. swatch.thickness = 2;
  2360. };
  2361. swatch.onPointerClickObservable.add(function () {
  2362. if (!editSwatchMode) {
  2363. if (options.savedColors) {
  2364. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[metadata_1]), swatch.name);
  2365. }
  2366. }
  2367. else {
  2368. deleteSwatch(metadata_1);
  2369. updateSwatches("", butSave);
  2370. }
  2371. });
  2372. return swatch;
  2373. }
  2374. else {
  2375. return null;
  2376. }
  2377. }
  2378. // Mode switch to render button text and close symbols on swatch controls
  2379. function editSwatches(mode) {
  2380. if (mode !== undefined) {
  2381. editSwatchMode = mode;
  2382. }
  2383. if (editSwatchMode) {
  2384. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2385. var thisButton = swatchDrawer.children[i];
  2386. thisButton.textBlock.text = "b";
  2387. }
  2388. if (butEdit !== undefined) {
  2389. butEdit.textBlock.text = "Done";
  2390. }
  2391. }
  2392. else {
  2393. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2394. var thisButton = swatchDrawer.children[i];
  2395. thisButton.textBlock.text = "";
  2396. }
  2397. if (butEdit !== undefined) {
  2398. butEdit.textBlock.text = "Edit";
  2399. }
  2400. }
  2401. }
  2402. /**
  2403. * When Save Color button is pressed this function will first create a swatch drawer if one is not already
  2404. * made. Then all controls are removed from the drawer and we step through the savedColors array and
  2405. * creates one swatch per color. It will also set the height of the drawer control based on how many
  2406. * saved colors there are and how many can be stored per row.
  2407. */
  2408. function updateSwatches(color, button) {
  2409. if (options.savedColors) {
  2410. if (color != "") {
  2411. options.savedColors.push(color);
  2412. }
  2413. swatchNumber = 0;
  2414. swatchDrawer.clearControls();
  2415. var rowCount = Math.ceil(options.savedColors.length / options.numSwatchesPerLine);
  2416. if (rowCount == 0) {
  2417. var gutterCount = 0;
  2418. }
  2419. else {
  2420. var gutterCount = rowCount + 1;
  2421. }
  2422. if (swatchDrawer.rowCount != rowCount + gutterCount) {
  2423. var currentRows = swatchDrawer.rowCount;
  2424. for (var i = 0; i < currentRows; i++) {
  2425. swatchDrawer.removeRowDefinition(0);
  2426. }
  2427. for (var i = 0; i < rowCount + gutterCount; i++) {
  2428. if (i % 2) {
  2429. swatchDrawer.addRowDefinition(swatchSize, true);
  2430. }
  2431. else {
  2432. swatchDrawer.addRowDefinition(gutterSize, true);
  2433. }
  2434. }
  2435. }
  2436. swatchDrawer.height = ((swatchSize * rowCount) + (gutterCount * gutterSize)).toString() + "px";
  2437. for (var y = 1, thisRow = 1; y < rowCount + gutterCount; y += 2, thisRow++) {
  2438. // Determine number of buttons to create per row based on the button limit per row and number of saved colors
  2439. if (options.savedColors.length > thisRow * options.numSwatchesPerLine) {
  2440. var totalButtonsThisRow = options.numSwatchesPerLine;
  2441. }
  2442. else {
  2443. var totalButtonsThisRow = options.savedColors.length - ((thisRow - 1) * options.numSwatchesPerLine);
  2444. }
  2445. var buttonIterations = (Math.min(Math.max(totalButtonsThisRow, 0), options.numSwatchesPerLine));
  2446. for (var x = 0, w = 1; x < buttonIterations; x++) {
  2447. if (x > options.numSwatchesPerLine) {
  2448. continue;
  2449. }
  2450. var swatch = createSwatch();
  2451. if (swatch != null) {
  2452. swatchDrawer.addControl(swatch, y, w);
  2453. w += 2;
  2454. swatchNumber++;
  2455. }
  2456. else {
  2457. continue;
  2458. }
  2459. }
  2460. }
  2461. if (options.savedColors.length >= options.swatchLimit) {
  2462. disableButton(button, true);
  2463. }
  2464. else {
  2465. disableButton(button, false);
  2466. }
  2467. }
  2468. }
  2469. // Shows or hides edit swatches button depending on if there are saved swatches
  2470. function setEditButtonVisibility(enableButton) {
  2471. if (enableButton) {
  2472. butEdit = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butEdit", "Edit");
  2473. butEdit.width = buttonWidth;
  2474. butEdit.height = buttonHeight;
  2475. butEdit.left = (Math.floor(parseInt(buttonWidth) * 0.1)).toString() + "px";
  2476. butEdit.top = (parseFloat(butEdit.left) * -1).toString() + "px";
  2477. butEdit.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_BOTTOM;
  2478. butEdit.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2479. butEdit.thickness = 2;
  2480. butEdit.color = buttonColor;
  2481. butEdit.fontSize = buttonFontSize;
  2482. butEdit.background = buttonBackgroundColor;
  2483. butEdit.onPointerEnterObservable.add(function () {
  2484. butEdit.background = buttonBackgroundHoverColor;
  2485. });
  2486. butEdit.onPointerOutObservable.add(function () {
  2487. butEdit.background = buttonBackgroundColor;
  2488. });
  2489. butEdit.pointerDownAnimation = function () {
  2490. butEdit.background = buttonBackgroundClickColor;
  2491. };
  2492. butEdit.pointerUpAnimation = function () {
  2493. butEdit.background = buttonBackgroundHoverColor;
  2494. };
  2495. butEdit.onPointerClickObservable.add(function () {
  2496. if (editSwatchMode) {
  2497. editSwatchMode = false;
  2498. }
  2499. else {
  2500. editSwatchMode = true;
  2501. }
  2502. editSwatches();
  2503. });
  2504. pickerGrid.addControl(butEdit, 1, 0);
  2505. }
  2506. else {
  2507. pickerGrid.removeControl(butEdit);
  2508. }
  2509. }
  2510. // Called when the user hits the limit of saved colors in the drawer.
  2511. function disableButton(button, disabled) {
  2512. if (disabled) {
  2513. button.color = buttonDisabledColor;
  2514. button.background = buttonDisabledBackgroundColor;
  2515. }
  2516. else {
  2517. button.color = buttonColor;
  2518. button.background = buttonBackgroundColor;
  2519. }
  2520. }
  2521. // Passes last chosen color back to scene and kills dialog by removing from AdvancedDynamicTexture
  2522. function closePicker(color) {
  2523. if (options.savedColors && options.savedColors.length > 0) {
  2524. resolve({
  2525. savedColors: options.savedColors,
  2526. pickedColor: color
  2527. });
  2528. }
  2529. else {
  2530. resolve({
  2531. pickedColor: color
  2532. });
  2533. }
  2534. advancedTexture.removeControl(dialogContainer);
  2535. }
  2536. // Dialogue menu container which will contain both the main dialogue window and the swatch drawer which opens once a color is saved.
  2537. var dialogContainer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2538. dialogContainer.name = "Dialog Container";
  2539. dialogContainer.width = options.pickerWidth;
  2540. if (options.savedColors) {
  2541. dialogContainer.height = containerSize;
  2542. var topRow = parseInt(options.pickerHeight) / parseInt(containerSize);
  2543. dialogContainer.addRowDefinition(topRow, false);
  2544. dialogContainer.addRowDefinition(1.0 - topRow, false);
  2545. }
  2546. else {
  2547. dialogContainer.height = options.pickerHeight;
  2548. dialogContainer.addRowDefinition(1.0, false);
  2549. }
  2550. advancedTexture.addControl(dialogContainer);
  2551. // Swatch drawer which contains all saved color buttons
  2552. if (options.savedColors) {
  2553. swatchDrawer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2554. swatchDrawer.name = "Swatch Drawer";
  2555. swatchDrawer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  2556. swatchDrawer.background = buttonBackgroundColor;
  2557. swatchDrawer.width = options.pickerWidth;
  2558. var initialRows = options.savedColors.length / options.numSwatchesPerLine;
  2559. if (initialRows == 0) {
  2560. var gutterCount = 0;
  2561. }
  2562. else {
  2563. var gutterCount = initialRows + 1;
  2564. }
  2565. swatchDrawer.height = ((swatchSize * initialRows) + (gutterCount * gutterSize)).toString() + "px";
  2566. swatchDrawer.top = Math.floor(swatchSize * 0.25).toString() + "px";
  2567. for (var i = 0; i < (Math.ceil(options.savedColors.length / options.numSwatchesPerLine) * 2) + 1; i++) {
  2568. if (i % 2 != 0) {
  2569. swatchDrawer.addRowDefinition(swatchSize, true);
  2570. }
  2571. else {
  2572. swatchDrawer.addRowDefinition(gutterSize, true);
  2573. }
  2574. }
  2575. for (var i = 0; i < options.numSwatchesPerLine * 2 + 1; i++) {
  2576. if (i % 2 != 0) {
  2577. swatchDrawer.addColumnDefinition(swatchSize, true);
  2578. }
  2579. else {
  2580. swatchDrawer.addColumnDefinition(gutterSize, true);
  2581. }
  2582. }
  2583. dialogContainer.addControl(swatchDrawer, 1, 0);
  2584. }
  2585. // Picker container
  2586. var pickerPanel = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2587. pickerPanel.name = "Picker Panel";
  2588. pickerPanel.height = options.pickerHeight;
  2589. var panelHead = parseInt(options.headerHeight) / parseInt(options.pickerHeight);
  2590. var pickerPanelRows = [panelHead, 1.0 - panelHead];
  2591. pickerPanel.addRowDefinition(pickerPanelRows[0], false);
  2592. pickerPanel.addRowDefinition(pickerPanelRows[1], false);
  2593. dialogContainer.addControl(pickerPanel, 0, 0);
  2594. // Picker container header
  2595. var header = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2596. header.name = "Dialogue Header Bar";
  2597. header.background = "#cccccc";
  2598. header.thickness = 0;
  2599. pickerPanel.addControl(header, 0, 0);
  2600. // Header close button
  2601. var closeButton = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("closeButton", "a");
  2602. closeButton.fontFamily = "BabylonJSglyphs";
  2603. var headerColor3 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(header.background);
  2604. closeIconColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0 - headerColor3.r, 1.0 - headerColor3.g, 1.0 - headerColor3.b);
  2605. closeButton.color = closeIconColor.toHexString();
  2606. closeButton.fontSize = Math.floor(parseInt(options.headerHeight) * 0.6);
  2607. closeButton.textBlock.textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2608. closeButton.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_RIGHT;
  2609. closeButton.height = closeButton.width = options.headerHeight;
  2610. closeButton.background = header.background;
  2611. closeButton.thickness = 0;
  2612. closeButton.pointerDownAnimation = function () {
  2613. };
  2614. closeButton.pointerUpAnimation = function () {
  2615. closeButton.background = header.background;
  2616. };
  2617. closeButton.pointerEnterAnimation = function () {
  2618. closeButton.color = header.background;
  2619. closeButton.background = "red";
  2620. };
  2621. closeButton.pointerOutAnimation = function () {
  2622. closeButton.color = closeIconColor.toHexString();
  2623. closeButton.background = header.background;
  2624. };
  2625. closeButton.onPointerClickObservable.add(function () {
  2626. closePicker(currentSwatch.background);
  2627. });
  2628. pickerPanel.addControl(closeButton, 0, 0);
  2629. // Dialog container body
  2630. var dialogBody = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2631. dialogBody.name = "Dialogue Body";
  2632. dialogBody.background = buttonBackgroundColor;
  2633. var dialogBodyCols = [0.4375, 0.5625];
  2634. dialogBody.addRowDefinition(1.0, false);
  2635. dialogBody.addColumnDefinition(dialogBodyCols[0], false);
  2636. dialogBody.addColumnDefinition(dialogBodyCols[1], false);
  2637. pickerPanel.addControl(dialogBody, 1, 0);
  2638. // Picker grid
  2639. var pickerGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2640. pickerGrid.name = "Picker Grid";
  2641. pickerGrid.addRowDefinition(0.85, false);
  2642. pickerGrid.addRowDefinition(0.15, false);
  2643. dialogBody.addControl(pickerGrid, 0, 0);
  2644. // Picker control
  2645. picker = new ColorPicker();
  2646. picker.name = "GUI Color Picker";
  2647. if (options.pickerHeight < options.pickerWidth) {
  2648. picker.width = 0.89;
  2649. }
  2650. else {
  2651. picker.height = 0.89;
  2652. }
  2653. picker.value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2654. picker.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  2655. picker.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2656. picker.onPointerDownObservable.add(function () {
  2657. activeField = picker.name;
  2658. lastVal = "";
  2659. editSwatches(false);
  2660. });
  2661. picker.onValueChangedObservable.add(function (value) {
  2662. if (activeField == picker.name) {
  2663. updateValues(value, picker.name);
  2664. }
  2665. });
  2666. pickerGrid.addControl(picker, 0, 0);
  2667. // Picker body right quarant
  2668. var pickerBodyRight = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2669. pickerBodyRight.name = "Dialogue Right Half";
  2670. pickerBodyRight.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2671. var pickerBodyRightRows = [0.514, 0.486];
  2672. pickerBodyRight.addRowDefinition(pickerBodyRightRows[0], false);
  2673. pickerBodyRight.addRowDefinition(pickerBodyRightRows[1], false);
  2674. dialogBody.addControl(pickerBodyRight, 1, 1);
  2675. // Picker container swatches and buttons
  2676. var pickerSwatchesButtons = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2677. pickerSwatchesButtons.name = "Swatches and Buttons";
  2678. var pickerButtonsCol = [0.417, 0.583];
  2679. pickerSwatchesButtons.addRowDefinition(1.0, false);
  2680. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[0], false);
  2681. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[1], false);
  2682. pickerBodyRight.addControl(pickerSwatchesButtons, 0, 0);
  2683. // Picker Swatches quadrant
  2684. var pickerSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2685. pickerSwatches.name = "New and Current Swatches";
  2686. var pickeSwatchesRows = [0.04, 0.16, 0.64, 0.16];
  2687. pickerSwatches.addRowDefinition(pickeSwatchesRows[0], false);
  2688. pickerSwatches.addRowDefinition(pickeSwatchesRows[1], false);
  2689. pickerSwatches.addRowDefinition(pickeSwatchesRows[2], false);
  2690. pickerSwatches.addRowDefinition(pickeSwatchesRows[3], false);
  2691. pickerSwatchesButtons.addControl(pickerSwatches, 0, 0);
  2692. // Active swatches
  2693. var activeSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2694. activeSwatches.name = "Active Swatches";
  2695. activeSwatches.width = 0.67;
  2696. activeSwatches.addRowDefinition(0.5, false);
  2697. activeSwatches.addRowDefinition(0.5, false);
  2698. pickerSwatches.addControl(activeSwatches, 2, 0);
  2699. var labelWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[0] * 0.11));
  2700. var labelHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * pickeSwatchesRows[1] * 0.5));
  2701. if (options.pickerWidth > options.pickerHeight) {
  2702. var labelTextSize = labelHeight;
  2703. }
  2704. else {
  2705. var labelTextSize = labelWidth;
  2706. }
  2707. // New color swatch and previous color button
  2708. var newText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2709. newText.text = "new";
  2710. newText.name = "New Color Label";
  2711. newText.color = buttonColor;
  2712. newText.fontSize = labelTextSize;
  2713. pickerSwatches.addControl(newText, 1, 0);
  2714. newSwatch = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2715. newSwatch.name = "New Color Swatch";
  2716. newSwatch.background = options.lastColor;
  2717. newSwatch.thickness = 0;
  2718. activeSwatches.addControl(newSwatch, 0, 0);
  2719. var currentSwatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("currentSwatch", "");
  2720. currentSwatch.background = options.lastColor;
  2721. currentSwatch.thickness = 0;
  2722. currentSwatch.onPointerClickObservable.add(function () {
  2723. var revertColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(currentSwatch.background);
  2724. updateValues(revertColor, currentSwatch.name);
  2725. editSwatches(false);
  2726. });
  2727. currentSwatch.pointerDownAnimation = function () { };
  2728. currentSwatch.pointerUpAnimation = function () { };
  2729. currentSwatch.pointerEnterAnimation = function () { };
  2730. currentSwatch.pointerOutAnimation = function () { };
  2731. activeSwatches.addControl(currentSwatch, 1, 0);
  2732. var swatchOutline = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2733. swatchOutline.name = "Swatch Outline";
  2734. swatchOutline.width = 0.67;
  2735. swatchOutline.thickness = 2;
  2736. swatchOutline.color = currentSwatchesOutlineColor;
  2737. swatchOutline.isHitTestVisible = false;
  2738. pickerSwatches.addControl(swatchOutline, 2, 0);
  2739. var currentText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2740. currentText.name = "Current Color Label";
  2741. currentText.text = "current";
  2742. currentText.color = buttonColor;
  2743. currentText.fontSize = labelTextSize;
  2744. pickerSwatches.addControl(currentText, 3, 0);
  2745. // Buttons grid
  2746. var buttonGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2747. buttonGrid.name = "Button Grid";
  2748. buttonGrid.height = 0.8;
  2749. var buttonGridRows = 1 / 3;
  2750. buttonGrid.addRowDefinition(buttonGridRows, false);
  2751. buttonGrid.addRowDefinition(buttonGridRows, false);
  2752. buttonGrid.addRowDefinition(buttonGridRows, false);
  2753. pickerSwatchesButtons.addControl(buttonGrid, 0, 1);
  2754. // Determine pixel width and height for all buttons from overall panel dimensions
  2755. buttonWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[1] * 0.67)).toString() + "px";
  2756. buttonHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * (parseFloat(buttonGrid.height.toString()) / 100) * buttonGridRows * 0.7)).toString() + "px";
  2757. // Determine button type size
  2758. if (parseFloat(buttonWidth) > parseFloat(buttonHeight)) {
  2759. buttonFontSize = Math.floor(parseFloat(buttonHeight) * 0.45);
  2760. }
  2761. else {
  2762. buttonFontSize = Math.floor(parseFloat(buttonWidth) * 0.11);
  2763. }
  2764. // Panel Buttons
  2765. var butOK = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butOK", "OK");
  2766. butOK.width = buttonWidth;
  2767. butOK.height = buttonHeight;
  2768. butOK.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2769. butOK.thickness = 2;
  2770. butOK.color = buttonColor;
  2771. butOK.fontSize = buttonFontSize;
  2772. butOK.background = buttonBackgroundColor;
  2773. butOK.onPointerEnterObservable.add(function () { butOK.background = buttonBackgroundHoverColor; });
  2774. butOK.onPointerOutObservable.add(function () { butOK.background = buttonBackgroundColor; });
  2775. butOK.pointerDownAnimation = function () {
  2776. butOK.background = buttonBackgroundClickColor;
  2777. };
  2778. butOK.pointerUpAnimation = function () {
  2779. butOK.background = buttonBackgroundHoverColor;
  2780. };
  2781. butOK.onPointerClickObservable.add(function () {
  2782. editSwatches(false);
  2783. closePicker(newSwatch.background);
  2784. });
  2785. buttonGrid.addControl(butOK, 0, 0);
  2786. var butCancel = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butCancel", "Cancel");
  2787. butCancel.width = buttonWidth;
  2788. butCancel.height = buttonHeight;
  2789. butCancel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2790. butCancel.thickness = 2;
  2791. butCancel.color = buttonColor;
  2792. butCancel.fontSize = buttonFontSize;
  2793. butCancel.background = buttonBackgroundColor;
  2794. butCancel.onPointerEnterObservable.add(function () { butCancel.background = buttonBackgroundHoverColor; });
  2795. butCancel.onPointerOutObservable.add(function () { butCancel.background = buttonBackgroundColor; });
  2796. butCancel.pointerDownAnimation = function () {
  2797. butCancel.background = buttonBackgroundClickColor;
  2798. };
  2799. butCancel.pointerUpAnimation = function () {
  2800. butCancel.background = buttonBackgroundHoverColor;
  2801. };
  2802. butCancel.onPointerClickObservable.add(function () {
  2803. editSwatches(false);
  2804. closePicker(currentSwatch.background);
  2805. });
  2806. buttonGrid.addControl(butCancel, 1, 0);
  2807. if (options.savedColors) {
  2808. var butSave = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butSave", "Save");
  2809. butSave.width = buttonWidth;
  2810. butSave.height = buttonHeight;
  2811. butSave.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2812. butSave.thickness = 2;
  2813. butSave.fontSize = buttonFontSize;
  2814. if (options.savedColors.length < options.swatchLimit) {
  2815. butSave.color = buttonColor;
  2816. butSave.background = buttonBackgroundColor;
  2817. }
  2818. else {
  2819. disableButton(butSave, true);
  2820. }
  2821. butSave.onPointerEnterObservable.add(function () {
  2822. if (options.savedColors) {
  2823. if (options.savedColors.length < options.swatchLimit) {
  2824. butSave.background = buttonBackgroundHoverColor;
  2825. }
  2826. }
  2827. });
  2828. butSave.onPointerOutObservable.add(function () {
  2829. if (options.savedColors) {
  2830. if (options.savedColors.length < options.swatchLimit) {
  2831. butSave.background = buttonBackgroundColor;
  2832. }
  2833. }
  2834. });
  2835. butSave.pointerDownAnimation = function () {
  2836. if (options.savedColors) {
  2837. if (options.savedColors.length < options.swatchLimit) {
  2838. butSave.background = buttonBackgroundClickColor;
  2839. }
  2840. }
  2841. };
  2842. butSave.pointerUpAnimation = function () {
  2843. if (options.savedColors) {
  2844. if (options.savedColors.length < options.swatchLimit) {
  2845. butSave.background = buttonBackgroundHoverColor;
  2846. }
  2847. }
  2848. };
  2849. butSave.onPointerClickObservable.add(function () {
  2850. if (options.savedColors) {
  2851. if (options.savedColors.length == 0) {
  2852. setEditButtonVisibility(true);
  2853. }
  2854. if (options.savedColors.length < options.swatchLimit) {
  2855. updateSwatches(newSwatch.background, butSave);
  2856. }
  2857. editSwatches(false);
  2858. }
  2859. });
  2860. if (options.savedColors.length > 0) {
  2861. setEditButtonVisibility(true);
  2862. }
  2863. buttonGrid.addControl(butSave, 2, 0);
  2864. }
  2865. // Picker color values input
  2866. var pickerColorValues = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2867. pickerColorValues.name = "Dialog Lower Right";
  2868. pickerColorValues.addRowDefinition(0.02, false);
  2869. pickerColorValues.addRowDefinition(0.63, false);
  2870. pickerColorValues.addRowDefinition(0.21, false);
  2871. pickerColorValues.addRowDefinition(0.14, false);
  2872. pickerBodyRight.addControl(pickerColorValues, 1, 0);
  2873. // RGB values text boxes
  2874. currentColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2875. var rgbValuesQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2876. rgbValuesQuadrant.name = "RGB Values";
  2877. rgbValuesQuadrant.width = 0.82;
  2878. rgbValuesQuadrant.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2879. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2880. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2881. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2882. rgbValuesQuadrant.addColumnDefinition(0.1, false);
  2883. rgbValuesQuadrant.addColumnDefinition(0.2, false);
  2884. rgbValuesQuadrant.addColumnDefinition(0.7, false);
  2885. pickerColorValues.addControl(rgbValuesQuadrant, 1, 0);
  2886. for (var i = 0; i < inputFieldLabels.length; i++) {
  2887. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2888. labelText.text = inputFieldLabels[i];
  2889. labelText.color = buttonColor;
  2890. labelText.fontSize = buttonFontSize;
  2891. rgbValuesQuadrant.addControl(labelText, i, 0);
  2892. }
  2893. // Input fields for RGB values
  2894. rValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2895. rValInt.width = 0.83;
  2896. rValInt.height = 0.72;
  2897. rValInt.name = "rIntField";
  2898. rValInt.fontSize = buttonFontSize;
  2899. rValInt.text = (currentColor.r * 255).toString();
  2900. rValInt.color = inputTextColor;
  2901. rValInt.background = inputTextBackgroundColor;
  2902. rValInt.onFocusObservable.add(function () {
  2903. activeField = rValInt.name;
  2904. lastVal = rValInt.text;
  2905. editSwatches(false);
  2906. });
  2907. rValInt.onBlurObservable.add(function () {
  2908. if (rValInt.text == "") {
  2909. rValInt.text = "0";
  2910. }
  2911. updateInt(rValInt, "r");
  2912. if (activeField == rValInt.name) {
  2913. activeField = "";
  2914. }
  2915. });
  2916. rValInt.onTextChangedObservable.add(function () {
  2917. if (activeField == rValInt.name) {
  2918. updateInt(rValInt, "r");
  2919. }
  2920. });
  2921. rgbValuesQuadrant.addControl(rValInt, 0, 1);
  2922. gValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2923. gValInt.width = 0.83;
  2924. gValInt.height = 0.72;
  2925. gValInt.name = "gIntField";
  2926. gValInt.fontSize = buttonFontSize;
  2927. gValInt.text = (currentColor.g * 255).toString();
  2928. gValInt.color = inputTextColor;
  2929. gValInt.background = inputTextBackgroundColor;
  2930. gValInt.onFocusObservable.add(function () {
  2931. activeField = gValInt.name;
  2932. lastVal = gValInt.text;
  2933. editSwatches(false);
  2934. });
  2935. gValInt.onBlurObservable.add(function () {
  2936. if (gValInt.text == "") {
  2937. gValInt.text = "0";
  2938. }
  2939. updateInt(gValInt, "g");
  2940. if (activeField == gValInt.name) {
  2941. activeField = "";
  2942. }
  2943. });
  2944. gValInt.onTextChangedObservable.add(function () {
  2945. if (activeField == gValInt.name) {
  2946. updateInt(gValInt, "g");
  2947. }
  2948. });
  2949. rgbValuesQuadrant.addControl(gValInt, 1, 1);
  2950. bValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2951. bValInt.width = 0.83;
  2952. bValInt.height = 0.72;
  2953. bValInt.name = "bIntField";
  2954. bValInt.fontSize = buttonFontSize;
  2955. bValInt.text = (currentColor.b * 255).toString();
  2956. bValInt.color = inputTextColor;
  2957. bValInt.background = inputTextBackgroundColor;
  2958. bValInt.onFocusObservable.add(function () {
  2959. activeField = bValInt.name;
  2960. lastVal = bValInt.text;
  2961. editSwatches(false);
  2962. });
  2963. bValInt.onBlurObservable.add(function () {
  2964. if (bValInt.text == "") {
  2965. bValInt.text = "0";
  2966. }
  2967. updateInt(bValInt, "b");
  2968. if (activeField == bValInt.name) {
  2969. activeField = "";
  2970. }
  2971. });
  2972. bValInt.onTextChangedObservable.add(function () {
  2973. if (activeField == bValInt.name) {
  2974. updateInt(bValInt, "b");
  2975. }
  2976. });
  2977. rgbValuesQuadrant.addControl(bValInt, 2, 1);
  2978. rValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2979. rValDec.width = 0.95;
  2980. rValDec.height = 0.72;
  2981. rValDec.name = "rDecField";
  2982. rValDec.fontSize = buttonFontSize;
  2983. rValDec.text = currentColor.r.toString();
  2984. rValDec.color = inputTextColor;
  2985. rValDec.background = inputTextBackgroundColor;
  2986. rValDec.onFocusObservable.add(function () {
  2987. activeField = rValDec.name;
  2988. lastVal = rValDec.text;
  2989. editSwatches(false);
  2990. });
  2991. rValDec.onBlurObservable.add(function () {
  2992. if (parseFloat(rValDec.text) == 0 || rValDec.text == "") {
  2993. rValDec.text = "0";
  2994. updateFloat(rValDec, "r");
  2995. }
  2996. if (activeField == rValDec.name) {
  2997. activeField = "";
  2998. }
  2999. });
  3000. rValDec.onTextChangedObservable.add(function () {
  3001. if (activeField == rValDec.name) {
  3002. updateFloat(rValDec, "r");
  3003. }
  3004. });
  3005. rgbValuesQuadrant.addControl(rValDec, 0, 2);
  3006. gValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3007. gValDec.width = 0.95;
  3008. gValDec.height = 0.72;
  3009. gValDec.name = "gDecField";
  3010. gValDec.fontSize = buttonFontSize;
  3011. gValDec.text = currentColor.g.toString();
  3012. gValDec.color = inputTextColor;
  3013. gValDec.background = inputTextBackgroundColor;
  3014. gValDec.onFocusObservable.add(function () {
  3015. activeField = gValDec.name;
  3016. lastVal = gValDec.text;
  3017. editSwatches(false);
  3018. });
  3019. gValDec.onBlurObservable.add(function () {
  3020. if (parseFloat(gValDec.text) == 0 || gValDec.text == "") {
  3021. gValDec.text = "0";
  3022. updateFloat(gValDec, "g");
  3023. }
  3024. if (activeField == gValDec.name) {
  3025. activeField = "";
  3026. }
  3027. });
  3028. gValDec.onTextChangedObservable.add(function () {
  3029. if (activeField == gValDec.name) {
  3030. updateFloat(gValDec, "g");
  3031. }
  3032. });
  3033. rgbValuesQuadrant.addControl(gValDec, 1, 2);
  3034. bValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3035. bValDec.width = 0.95;
  3036. bValDec.height = 0.72;
  3037. bValDec.name = "bDecField";
  3038. bValDec.fontSize = buttonFontSize;
  3039. bValDec.text = currentColor.b.toString();
  3040. bValDec.color = inputTextColor;
  3041. bValDec.background = inputTextBackgroundColor;
  3042. bValDec.onFocusObservable.add(function () {
  3043. activeField = bValDec.name;
  3044. lastVal = bValDec.text;
  3045. editSwatches(false);
  3046. });
  3047. bValDec.onBlurObservable.add(function () {
  3048. if (parseFloat(bValDec.text) == 0 || bValDec.text == "") {
  3049. bValDec.text = "0";
  3050. updateFloat(bValDec, "b");
  3051. }
  3052. if (activeField == bValDec.name) {
  3053. activeField = "";
  3054. }
  3055. });
  3056. bValDec.onTextChangedObservable.add(function () {
  3057. if (activeField == bValDec.name) {
  3058. updateFloat(bValDec, "b");
  3059. }
  3060. });
  3061. rgbValuesQuadrant.addControl(bValDec, 2, 2);
  3062. // Hex value input
  3063. var hexValueQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3064. hexValueQuadrant.name = "Hex Value";
  3065. hexValueQuadrant.width = 0.82;
  3066. hexValueQuadrant.addRowDefinition(1.0, false);
  3067. hexValueQuadrant.addColumnDefinition(0.1, false);
  3068. hexValueQuadrant.addColumnDefinition(0.9, false);
  3069. pickerColorValues.addControl(hexValueQuadrant, 2, 0);
  3070. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  3071. labelText.text = "#";
  3072. labelText.color = buttonColor;
  3073. labelText.fontSize = buttonFontSize;
  3074. hexValueQuadrant.addControl(labelText, 0, 0);
  3075. hexVal = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3076. hexVal.width = 0.96;
  3077. hexVal.height = 0.72;
  3078. hexVal.name = "hexField";
  3079. hexVal.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  3080. hexVal.fontSize = buttonFontSize;
  3081. var minusPound = options.lastColor.split("#");
  3082. hexVal.text = minusPound[1];
  3083. hexVal.color = inputTextColor;
  3084. hexVal.background = inputTextBackgroundColor;
  3085. hexVal.onFocusObservable.add(function () {
  3086. activeField = hexVal.name;
  3087. lastVal = hexVal.text;
  3088. editSwatches(false);
  3089. });
  3090. hexVal.onBlurObservable.add(function () {
  3091. if (hexVal.text.length == 3) {
  3092. var val = hexVal.text.split("");
  3093. hexVal.text = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3094. }
  3095. if (hexVal.text == "") {
  3096. hexVal.text = "000000";
  3097. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(hexVal.text), "b");
  3098. }
  3099. if (activeField == hexVal.name) {
  3100. activeField = "";
  3101. }
  3102. });
  3103. hexVal.onTextChangedObservable.add(function () {
  3104. var newHexValue = hexVal.text;
  3105. var checkHex = /[^0-9A-F]/i.test(newHexValue);
  3106. if ((hexVal.text.length > 6 || checkHex) && activeField == hexVal.name) {
  3107. hexVal.text = lastVal;
  3108. }
  3109. else {
  3110. if (hexVal.text.length < 6) {
  3111. var leadingZero = 6 - hexVal.text.length;
  3112. for (var i = 0; i < leadingZero; i++) {
  3113. newHexValue = "0" + newHexValue;
  3114. }
  3115. }
  3116. if (hexVal.text.length == 3) {
  3117. var val = hexVal.text.split("");
  3118. newHexValue = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3119. }
  3120. newHexValue = "#" + newHexValue;
  3121. if (activeField == hexVal.name) {
  3122. lastVal = hexVal.text;
  3123. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newHexValue), hexVal.name);
  3124. }
  3125. }
  3126. });
  3127. hexValueQuadrant.addControl(hexVal, 0, 1);
  3128. if (options.savedColors && options.savedColors.length > 0) {
  3129. updateSwatches("", butSave);
  3130. }
  3131. });
  3132. };
  3133. ColorPicker._Epsilon = 0.000001;
  3134. return ColorPicker;
  3135. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3136. /***/ }),
  3137. /***/ "./2D/controls/container.ts":
  3138. /*!**********************************!*\
  3139. !*** ./2D/controls/container.ts ***!
  3140. \**********************************/
  3141. /*! exports provided: Container */
  3142. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3143. "use strict";
  3144. __webpack_require__.r(__webpack_exports__);
  3145. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return Container; });
  3146. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  3147. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Misc/observable");
  3148. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__);
  3149. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  3150. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3151. /**
  3152. * Root class for 2D containers
  3153. * @see http://doc.babylonjs.com/how_to/gui#containers
  3154. */
  3155. var Container = /** @class */ (function (_super) {
  3156. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Container, _super);
  3157. /**
  3158. * Creates a new Container
  3159. * @param name defines the name of the container
  3160. */
  3161. function Container(name) {
  3162. var _this = _super.call(this, name) || this;
  3163. _this.name = name;
  3164. /** @hidden */
  3165. _this._children = new Array();
  3166. /** @hidden */
  3167. _this._measureForChildren = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3168. /** @hidden */
  3169. _this._background = "";
  3170. /** @hidden */
  3171. _this._adaptWidthToChildren = false;
  3172. /** @hidden */
  3173. _this._adaptHeightToChildren = false;
  3174. return _this;
  3175. }
  3176. Object.defineProperty(Container.prototype, "adaptHeightToChildren", {
  3177. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  3178. get: function () {
  3179. return this._adaptHeightToChildren;
  3180. },
  3181. set: function (value) {
  3182. if (this._adaptHeightToChildren === value) {
  3183. return;
  3184. }
  3185. this._adaptHeightToChildren = value;
  3186. if (value) {
  3187. this.height = "100%";
  3188. }
  3189. this._markAsDirty();
  3190. },
  3191. enumerable: true,
  3192. configurable: true
  3193. });
  3194. Object.defineProperty(Container.prototype, "adaptWidthToChildren", {
  3195. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  3196. get: function () {
  3197. return this._adaptWidthToChildren;
  3198. },
  3199. set: function (value) {
  3200. if (this._adaptWidthToChildren === value) {
  3201. return;
  3202. }
  3203. this._adaptWidthToChildren = value;
  3204. if (value) {
  3205. this.width = "100%";
  3206. }
  3207. this._markAsDirty();
  3208. },
  3209. enumerable: true,
  3210. configurable: true
  3211. });
  3212. Object.defineProperty(Container.prototype, "background", {
  3213. /** Gets or sets background color */
  3214. get: function () {
  3215. return this._background;
  3216. },
  3217. set: function (value) {
  3218. if (this._background === value) {
  3219. return;
  3220. }
  3221. this._background = value;
  3222. this._markAsDirty();
  3223. },
  3224. enumerable: true,
  3225. configurable: true
  3226. });
  3227. Object.defineProperty(Container.prototype, "children", {
  3228. /** Gets the list of children */
  3229. get: function () {
  3230. return this._children;
  3231. },
  3232. enumerable: true,
  3233. configurable: true
  3234. });
  3235. Container.prototype._getTypeName = function () {
  3236. return "Container";
  3237. };
  3238. Container.prototype._flagDescendantsAsMatrixDirty = function () {
  3239. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3240. var child = _a[_i];
  3241. child._markMatrixAsDirty();
  3242. }
  3243. };
  3244. /**
  3245. * Gets a child using its name
  3246. * @param name defines the child name to look for
  3247. * @returns the child control if found
  3248. */
  3249. Container.prototype.getChildByName = function (name) {
  3250. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3251. var child = _a[_i];
  3252. if (child.name === name) {
  3253. return child;
  3254. }
  3255. }
  3256. return null;
  3257. };
  3258. /**
  3259. * Gets a child using its type and its name
  3260. * @param name defines the child name to look for
  3261. * @param type defines the child type to look for
  3262. * @returns the child control if found
  3263. */
  3264. Container.prototype.getChildByType = function (name, type) {
  3265. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3266. var child = _a[_i];
  3267. if (child.typeName === type) {
  3268. return child;
  3269. }
  3270. }
  3271. return null;
  3272. };
  3273. /**
  3274. * Search for a specific control in children
  3275. * @param control defines the control to look for
  3276. * @returns true if the control is in child list
  3277. */
  3278. Container.prototype.containsControl = function (control) {
  3279. return this.children.indexOf(control) !== -1;
  3280. };
  3281. /**
  3282. * Adds a new control to the current container
  3283. * @param control defines the control to add
  3284. * @returns the current container
  3285. */
  3286. Container.prototype.addControl = function (control) {
  3287. if (!control) {
  3288. return this;
  3289. }
  3290. var index = this._children.indexOf(control);
  3291. if (index !== -1) {
  3292. return this;
  3293. }
  3294. control._link(this._host);
  3295. control._markAllAsDirty();
  3296. this._reOrderControl(control);
  3297. this._markAsDirty();
  3298. return this;
  3299. };
  3300. /**
  3301. * Removes all controls from the current container
  3302. * @returns the current container
  3303. */
  3304. Container.prototype.clearControls = function () {
  3305. var children = this.children.slice();
  3306. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  3307. var child = children_1[_i];
  3308. this.removeControl(child);
  3309. }
  3310. return this;
  3311. };
  3312. /**
  3313. * Removes a control from the current container
  3314. * @param control defines the control to remove
  3315. * @returns the current container
  3316. */
  3317. Container.prototype.removeControl = function (control) {
  3318. var index = this._children.indexOf(control);
  3319. if (index !== -1) {
  3320. this._children.splice(index, 1);
  3321. control.parent = null;
  3322. }
  3323. control.linkWithMesh(null);
  3324. if (this._host) {
  3325. this._host._cleanControlAfterRemoval(control);
  3326. }
  3327. this._markAsDirty();
  3328. return this;
  3329. };
  3330. /** @hidden */
  3331. Container.prototype._reOrderControl = function (control) {
  3332. this.removeControl(control);
  3333. for (var index = 0; index < this._children.length; index++) {
  3334. if (this._children[index].zIndex > control.zIndex) {
  3335. this._children.splice(index, 0, control);
  3336. return;
  3337. }
  3338. }
  3339. this._children.push(control);
  3340. control.parent = this;
  3341. this._markAsDirty();
  3342. };
  3343. /** @hidden */
  3344. Container.prototype._offsetLeft = function (offset) {
  3345. _super.prototype._offsetLeft.call(this, offset);
  3346. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3347. var child = _a[_i];
  3348. child._offsetLeft(offset);
  3349. }
  3350. };
  3351. /** @hidden */
  3352. Container.prototype._offsetTop = function (offset) {
  3353. _super.prototype._offsetTop.call(this, offset);
  3354. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3355. var child = _a[_i];
  3356. child._offsetTop(offset);
  3357. }
  3358. };
  3359. /** @hidden */
  3360. Container.prototype._markAllAsDirty = function () {
  3361. _super.prototype._markAllAsDirty.call(this);
  3362. for (var index = 0; index < this._children.length; index++) {
  3363. this._children[index]._markAllAsDirty();
  3364. }
  3365. };
  3366. /** @hidden */
  3367. Container.prototype._localDraw = function (context) {
  3368. if (this._background) {
  3369. context.save();
  3370. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  3371. context.shadowColor = this.shadowColor;
  3372. context.shadowBlur = this.shadowBlur;
  3373. context.shadowOffsetX = this.shadowOffsetX;
  3374. context.shadowOffsetY = this.shadowOffsetY;
  3375. }
  3376. context.fillStyle = this._background;
  3377. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  3378. context.restore();
  3379. }
  3380. };
  3381. /** @hidden */
  3382. Container.prototype._link = function (host) {
  3383. _super.prototype._link.call(this, host);
  3384. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3385. var child = _a[_i];
  3386. child._link(host);
  3387. }
  3388. };
  3389. /** @hidden */
  3390. Container.prototype._beforeLayout = function () {
  3391. // Do nothing
  3392. };
  3393. /** @hidden */
  3394. Container.prototype._processMeasures = function (parentMeasure, context) {
  3395. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  3396. _super.prototype._processMeasures.call(this, parentMeasure, context);
  3397. this._evaluateClippingState(parentMeasure);
  3398. }
  3399. };
  3400. /** @hidden */
  3401. Container.prototype._layout = function (parentMeasure, context) {
  3402. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  3403. return false;
  3404. }
  3405. if (this._isDirty) {
  3406. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  3407. }
  3408. var rebuildCount = 0;
  3409. context.save();
  3410. this._applyStates(context);
  3411. this._beforeLayout();
  3412. do {
  3413. var computedWidth = -1;
  3414. var computedHeight = -1;
  3415. this._rebuildLayout = false;
  3416. this._processMeasures(parentMeasure, context);
  3417. if (!this._isClipped) {
  3418. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3419. var child = _a[_i];
  3420. child._tempParentMeasure.copyFrom(this._measureForChildren);
  3421. if (child._layout(this._measureForChildren, context)) {
  3422. if (this.adaptWidthToChildren && child._width.isPixel) {
  3423. computedWidth = Math.max(computedWidth, child._currentMeasure.width);
  3424. }
  3425. if (this.adaptHeightToChildren && child._height.isPixel) {
  3426. computedHeight = Math.max(computedHeight, child._currentMeasure.height);
  3427. }
  3428. }
  3429. }
  3430. if (this.adaptWidthToChildren && computedWidth >= 0) {
  3431. if (this.width !== computedWidth + "px") {
  3432. this.width = computedWidth + "px";
  3433. this._rebuildLayout = true;
  3434. }
  3435. }
  3436. if (this.adaptHeightToChildren && computedHeight >= 0) {
  3437. if (this.height !== computedHeight + "px") {
  3438. this.height = computedHeight + "px";
  3439. this._rebuildLayout = true;
  3440. }
  3441. }
  3442. this._postMeasure();
  3443. }
  3444. rebuildCount++;
  3445. } while (this._rebuildLayout && rebuildCount < 3);
  3446. if (rebuildCount >= 3) {
  3447. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Layout cycle detected in GUI (Container name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  3448. }
  3449. context.restore();
  3450. if (this._isDirty) {
  3451. this.invalidateRect();
  3452. this._isDirty = false;
  3453. }
  3454. return true;
  3455. };
  3456. Container.prototype._postMeasure = function () {
  3457. // Do nothing by default
  3458. };
  3459. /** @hidden */
  3460. Container.prototype._draw = function (context, invalidatedRectangle) {
  3461. this._localDraw(context);
  3462. if (this.clipChildren) {
  3463. this._clipForChildren(context);
  3464. }
  3465. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3466. var child = _a[_i];
  3467. // Only redraw parts of the screen that are invalidated
  3468. if (invalidatedRectangle) {
  3469. if (!child._intersectsRect(invalidatedRectangle)) {
  3470. continue;
  3471. }
  3472. }
  3473. child._render(context, invalidatedRectangle);
  3474. }
  3475. };
  3476. /** @hidden */
  3477. Container.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  3478. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  3479. if (!this.children) {
  3480. return;
  3481. }
  3482. for (var index = 0; index < this.children.length; index++) {
  3483. var item = this.children[index];
  3484. if (!predicate || predicate(item)) {
  3485. results.push(item);
  3486. }
  3487. if (!directDescendantsOnly) {
  3488. item._getDescendants(results, false, predicate);
  3489. }
  3490. }
  3491. };
  3492. /** @hidden */
  3493. Container.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  3494. if (!this.isVisible || this.notRenderable) {
  3495. return false;
  3496. }
  3497. if (!_super.prototype.contains.call(this, x, y)) {
  3498. return false;
  3499. }
  3500. // Checking backwards to pick closest first
  3501. for (var index = this._children.length - 1; index >= 0; index--) {
  3502. var child = this._children[index];
  3503. if (child._processPicking(x, y, type, pointerId, buttonIndex)) {
  3504. if (child.hoverCursor) {
  3505. this._host._changeCursor(child.hoverCursor);
  3506. }
  3507. return true;
  3508. }
  3509. }
  3510. if (!this.isHitTestVisible) {
  3511. return false;
  3512. }
  3513. return this._processObservables(type, x, y, pointerId, buttonIndex);
  3514. };
  3515. /** @hidden */
  3516. Container.prototype._additionalProcessing = function (parentMeasure, context) {
  3517. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  3518. this._measureForChildren.copyFrom(this._currentMeasure);
  3519. };
  3520. /** Releases associated resources */
  3521. Container.prototype.dispose = function () {
  3522. _super.prototype.dispose.call(this);
  3523. for (var index = this.children.length - 1; index >= 0; index--) {
  3524. this.children[index].dispose();
  3525. }
  3526. };
  3527. return Container;
  3528. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3529. /***/ }),
  3530. /***/ "./2D/controls/control.ts":
  3531. /*!********************************!*\
  3532. !*** ./2D/controls/control.ts ***!
  3533. \********************************/
  3534. /*! exports provided: Control */
  3535. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3536. "use strict";
  3537. __webpack_require__.r(__webpack_exports__);
  3538. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return Control; });
  3539. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  3540. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  3541. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  3542. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3543. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../math2D */ "./2D/math2D.ts");
  3544. /**
  3545. * Root class used for all 2D controls
  3546. * @see http://doc.babylonjs.com/how_to/gui#controls
  3547. */
  3548. var Control = /** @class */ (function () {
  3549. // Functions
  3550. /**
  3551. * Creates a new control
  3552. * @param name defines the name of the control
  3553. */
  3554. function Control(
  3555. /** defines the name of the control */
  3556. name) {
  3557. this.name = name;
  3558. this._alpha = 1;
  3559. this._alphaSet = false;
  3560. this._zIndex = 0;
  3561. /** @hidden */
  3562. this._currentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3563. this._fontFamily = "Arial";
  3564. this._fontStyle = "";
  3565. this._fontWeight = "";
  3566. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  3567. /** @hidden */
  3568. this._width = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3569. /** @hidden */
  3570. this._height = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3571. this._color = "";
  3572. this._style = null;
  3573. /** @hidden */
  3574. this._horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
  3575. /** @hidden */
  3576. this._verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
  3577. /** @hidden */
  3578. this._isDirty = true;
  3579. /** @hidden */
  3580. this._wasDirty = false;
  3581. /** @hidden */
  3582. this._tempParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3583. /** @hidden */
  3584. this._prevCurrentMeasureTransformedIntoGlobalSpace = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3585. /** @hidden */
  3586. this._cachedParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3587. this._paddingLeft = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3588. this._paddingRight = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3589. this._paddingTop = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3590. this._paddingBottom = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3591. /** @hidden */
  3592. this._left = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3593. /** @hidden */
  3594. this._top = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3595. this._scaleX = 1.0;
  3596. this._scaleY = 1.0;
  3597. this._rotation = 0;
  3598. this._transformCenterX = 0.5;
  3599. this._transformCenterY = 0.5;
  3600. /** @hidden */
  3601. this._transformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3602. /** @hidden */
  3603. this._invertTransformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3604. /** @hidden */
  3605. this._transformedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3606. this._isMatrixDirty = true;
  3607. this._isVisible = true;
  3608. this._isHighlighted = false;
  3609. this._fontSet = false;
  3610. this._dummyVector2 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3611. this._downCount = 0;
  3612. this._enterCount = -1;
  3613. this._doNotRender = false;
  3614. this._downPointerIds = {};
  3615. this._isEnabled = true;
  3616. this._disabledColor = "#9a9a9a";
  3617. /** @hidden */
  3618. this._rebuildLayout = false;
  3619. /** @hidden */
  3620. this._isClipped = false;
  3621. /**
  3622. * Gets or sets an object used to store user defined information for the node
  3623. */
  3624. this.metadata = null;
  3625. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  3626. this.isHitTestVisible = true;
  3627. /** Gets or sets a boolean indicating if the control can block pointer events */
  3628. this.isPointerBlocker = false;
  3629. /** Gets or sets a boolean indicating if the control can be focusable */
  3630. this.isFocusInvisible = false;
  3631. /** Gets or sets a boolean indicating if the children are clipped to the current control bounds */
  3632. this.clipChildren = true;
  3633. /**
  3634. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  3635. */
  3636. this.useBitmapCache = false;
  3637. this._shadowOffsetX = 0;
  3638. this._shadowOffsetY = 0;
  3639. this._shadowBlur = 0;
  3640. this._shadowColor = 'black';
  3641. /** Gets or sets the cursor to use when the control is hovered */
  3642. this.hoverCursor = "";
  3643. /** @hidden */
  3644. this._linkOffsetX = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3645. /** @hidden */
  3646. this._linkOffsetY = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3647. /**
  3648. * An event triggered when the pointer move over the control.
  3649. */
  3650. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3651. /**
  3652. * An event triggered when the pointer move out of the control.
  3653. */
  3654. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3655. /**
  3656. * An event triggered when the pointer taps the control
  3657. */
  3658. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3659. /**
  3660. * An event triggered when pointer up
  3661. */
  3662. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3663. /**
  3664. * An event triggered when a control is clicked on
  3665. */
  3666. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3667. /**
  3668. * An event triggered when pointer enters the control
  3669. */
  3670. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3671. /**
  3672. * An event triggered when the control is marked as dirty
  3673. */
  3674. this.onDirtyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3675. /**
  3676. * An event triggered before drawing the control
  3677. */
  3678. this.onBeforeDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3679. /**
  3680. * An event triggered after the control was drawn
  3681. */
  3682. this.onAfterDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3683. this._tmpMeasureA = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  3684. }
  3685. Object.defineProperty(Control.prototype, "shadowOffsetX", {
  3686. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  3687. get: function () {
  3688. return this._shadowOffsetX;
  3689. },
  3690. set: function (value) {
  3691. if (this._shadowOffsetX === value) {
  3692. return;
  3693. }
  3694. this._shadowOffsetX = value;
  3695. this._markAsDirty();
  3696. },
  3697. enumerable: true,
  3698. configurable: true
  3699. });
  3700. Object.defineProperty(Control.prototype, "shadowOffsetY", {
  3701. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  3702. get: function () {
  3703. return this._shadowOffsetY;
  3704. },
  3705. set: function (value) {
  3706. if (this._shadowOffsetY === value) {
  3707. return;
  3708. }
  3709. this._shadowOffsetY = value;
  3710. this._markAsDirty();
  3711. },
  3712. enumerable: true,
  3713. configurable: true
  3714. });
  3715. Object.defineProperty(Control.prototype, "shadowBlur", {
  3716. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  3717. get: function () {
  3718. return this._shadowBlur;
  3719. },
  3720. set: function (value) {
  3721. if (this._shadowBlur === value) {
  3722. return;
  3723. }
  3724. this._shadowBlur = value;
  3725. this._markAsDirty();
  3726. },
  3727. enumerable: true,
  3728. configurable: true
  3729. });
  3730. Object.defineProperty(Control.prototype, "shadowColor", {
  3731. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  3732. get: function () {
  3733. return this._shadowColor;
  3734. },
  3735. set: function (value) {
  3736. if (this._shadowColor === value) {
  3737. return;
  3738. }
  3739. this._shadowColor = value;
  3740. this._markAsDirty();
  3741. },
  3742. enumerable: true,
  3743. configurable: true
  3744. });
  3745. Object.defineProperty(Control.prototype, "typeName", {
  3746. // Properties
  3747. /** Gets the control type name */
  3748. get: function () {
  3749. return this._getTypeName();
  3750. },
  3751. enumerable: true,
  3752. configurable: true
  3753. });
  3754. /**
  3755. * Get the current class name of the control.
  3756. * @returns current class name
  3757. */
  3758. Control.prototype.getClassName = function () {
  3759. return this._getTypeName();
  3760. };
  3761. Object.defineProperty(Control.prototype, "host", {
  3762. /**
  3763. * Get the hosting AdvancedDynamicTexture
  3764. */
  3765. get: function () {
  3766. return this._host;
  3767. },
  3768. enumerable: true,
  3769. configurable: true
  3770. });
  3771. Object.defineProperty(Control.prototype, "fontOffset", {
  3772. /** Gets or set information about font offsets (used to render and align text) */
  3773. get: function () {
  3774. return this._fontOffset;
  3775. },
  3776. set: function (offset) {
  3777. this._fontOffset = offset;
  3778. },
  3779. enumerable: true,
  3780. configurable: true
  3781. });
  3782. Object.defineProperty(Control.prototype, "alpha", {
  3783. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  3784. get: function () {
  3785. return this._alpha;
  3786. },
  3787. set: function (value) {
  3788. if (this._alpha === value) {
  3789. return;
  3790. }
  3791. this._alphaSet = true;
  3792. this._alpha = value;
  3793. this._markAsDirty();
  3794. },
  3795. enumerable: true,
  3796. configurable: true
  3797. });
  3798. Object.defineProperty(Control.prototype, "isHighlighted", {
  3799. /**
  3800. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  3801. */
  3802. get: function () {
  3803. return this._isHighlighted;
  3804. },
  3805. set: function (value) {
  3806. if (this._isHighlighted === value) {
  3807. return;
  3808. }
  3809. this._isHighlighted = value;
  3810. this._markAsDirty();
  3811. },
  3812. enumerable: true,
  3813. configurable: true
  3814. });
  3815. Object.defineProperty(Control.prototype, "scaleX", {
  3816. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  3817. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3818. */
  3819. get: function () {
  3820. return this._scaleX;
  3821. },
  3822. set: function (value) {
  3823. if (this._scaleX === value) {
  3824. return;
  3825. }
  3826. this._scaleX = value;
  3827. this._markAsDirty();
  3828. this._markMatrixAsDirty();
  3829. },
  3830. enumerable: true,
  3831. configurable: true
  3832. });
  3833. Object.defineProperty(Control.prototype, "scaleY", {
  3834. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  3835. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3836. */
  3837. get: function () {
  3838. return this._scaleY;
  3839. },
  3840. set: function (value) {
  3841. if (this._scaleY === value) {
  3842. return;
  3843. }
  3844. this._scaleY = value;
  3845. this._markAsDirty();
  3846. this._markMatrixAsDirty();
  3847. },
  3848. enumerable: true,
  3849. configurable: true
  3850. });
  3851. Object.defineProperty(Control.prototype, "rotation", {
  3852. /** Gets or sets the rotation angle (0 by default)
  3853. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3854. */
  3855. get: function () {
  3856. return this._rotation;
  3857. },
  3858. set: function (value) {
  3859. if (this._rotation === value) {
  3860. return;
  3861. }
  3862. this._rotation = value;
  3863. this._markAsDirty();
  3864. this._markMatrixAsDirty();
  3865. },
  3866. enumerable: true,
  3867. configurable: true
  3868. });
  3869. Object.defineProperty(Control.prototype, "transformCenterY", {
  3870. /** Gets or sets the transformation center on Y axis (0 by default)
  3871. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3872. */
  3873. get: function () {
  3874. return this._transformCenterY;
  3875. },
  3876. set: function (value) {
  3877. if (this._transformCenterY === value) {
  3878. return;
  3879. }
  3880. this._transformCenterY = value;
  3881. this._markAsDirty();
  3882. this._markMatrixAsDirty();
  3883. },
  3884. enumerable: true,
  3885. configurable: true
  3886. });
  3887. Object.defineProperty(Control.prototype, "transformCenterX", {
  3888. /** Gets or sets the transformation center on X axis (0 by default)
  3889. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3890. */
  3891. get: function () {
  3892. return this._transformCenterX;
  3893. },
  3894. set: function (value) {
  3895. if (this._transformCenterX === value) {
  3896. return;
  3897. }
  3898. this._transformCenterX = value;
  3899. this._markAsDirty();
  3900. this._markMatrixAsDirty();
  3901. },
  3902. enumerable: true,
  3903. configurable: true
  3904. });
  3905. Object.defineProperty(Control.prototype, "horizontalAlignment", {
  3906. /**
  3907. * Gets or sets the horizontal alignment
  3908. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3909. */
  3910. get: function () {
  3911. return this._horizontalAlignment;
  3912. },
  3913. set: function (value) {
  3914. if (this._horizontalAlignment === value) {
  3915. return;
  3916. }
  3917. this._horizontalAlignment = value;
  3918. this._markAsDirty();
  3919. },
  3920. enumerable: true,
  3921. configurable: true
  3922. });
  3923. Object.defineProperty(Control.prototype, "verticalAlignment", {
  3924. /**
  3925. * Gets or sets the vertical alignment
  3926. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3927. */
  3928. get: function () {
  3929. return this._verticalAlignment;
  3930. },
  3931. set: function (value) {
  3932. if (this._verticalAlignment === value) {
  3933. return;
  3934. }
  3935. this._verticalAlignment = value;
  3936. this._markAsDirty();
  3937. },
  3938. enumerable: true,
  3939. configurable: true
  3940. });
  3941. Object.defineProperty(Control.prototype, "width", {
  3942. /**
  3943. * Gets or sets control width
  3944. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3945. */
  3946. get: function () {
  3947. return this._width.toString(this._host);
  3948. },
  3949. set: function (value) {
  3950. if (this._width.toString(this._host) === value) {
  3951. return;
  3952. }
  3953. if (this._width.fromString(value)) {
  3954. this._markAsDirty();
  3955. }
  3956. },
  3957. enumerable: true,
  3958. configurable: true
  3959. });
  3960. Object.defineProperty(Control.prototype, "widthInPixels", {
  3961. /**
  3962. * Gets control width in pixel
  3963. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3964. */
  3965. get: function () {
  3966. return this._width.getValueInPixel(this._host, this._cachedParentMeasure.width);
  3967. },
  3968. enumerable: true,
  3969. configurable: true
  3970. });
  3971. Object.defineProperty(Control.prototype, "height", {
  3972. /**
  3973. * Gets or sets control height
  3974. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3975. */
  3976. get: function () {
  3977. return this._height.toString(this._host);
  3978. },
  3979. set: function (value) {
  3980. if (this._height.toString(this._host) === value) {
  3981. return;
  3982. }
  3983. if (this._height.fromString(value)) {
  3984. this._markAsDirty();
  3985. }
  3986. },
  3987. enumerable: true,
  3988. configurable: true
  3989. });
  3990. Object.defineProperty(Control.prototype, "heightInPixels", {
  3991. /**
  3992. * Gets control height in pixel
  3993. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3994. */
  3995. get: function () {
  3996. return this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  3997. },
  3998. enumerable: true,
  3999. configurable: true
  4000. });
  4001. Object.defineProperty(Control.prototype, "fontFamily", {
  4002. /** Gets or set font family */
  4003. get: function () {
  4004. if (!this._fontSet) {
  4005. return "";
  4006. }
  4007. return this._fontFamily;
  4008. },
  4009. set: function (value) {
  4010. if (this._fontFamily === value) {
  4011. return;
  4012. }
  4013. this._fontFamily = value;
  4014. this._resetFontCache();
  4015. },
  4016. enumerable: true,
  4017. configurable: true
  4018. });
  4019. Object.defineProperty(Control.prototype, "fontStyle", {
  4020. /** Gets or sets font style */
  4021. get: function () {
  4022. return this._fontStyle;
  4023. },
  4024. set: function (value) {
  4025. if (this._fontStyle === value) {
  4026. return;
  4027. }
  4028. this._fontStyle = value;
  4029. this._resetFontCache();
  4030. },
  4031. enumerable: true,
  4032. configurable: true
  4033. });
  4034. Object.defineProperty(Control.prototype, "fontWeight", {
  4035. /** Gets or sets font weight */
  4036. get: function () {
  4037. return this._fontWeight;
  4038. },
  4039. set: function (value) {
  4040. if (this._fontWeight === value) {
  4041. return;
  4042. }
  4043. this._fontWeight = value;
  4044. this._resetFontCache();
  4045. },
  4046. enumerable: true,
  4047. configurable: true
  4048. });
  4049. Object.defineProperty(Control.prototype, "style", {
  4050. /**
  4051. * Gets or sets style
  4052. * @see http://doc.babylonjs.com/how_to/gui#styles
  4053. */
  4054. get: function () {
  4055. return this._style;
  4056. },
  4057. set: function (value) {
  4058. var _this = this;
  4059. if (this._style) {
  4060. this._style.onChangedObservable.remove(this._styleObserver);
  4061. this._styleObserver = null;
  4062. }
  4063. this._style = value;
  4064. if (this._style) {
  4065. this._styleObserver = this._style.onChangedObservable.add(function () {
  4066. _this._markAsDirty();
  4067. _this._resetFontCache();
  4068. });
  4069. }
  4070. this._markAsDirty();
  4071. this._resetFontCache();
  4072. },
  4073. enumerable: true,
  4074. configurable: true
  4075. });
  4076. Object.defineProperty(Control.prototype, "_isFontSizeInPercentage", {
  4077. /** @hidden */
  4078. get: function () {
  4079. return this._fontSize.isPercentage;
  4080. },
  4081. enumerable: true,
  4082. configurable: true
  4083. });
  4084. Object.defineProperty(Control.prototype, "fontSizeInPixels", {
  4085. /** Gets font size in pixels */
  4086. get: function () {
  4087. var fontSizeToUse = this._style ? this._style._fontSize : this._fontSize;
  4088. if (fontSizeToUse.isPixel) {
  4089. return fontSizeToUse.getValue(this._host);
  4090. }
  4091. return fontSizeToUse.getValueInPixel(this._host, this._tempParentMeasure.height || this._cachedParentMeasure.height);
  4092. },
  4093. enumerable: true,
  4094. configurable: true
  4095. });
  4096. Object.defineProperty(Control.prototype, "fontSize", {
  4097. /** Gets or sets font size */
  4098. get: function () {
  4099. return this._fontSize.toString(this._host);
  4100. },
  4101. set: function (value) {
  4102. if (this._fontSize.toString(this._host) === value) {
  4103. return;
  4104. }
  4105. if (this._fontSize.fromString(value)) {
  4106. this._markAsDirty();
  4107. this._resetFontCache();
  4108. }
  4109. },
  4110. enumerable: true,
  4111. configurable: true
  4112. });
  4113. Object.defineProperty(Control.prototype, "color", {
  4114. /** Gets or sets foreground color */
  4115. get: function () {
  4116. return this._color;
  4117. },
  4118. set: function (value) {
  4119. if (this._color === value) {
  4120. return;
  4121. }
  4122. this._color = value;
  4123. this._markAsDirty();
  4124. },
  4125. enumerable: true,
  4126. configurable: true
  4127. });
  4128. Object.defineProperty(Control.prototype, "zIndex", {
  4129. /** Gets or sets z index which is used to reorder controls on the z axis */
  4130. get: function () {
  4131. return this._zIndex;
  4132. },
  4133. set: function (value) {
  4134. if (this.zIndex === value) {
  4135. return;
  4136. }
  4137. this._zIndex = value;
  4138. if (this.parent) {
  4139. this.parent._reOrderControl(this);
  4140. }
  4141. },
  4142. enumerable: true,
  4143. configurable: true
  4144. });
  4145. Object.defineProperty(Control.prototype, "notRenderable", {
  4146. /** Gets or sets a boolean indicating if the control can be rendered */
  4147. get: function () {
  4148. return this._doNotRender;
  4149. },
  4150. set: function (value) {
  4151. if (this._doNotRender === value) {
  4152. return;
  4153. }
  4154. this._doNotRender = value;
  4155. this._markAsDirty();
  4156. },
  4157. enumerable: true,
  4158. configurable: true
  4159. });
  4160. Object.defineProperty(Control.prototype, "isVisible", {
  4161. /** Gets or sets a boolean indicating if the control is visible */
  4162. get: function () {
  4163. return this._isVisible;
  4164. },
  4165. set: function (value) {
  4166. if (this._isVisible === value) {
  4167. return;
  4168. }
  4169. this._isVisible = value;
  4170. this._markAsDirty(true);
  4171. },
  4172. enumerable: true,
  4173. configurable: true
  4174. });
  4175. Object.defineProperty(Control.prototype, "isDirty", {
  4176. /** Gets a boolean indicating that the control needs to update its rendering */
  4177. get: function () {
  4178. return this._isDirty;
  4179. },
  4180. enumerable: true,
  4181. configurable: true
  4182. });
  4183. Object.defineProperty(Control.prototype, "linkedMesh", {
  4184. /**
  4185. * Gets the current linked mesh (or null if none)
  4186. */
  4187. get: function () {
  4188. return this._linkedMesh;
  4189. },
  4190. enumerable: true,
  4191. configurable: true
  4192. });
  4193. Object.defineProperty(Control.prototype, "paddingLeft", {
  4194. /**
  4195. * Gets or sets a value indicating the padding to use on the left of the control
  4196. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4197. */
  4198. get: function () {
  4199. return this._paddingLeft.toString(this._host);
  4200. },
  4201. set: function (value) {
  4202. if (this._paddingLeft.fromString(value)) {
  4203. this._markAsDirty();
  4204. }
  4205. },
  4206. enumerable: true,
  4207. configurable: true
  4208. });
  4209. Object.defineProperty(Control.prototype, "paddingLeftInPixels", {
  4210. /**
  4211. * Gets a value indicating the padding in pixels to use on the left of the control
  4212. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4213. */
  4214. get: function () {
  4215. return this._paddingLeft.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4216. },
  4217. enumerable: true,
  4218. configurable: true
  4219. });
  4220. Object.defineProperty(Control.prototype, "paddingRight", {
  4221. /**
  4222. * Gets or sets a value indicating the padding to use on the right of the control
  4223. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4224. */
  4225. get: function () {
  4226. return this._paddingRight.toString(this._host);
  4227. },
  4228. set: function (value) {
  4229. if (this._paddingRight.fromString(value)) {
  4230. this._markAsDirty();
  4231. }
  4232. },
  4233. enumerable: true,
  4234. configurable: true
  4235. });
  4236. Object.defineProperty(Control.prototype, "paddingRightInPixels", {
  4237. /**
  4238. * Gets a value indicating the padding in pixels to use on the right of the control
  4239. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4240. */
  4241. get: function () {
  4242. return this._paddingRight.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4243. },
  4244. enumerable: true,
  4245. configurable: true
  4246. });
  4247. Object.defineProperty(Control.prototype, "paddingTop", {
  4248. /**
  4249. * Gets or sets a value indicating the padding to use on the top of the control
  4250. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4251. */
  4252. get: function () {
  4253. return this._paddingTop.toString(this._host);
  4254. },
  4255. set: function (value) {
  4256. if (this._paddingTop.fromString(value)) {
  4257. this._markAsDirty();
  4258. }
  4259. },
  4260. enumerable: true,
  4261. configurable: true
  4262. });
  4263. Object.defineProperty(Control.prototype, "paddingTopInPixels", {
  4264. /**
  4265. * Gets a value indicating the padding in pixels to use on the top of the control
  4266. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4267. */
  4268. get: function () {
  4269. return this._paddingTop.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4270. },
  4271. enumerable: true,
  4272. configurable: true
  4273. });
  4274. Object.defineProperty(Control.prototype, "paddingBottom", {
  4275. /**
  4276. * Gets or sets a value indicating the padding to use on the bottom of the control
  4277. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4278. */
  4279. get: function () {
  4280. return this._paddingBottom.toString(this._host);
  4281. },
  4282. set: function (value) {
  4283. if (this._paddingBottom.fromString(value)) {
  4284. this._markAsDirty();
  4285. }
  4286. },
  4287. enumerable: true,
  4288. configurable: true
  4289. });
  4290. Object.defineProperty(Control.prototype, "paddingBottomInPixels", {
  4291. /**
  4292. * Gets a value indicating the padding in pixels to use on the bottom of the control
  4293. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4294. */
  4295. get: function () {
  4296. return this._paddingBottom.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4297. },
  4298. enumerable: true,
  4299. configurable: true
  4300. });
  4301. Object.defineProperty(Control.prototype, "left", {
  4302. /**
  4303. * Gets or sets a value indicating the left coordinate of the control
  4304. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4305. */
  4306. get: function () {
  4307. return this._left.toString(this._host);
  4308. },
  4309. set: function (value) {
  4310. if (this._left.fromString(value)) {
  4311. this._markAsDirty();
  4312. }
  4313. },
  4314. enumerable: true,
  4315. configurable: true
  4316. });
  4317. Object.defineProperty(Control.prototype, "leftInPixels", {
  4318. /**
  4319. * Gets a value indicating the left coordinate in pixels of the control
  4320. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4321. */
  4322. get: function () {
  4323. return this._left.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4324. },
  4325. enumerable: true,
  4326. configurable: true
  4327. });
  4328. Object.defineProperty(Control.prototype, "top", {
  4329. /**
  4330. * Gets or sets a value indicating the top coordinate of the control
  4331. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4332. */
  4333. get: function () {
  4334. return this._top.toString(this._host);
  4335. },
  4336. set: function (value) {
  4337. if (this._top.fromString(value)) {
  4338. this._markAsDirty();
  4339. }
  4340. },
  4341. enumerable: true,
  4342. configurable: true
  4343. });
  4344. Object.defineProperty(Control.prototype, "topInPixels", {
  4345. /**
  4346. * Gets a value indicating the top coordinate in pixels of the control
  4347. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4348. */
  4349. get: function () {
  4350. return this._top.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4351. },
  4352. enumerable: true,
  4353. configurable: true
  4354. });
  4355. Object.defineProperty(Control.prototype, "linkOffsetX", {
  4356. /**
  4357. * Gets or sets a value indicating the offset on X axis to the linked mesh
  4358. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4359. */
  4360. get: function () {
  4361. return this._linkOffsetX.toString(this._host);
  4362. },
  4363. set: function (value) {
  4364. if (this._linkOffsetX.fromString(value)) {
  4365. this._markAsDirty();
  4366. }
  4367. },
  4368. enumerable: true,
  4369. configurable: true
  4370. });
  4371. Object.defineProperty(Control.prototype, "linkOffsetXInPixels", {
  4372. /**
  4373. * Gets a value indicating the offset in pixels on X axis to the linked mesh
  4374. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4375. */
  4376. get: function () {
  4377. return this._linkOffsetX.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4378. },
  4379. enumerable: true,
  4380. configurable: true
  4381. });
  4382. Object.defineProperty(Control.prototype, "linkOffsetY", {
  4383. /**
  4384. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  4385. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4386. */
  4387. get: function () {
  4388. return this._linkOffsetY.toString(this._host);
  4389. },
  4390. set: function (value) {
  4391. if (this._linkOffsetY.fromString(value)) {
  4392. this._markAsDirty();
  4393. }
  4394. },
  4395. enumerable: true,
  4396. configurable: true
  4397. });
  4398. Object.defineProperty(Control.prototype, "linkOffsetYInPixels", {
  4399. /**
  4400. * Gets a value indicating the offset in pixels on Y axis to the linked mesh
  4401. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4402. */
  4403. get: function () {
  4404. return this._linkOffsetY.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4405. },
  4406. enumerable: true,
  4407. configurable: true
  4408. });
  4409. Object.defineProperty(Control.prototype, "centerX", {
  4410. /** Gets the center coordinate on X axis */
  4411. get: function () {
  4412. return this._currentMeasure.left + this._currentMeasure.width / 2;
  4413. },
  4414. enumerable: true,
  4415. configurable: true
  4416. });
  4417. Object.defineProperty(Control.prototype, "centerY", {
  4418. /** Gets the center coordinate on Y axis */
  4419. get: function () {
  4420. return this._currentMeasure.top + this._currentMeasure.height / 2;
  4421. },
  4422. enumerable: true,
  4423. configurable: true
  4424. });
  4425. Object.defineProperty(Control.prototype, "isEnabled", {
  4426. /** Gets or sets if control is Enabled*/
  4427. get: function () {
  4428. return this._isEnabled;
  4429. },
  4430. set: function (value) {
  4431. if (this._isEnabled === value) {
  4432. return;
  4433. }
  4434. this._isEnabled = value;
  4435. this._markAsDirty();
  4436. },
  4437. enumerable: true,
  4438. configurable: true
  4439. });
  4440. Object.defineProperty(Control.prototype, "disabledColor", {
  4441. /** Gets or sets background color of control if it's disabled*/
  4442. get: function () {
  4443. return this._disabledColor;
  4444. },
  4445. set: function (value) {
  4446. if (this._disabledColor === value) {
  4447. return;
  4448. }
  4449. this._disabledColor = value;
  4450. this._markAsDirty();
  4451. },
  4452. enumerable: true,
  4453. configurable: true
  4454. });
  4455. /** @hidden */
  4456. Control.prototype._getTypeName = function () {
  4457. return "Control";
  4458. };
  4459. /**
  4460. * Gets the first ascendant in the hierarchy of the given type
  4461. * @param className defines the required type
  4462. * @returns the ascendant or null if not found
  4463. */
  4464. Control.prototype.getAscendantOfClass = function (className) {
  4465. if (!this.parent) {
  4466. return null;
  4467. }
  4468. if (this.parent.getClassName() === className) {
  4469. return this.parent;
  4470. }
  4471. return this.parent.getAscendantOfClass(className);
  4472. };
  4473. /** @hidden */
  4474. Control.prototype._resetFontCache = function () {
  4475. this._fontSet = true;
  4476. this._markAsDirty();
  4477. };
  4478. /**
  4479. * Determines if a container is an ascendant of the current control
  4480. * @param container defines the container to look for
  4481. * @returns true if the container is one of the ascendant of the control
  4482. */
  4483. Control.prototype.isAscendant = function (container) {
  4484. if (!this.parent) {
  4485. return false;
  4486. }
  4487. if (this.parent === container) {
  4488. return true;
  4489. }
  4490. return this.parent.isAscendant(container);
  4491. };
  4492. /**
  4493. * Gets coordinates in local control space
  4494. * @param globalCoordinates defines the coordinates to transform
  4495. * @returns the new coordinates in local space
  4496. */
  4497. Control.prototype.getLocalCoordinates = function (globalCoordinates) {
  4498. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4499. this.getLocalCoordinatesToRef(globalCoordinates, result);
  4500. return result;
  4501. };
  4502. /**
  4503. * Gets coordinates in local control space
  4504. * @param globalCoordinates defines the coordinates to transform
  4505. * @param result defines the target vector2 where to store the result
  4506. * @returns the current control
  4507. */
  4508. Control.prototype.getLocalCoordinatesToRef = function (globalCoordinates, result) {
  4509. result.x = globalCoordinates.x - this._currentMeasure.left;
  4510. result.y = globalCoordinates.y - this._currentMeasure.top;
  4511. return this;
  4512. };
  4513. /**
  4514. * Gets coordinates in parent local control space
  4515. * @param globalCoordinates defines the coordinates to transform
  4516. * @returns the new coordinates in parent local space
  4517. */
  4518. Control.prototype.getParentLocalCoordinates = function (globalCoordinates) {
  4519. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4520. result.x = globalCoordinates.x - this._cachedParentMeasure.left;
  4521. result.y = globalCoordinates.y - this._cachedParentMeasure.top;
  4522. return result;
  4523. };
  4524. /**
  4525. * Move the current control to a vector3 position projected onto the screen.
  4526. * @param position defines the target position
  4527. * @param scene defines the hosting scene
  4528. */
  4529. Control.prototype.moveToVector3 = function (position, scene) {
  4530. if (!this._host || this.parent !== this._host._rootContainer) {
  4531. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  4532. return;
  4533. }
  4534. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4535. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4536. var globalViewport = this._host._getGlobalViewport(scene);
  4537. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Project(position, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  4538. this._moveToProjectedPosition(projectedPosition);
  4539. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  4540. this.notRenderable = true;
  4541. return;
  4542. }
  4543. this.notRenderable = false;
  4544. };
  4545. /** @hidden */
  4546. Control.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  4547. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  4548. // Do nothing by default
  4549. };
  4550. /**
  4551. * Will return all controls that have this control as ascendant
  4552. * @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
  4553. * @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
  4554. * @return all child controls
  4555. */
  4556. Control.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  4557. var results = new Array();
  4558. this._getDescendants(results, directDescendantsOnly, predicate);
  4559. return results;
  4560. };
  4561. /**
  4562. * Link current control with a target mesh
  4563. * @param mesh defines the mesh to link with
  4564. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4565. */
  4566. Control.prototype.linkWithMesh = function (mesh) {
  4567. if (!this._host || this.parent && this.parent !== this._host._rootContainer) {
  4568. if (mesh) {
  4569. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot link a control to a mesh if the control is not at root level");
  4570. }
  4571. return;
  4572. }
  4573. var index = this._host._linkedControls.indexOf(this);
  4574. if (index !== -1) {
  4575. this._linkedMesh = mesh;
  4576. if (!mesh) {
  4577. this._host._linkedControls.splice(index, 1);
  4578. }
  4579. return;
  4580. }
  4581. else if (!mesh) {
  4582. return;
  4583. }
  4584. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4585. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4586. this._linkedMesh = mesh;
  4587. this._host._linkedControls.push(this);
  4588. };
  4589. /** @hidden */
  4590. Control.prototype._moveToProjectedPosition = function (projectedPosition) {
  4591. var oldLeft = this._left.getValue(this._host);
  4592. var oldTop = this._top.getValue(this._host);
  4593. var newLeft = ((projectedPosition.x + this._linkOffsetX.getValue(this._host)) - this._currentMeasure.width / 2);
  4594. var newTop = ((projectedPosition.y + this._linkOffsetY.getValue(this._host)) - this._currentMeasure.height / 2);
  4595. if (this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling) {
  4596. if (Math.abs(newLeft - oldLeft) < 0.5) {
  4597. newLeft = oldLeft;
  4598. }
  4599. if (Math.abs(newTop - oldTop) < 0.5) {
  4600. newTop = oldTop;
  4601. }
  4602. }
  4603. this.left = newLeft + "px";
  4604. this.top = newTop + "px";
  4605. this._left.ignoreAdaptiveScaling = true;
  4606. this._top.ignoreAdaptiveScaling = true;
  4607. this._markAsDirty();
  4608. };
  4609. /** @hidden */
  4610. Control.prototype._offsetLeft = function (offset) {
  4611. this._isDirty = true;
  4612. this._currentMeasure.left += offset;
  4613. };
  4614. /** @hidden */
  4615. Control.prototype._offsetTop = function (offset) {
  4616. this._isDirty = true;
  4617. this._currentMeasure.top += offset;
  4618. };
  4619. /** @hidden */
  4620. Control.prototype._markMatrixAsDirty = function () {
  4621. this._isMatrixDirty = true;
  4622. this._flagDescendantsAsMatrixDirty();
  4623. };
  4624. /** @hidden */
  4625. Control.prototype._flagDescendantsAsMatrixDirty = function () {
  4626. // No child
  4627. };
  4628. /** @hidden */
  4629. Control.prototype._intersectsRect = function (rect) {
  4630. // Rotate the control's current measure into local space and check if it intersects the passed in rectangle
  4631. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4632. if (this._tmpMeasureA.left >= rect.left + rect.width) {
  4633. return false;
  4634. }
  4635. if (this._tmpMeasureA.top >= rect.top + rect.height) {
  4636. return false;
  4637. }
  4638. if (this._tmpMeasureA.left + this._tmpMeasureA.width <= rect.left) {
  4639. return false;
  4640. }
  4641. if (this._tmpMeasureA.top + this._tmpMeasureA.height <= rect.top) {
  4642. return false;
  4643. }
  4644. return true;
  4645. };
  4646. /** @hidden */
  4647. Control.prototype.invalidateRect = function () {
  4648. this._transform();
  4649. if (this.host && this.host.useInvalidateRectOptimization) {
  4650. // Rotate by transform to get the measure transformed to global space
  4651. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4652. // get the boudning box of the current measure and last frames measure in global space and invalidate it
  4653. // the previous measure is used to properly clear a control that is scaled down
  4654. _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].CombineToRef(this._tmpMeasureA, this._prevCurrentMeasureTransformedIntoGlobalSpace, this._tmpMeasureA);
  4655. this.host.invalidateRect(Math.floor(this._tmpMeasureA.left), Math.floor(this._tmpMeasureA.top), Math.ceil(this._tmpMeasureA.left + this._tmpMeasureA.width), Math.ceil(this._tmpMeasureA.top + this._tmpMeasureA.height));
  4656. }
  4657. };
  4658. /** @hidden */
  4659. Control.prototype._markAsDirty = function (force) {
  4660. if (force === void 0) { force = false; }
  4661. if (!this._isVisible && !force) {
  4662. return;
  4663. }
  4664. this._isDirty = true;
  4665. // Redraw only this rectangle
  4666. if (this._host) {
  4667. this._host.markAsDirty();
  4668. }
  4669. };
  4670. /** @hidden */
  4671. Control.prototype._markAllAsDirty = function () {
  4672. this._markAsDirty();
  4673. if (this._font) {
  4674. this._prepareFont();
  4675. }
  4676. };
  4677. /** @hidden */
  4678. Control.prototype._link = function (host) {
  4679. this._host = host;
  4680. if (this._host) {
  4681. this.uniqueId = this._host.getScene().getUniqueId();
  4682. }
  4683. };
  4684. /** @hidden */
  4685. Control.prototype._transform = function (context) {
  4686. if (!this._isMatrixDirty && this._scaleX === 1 && this._scaleY === 1 && this._rotation === 0) {
  4687. return;
  4688. }
  4689. // postTranslate
  4690. var offsetX = this._currentMeasure.width * this._transformCenterX + this._currentMeasure.left;
  4691. var offsetY = this._currentMeasure.height * this._transformCenterY + this._currentMeasure.top;
  4692. if (context) {
  4693. context.translate(offsetX, offsetY);
  4694. // rotate
  4695. context.rotate(this._rotation);
  4696. // scale
  4697. context.scale(this._scaleX, this._scaleY);
  4698. // preTranslate
  4699. context.translate(-offsetX, -offsetY);
  4700. }
  4701. // Need to update matrices?
  4702. if (this._isMatrixDirty || this._cachedOffsetX !== offsetX || this._cachedOffsetY !== offsetY) {
  4703. this._cachedOffsetX = offsetX;
  4704. this._cachedOffsetY = offsetY;
  4705. this._isMatrixDirty = false;
  4706. this._flagDescendantsAsMatrixDirty();
  4707. _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].ComposeToRef(-offsetX, -offsetY, this._rotation, this._scaleX, this._scaleY, this.parent ? this.parent._transformMatrix : null, this._transformMatrix);
  4708. this._transformMatrix.invertToRef(this._invertTransformMatrix);
  4709. }
  4710. };
  4711. /** @hidden */
  4712. Control.prototype._renderHighlight = function (context) {
  4713. if (!this.isHighlighted) {
  4714. return;
  4715. }
  4716. context.save();
  4717. context.strokeStyle = "#4affff";
  4718. context.lineWidth = 2;
  4719. this._renderHighlightSpecific(context);
  4720. context.restore();
  4721. };
  4722. /** @hidden */
  4723. Control.prototype._renderHighlightSpecific = function (context) {
  4724. context.strokeRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  4725. };
  4726. /** @hidden */
  4727. Control.prototype._applyStates = function (context) {
  4728. if (this._isFontSizeInPercentage) {
  4729. this._fontSet = true;
  4730. }
  4731. if (this._fontSet) {
  4732. this._prepareFont();
  4733. this._fontSet = false;
  4734. }
  4735. if (this._font) {
  4736. context.font = this._font;
  4737. }
  4738. if (this._color) {
  4739. context.fillStyle = this._color;
  4740. }
  4741. if (Control.AllowAlphaInheritance) {
  4742. context.globalAlpha *= this._alpha;
  4743. }
  4744. else if (this._alphaSet) {
  4745. context.globalAlpha = this.parent ? this.parent.alpha * this._alpha : this._alpha;
  4746. }
  4747. };
  4748. /** @hidden */
  4749. Control.prototype._layout = function (parentMeasure, context) {
  4750. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  4751. return false;
  4752. }
  4753. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  4754. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  4755. context.save();
  4756. this._applyStates(context);
  4757. var rebuildCount = 0;
  4758. do {
  4759. this._rebuildLayout = false;
  4760. this._processMeasures(parentMeasure, context);
  4761. rebuildCount++;
  4762. } while (this._rebuildLayout && rebuildCount < 3);
  4763. if (rebuildCount >= 3) {
  4764. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Layout cycle detected in GUI (Control name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  4765. }
  4766. context.restore();
  4767. this.invalidateRect();
  4768. this._evaluateClippingState(parentMeasure);
  4769. }
  4770. this._wasDirty = this._isDirty;
  4771. this._isDirty = false;
  4772. return true;
  4773. };
  4774. /** @hidden */
  4775. Control.prototype._processMeasures = function (parentMeasure, context) {
  4776. this._currentMeasure.copyFrom(parentMeasure);
  4777. // Let children take some pre-measurement actions
  4778. this._preMeasure(parentMeasure, context);
  4779. this._measure();
  4780. this._computeAlignment(parentMeasure, context);
  4781. // Convert to int values
  4782. this._currentMeasure.left = this._currentMeasure.left | 0;
  4783. this._currentMeasure.top = this._currentMeasure.top | 0;
  4784. this._currentMeasure.width = this._currentMeasure.width | 0;
  4785. this._currentMeasure.height = this._currentMeasure.height | 0;
  4786. // Let children add more features
  4787. this._additionalProcessing(parentMeasure, context);
  4788. this._cachedParentMeasure.copyFrom(parentMeasure);
  4789. if (this.onDirtyObservable.hasObservers()) {
  4790. this.onDirtyObservable.notifyObservers(this);
  4791. }
  4792. };
  4793. Control.prototype._evaluateClippingState = function (parentMeasure) {
  4794. if (this.parent && this.parent.clipChildren) {
  4795. // Early clip
  4796. if (this._currentMeasure.left > parentMeasure.left + parentMeasure.width) {
  4797. this._isClipped = true;
  4798. return;
  4799. }
  4800. if (this._currentMeasure.left + this._currentMeasure.width < parentMeasure.left) {
  4801. this._isClipped = true;
  4802. return;
  4803. }
  4804. if (this._currentMeasure.top > parentMeasure.top + parentMeasure.height) {
  4805. this._isClipped = true;
  4806. return;
  4807. }
  4808. if (this._currentMeasure.top + this._currentMeasure.height < parentMeasure.top) {
  4809. this._isClipped = true;
  4810. return;
  4811. }
  4812. }
  4813. this._isClipped = false;
  4814. };
  4815. /** @hidden */
  4816. Control.prototype._measure = function () {
  4817. // Width / Height
  4818. if (this._width.isPixel) {
  4819. this._currentMeasure.width = this._width.getValue(this._host);
  4820. }
  4821. else {
  4822. this._currentMeasure.width *= this._width.getValue(this._host);
  4823. }
  4824. if (this._height.isPixel) {
  4825. this._currentMeasure.height = this._height.getValue(this._host);
  4826. }
  4827. else {
  4828. this._currentMeasure.height *= this._height.getValue(this._host);
  4829. }
  4830. };
  4831. /** @hidden */
  4832. Control.prototype._computeAlignment = function (parentMeasure, context) {
  4833. var width = this._currentMeasure.width;
  4834. var height = this._currentMeasure.height;
  4835. var parentWidth = parentMeasure.width;
  4836. var parentHeight = parentMeasure.height;
  4837. // Left / top
  4838. var x = 0;
  4839. var y = 0;
  4840. switch (this.horizontalAlignment) {
  4841. case Control.HORIZONTAL_ALIGNMENT_LEFT:
  4842. x = 0;
  4843. break;
  4844. case Control.HORIZONTAL_ALIGNMENT_RIGHT:
  4845. x = parentWidth - width;
  4846. break;
  4847. case Control.HORIZONTAL_ALIGNMENT_CENTER:
  4848. x = (parentWidth - width) / 2;
  4849. break;
  4850. }
  4851. switch (this.verticalAlignment) {
  4852. case Control.VERTICAL_ALIGNMENT_TOP:
  4853. y = 0;
  4854. break;
  4855. case Control.VERTICAL_ALIGNMENT_BOTTOM:
  4856. y = parentHeight - height;
  4857. break;
  4858. case Control.VERTICAL_ALIGNMENT_CENTER:
  4859. y = (parentHeight - height) / 2;
  4860. break;
  4861. }
  4862. if (this._paddingLeft.isPixel) {
  4863. this._currentMeasure.left += this._paddingLeft.getValue(this._host);
  4864. this._currentMeasure.width -= this._paddingLeft.getValue(this._host);
  4865. }
  4866. else {
  4867. this._currentMeasure.left += parentWidth * this._paddingLeft.getValue(this._host);
  4868. this._currentMeasure.width -= parentWidth * this._paddingLeft.getValue(this._host);
  4869. }
  4870. if (this._paddingRight.isPixel) {
  4871. this._currentMeasure.width -= this._paddingRight.getValue(this._host);
  4872. }
  4873. else {
  4874. this._currentMeasure.width -= parentWidth * this._paddingRight.getValue(this._host);
  4875. }
  4876. if (this._paddingTop.isPixel) {
  4877. this._currentMeasure.top += this._paddingTop.getValue(this._host);
  4878. this._currentMeasure.height -= this._paddingTop.getValue(this._host);
  4879. }
  4880. else {
  4881. this._currentMeasure.top += parentHeight * this._paddingTop.getValue(this._host);
  4882. this._currentMeasure.height -= parentHeight * this._paddingTop.getValue(this._host);
  4883. }
  4884. if (this._paddingBottom.isPixel) {
  4885. this._currentMeasure.height -= this._paddingBottom.getValue(this._host);
  4886. }
  4887. else {
  4888. this._currentMeasure.height -= parentHeight * this._paddingBottom.getValue(this._host);
  4889. }
  4890. if (this._left.isPixel) {
  4891. this._currentMeasure.left += this._left.getValue(this._host);
  4892. }
  4893. else {
  4894. this._currentMeasure.left += parentWidth * this._left.getValue(this._host);
  4895. }
  4896. if (this._top.isPixel) {
  4897. this._currentMeasure.top += this._top.getValue(this._host);
  4898. }
  4899. else {
  4900. this._currentMeasure.top += parentHeight * this._top.getValue(this._host);
  4901. }
  4902. this._currentMeasure.left += x;
  4903. this._currentMeasure.top += y;
  4904. };
  4905. /** @hidden */
  4906. Control.prototype._preMeasure = function (parentMeasure, context) {
  4907. // Do nothing
  4908. };
  4909. /** @hidden */
  4910. Control.prototype._additionalProcessing = function (parentMeasure, context) {
  4911. // Do nothing
  4912. };
  4913. /** @hidden */
  4914. Control.prototype._clipForChildren = function (context) {
  4915. // DO nothing
  4916. };
  4917. Control.prototype._clip = function (context, invalidatedRectangle) {
  4918. context.beginPath();
  4919. Control._ClipMeasure.copyFrom(this._currentMeasure);
  4920. if (invalidatedRectangle) {
  4921. // Rotate the invalidated rect into the control's space
  4922. invalidatedRectangle.transformToRef(this._invertTransformMatrix, this._tmpMeasureA);
  4923. // Get the intersection of the rect in context space and the current context
  4924. var intersection = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  4925. intersection.left = Math.max(this._tmpMeasureA.left, this._currentMeasure.left);
  4926. intersection.top = Math.max(this._tmpMeasureA.top, this._currentMeasure.top);
  4927. intersection.width = Math.min(this._tmpMeasureA.left + this._tmpMeasureA.width, this._currentMeasure.left + this._currentMeasure.width) - intersection.left;
  4928. intersection.height = Math.min(this._tmpMeasureA.top + this._tmpMeasureA.height, this._currentMeasure.top + this._currentMeasure.height) - intersection.top;
  4929. Control._ClipMeasure.copyFrom(intersection);
  4930. }
  4931. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4932. var shadowOffsetX = this.shadowOffsetX;
  4933. var shadowOffsetY = this.shadowOffsetY;
  4934. var shadowBlur = this.shadowBlur;
  4935. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  4936. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  4937. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  4938. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  4939. context.rect(Control._ClipMeasure.left + leftShadowOffset, Control._ClipMeasure.top + topShadowOffset, Control._ClipMeasure.width + rightShadowOffset - leftShadowOffset, Control._ClipMeasure.height + bottomShadowOffset - topShadowOffset);
  4940. }
  4941. else {
  4942. context.rect(Control._ClipMeasure.left, Control._ClipMeasure.top, Control._ClipMeasure.width, Control._ClipMeasure.height);
  4943. }
  4944. context.clip();
  4945. };
  4946. /** @hidden */
  4947. Control.prototype._render = function (context, invalidatedRectangle) {
  4948. if (!this.isVisible || this.notRenderable || this._isClipped) {
  4949. this._isDirty = false;
  4950. return false;
  4951. }
  4952. context.save();
  4953. this._applyStates(context);
  4954. // Transform
  4955. this._transform(context);
  4956. // Clip
  4957. if (this.clipChildren) {
  4958. this._clip(context, invalidatedRectangle);
  4959. }
  4960. if (this.onBeforeDrawObservable.hasObservers()) {
  4961. this.onBeforeDrawObservable.notifyObservers(this);
  4962. }
  4963. if (this.useBitmapCache && !this._wasDirty && this._cacheData) {
  4964. context.putImageData(this._cacheData, this._currentMeasure.left, this._currentMeasure.top);
  4965. }
  4966. else {
  4967. this._draw(context, invalidatedRectangle);
  4968. }
  4969. if (this.useBitmapCache && this._wasDirty) {
  4970. this._cacheData = context.getImageData(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  4971. }
  4972. this._renderHighlight(context);
  4973. if (this.onAfterDrawObservable.hasObservers()) {
  4974. this.onAfterDrawObservable.notifyObservers(this);
  4975. }
  4976. context.restore();
  4977. return true;
  4978. };
  4979. /** @hidden */
  4980. Control.prototype._draw = function (context, invalidatedRectangle) {
  4981. // Do nothing
  4982. };
  4983. /**
  4984. * Tests if a given coordinates belong to the current control
  4985. * @param x defines x coordinate to test
  4986. * @param y defines y coordinate to test
  4987. * @returns true if the coordinates are inside the control
  4988. */
  4989. Control.prototype.contains = function (x, y) {
  4990. // Invert transform
  4991. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  4992. x = this._transformedPosition.x;
  4993. y = this._transformedPosition.y;
  4994. // Check
  4995. if (x < this._currentMeasure.left) {
  4996. return false;
  4997. }
  4998. if (x > this._currentMeasure.left + this._currentMeasure.width) {
  4999. return false;
  5000. }
  5001. if (y < this._currentMeasure.top) {
  5002. return false;
  5003. }
  5004. if (y > this._currentMeasure.top + this._currentMeasure.height) {
  5005. return false;
  5006. }
  5007. if (this.isPointerBlocker) {
  5008. this._host._shouldBlockPointer = true;
  5009. }
  5010. return true;
  5011. };
  5012. /** @hidden */
  5013. Control.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  5014. if (!this._isEnabled) {
  5015. return false;
  5016. }
  5017. if (!this.isHitTestVisible || !this.isVisible || this._doNotRender) {
  5018. return false;
  5019. }
  5020. if (!this.contains(x, y)) {
  5021. return false;
  5022. }
  5023. this._processObservables(type, x, y, pointerId, buttonIndex);
  5024. return true;
  5025. };
  5026. /** @hidden */
  5027. Control.prototype._onPointerMove = function (target, coordinates) {
  5028. var canNotify = this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  5029. if (canNotify && this.parent != null) {
  5030. this.parent._onPointerMove(target, coordinates);
  5031. }
  5032. };
  5033. /** @hidden */
  5034. Control.prototype._onPointerEnter = function (target) {
  5035. if (!this._isEnabled) {
  5036. return false;
  5037. }
  5038. if (this._enterCount > 0) {
  5039. return false;
  5040. }
  5041. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  5042. this._enterCount = 0;
  5043. }
  5044. this._enterCount++;
  5045. var canNotify = this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  5046. if (canNotify && this.parent != null) {
  5047. this.parent._onPointerEnter(target);
  5048. }
  5049. return true;
  5050. };
  5051. /** @hidden */
  5052. Control.prototype._onPointerOut = function (target) {
  5053. if (!this._isEnabled || target === this) {
  5054. return;
  5055. }
  5056. this._enterCount = 0;
  5057. var canNotify = true;
  5058. if (!target.isAscendant(this)) {
  5059. canNotify = this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  5060. }
  5061. if (canNotify && this.parent != null) {
  5062. this.parent._onPointerOut(target);
  5063. }
  5064. };
  5065. /** @hidden */
  5066. Control.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  5067. // Prevent pointerout to lose control context.
  5068. // Event redundancy is checked inside the function.
  5069. this._onPointerEnter(this);
  5070. if (this._downCount !== 0) {
  5071. return false;
  5072. }
  5073. this._downCount++;
  5074. this._downPointerIds[pointerId] = true;
  5075. var canNotify = this.onPointerDownObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5076. if (canNotify && this.parent != null) {
  5077. this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex);
  5078. }
  5079. return true;
  5080. };
  5081. /** @hidden */
  5082. Control.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  5083. if (!this._isEnabled) {
  5084. return;
  5085. }
  5086. this._downCount = 0;
  5087. delete this._downPointerIds[pointerId];
  5088. var canNotifyClick = notifyClick;
  5089. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  5090. canNotifyClick = this.onPointerClickObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5091. }
  5092. var canNotify = this.onPointerUpObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5093. if (canNotify && this.parent != null) {
  5094. this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex, canNotifyClick);
  5095. }
  5096. };
  5097. /** @hidden */
  5098. Control.prototype._forcePointerUp = function (pointerId) {
  5099. if (pointerId === void 0) { pointerId = null; }
  5100. if (pointerId !== null) {
  5101. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), pointerId, 0, true);
  5102. }
  5103. else {
  5104. for (var key in this._downPointerIds) {
  5105. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), +key, 0, true);
  5106. }
  5107. }
  5108. };
  5109. /** @hidden */
  5110. Control.prototype._processObservables = function (type, x, y, pointerId, buttonIndex) {
  5111. if (!this._isEnabled) {
  5112. return false;
  5113. }
  5114. this._dummyVector2.copyFromFloats(x, y);
  5115. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  5116. this._onPointerMove(this, this._dummyVector2);
  5117. var previousControlOver = this._host._lastControlOver[pointerId];
  5118. if (previousControlOver && previousControlOver !== this) {
  5119. previousControlOver._onPointerOut(this);
  5120. }
  5121. if (previousControlOver !== this) {
  5122. this._onPointerEnter(this);
  5123. }
  5124. this._host._lastControlOver[pointerId] = this;
  5125. return true;
  5126. }
  5127. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  5128. this._onPointerDown(this, this._dummyVector2, pointerId, buttonIndex);
  5129. this._host._registerLastControlDown(this, pointerId);
  5130. this._host._lastPickedControl = this;
  5131. return true;
  5132. }
  5133. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  5134. if (this._host._lastControlDown[pointerId]) {
  5135. this._host._lastControlDown[pointerId]._onPointerUp(this, this._dummyVector2, pointerId, buttonIndex, true);
  5136. }
  5137. delete this._host._lastControlDown[pointerId];
  5138. return true;
  5139. }
  5140. return false;
  5141. };
  5142. Control.prototype._prepareFont = function () {
  5143. if (!this._font && !this._fontSet) {
  5144. return;
  5145. }
  5146. if (this._style) {
  5147. this._font = this._style.fontStyle + " " + this._style.fontWeight + " " + this.fontSizeInPixels + "px " + this._style.fontFamily;
  5148. }
  5149. else {
  5150. this._font = this._fontStyle + " " + this._fontWeight + " " + this.fontSizeInPixels + "px " + this._fontFamily;
  5151. }
  5152. this._fontOffset = Control._GetFontOffset(this._font);
  5153. };
  5154. /** Releases associated resources */
  5155. Control.prototype.dispose = function () {
  5156. this.onDirtyObservable.clear();
  5157. this.onBeforeDrawObservable.clear();
  5158. this.onAfterDrawObservable.clear();
  5159. this.onPointerDownObservable.clear();
  5160. this.onPointerEnterObservable.clear();
  5161. this.onPointerMoveObservable.clear();
  5162. this.onPointerOutObservable.clear();
  5163. this.onPointerUpObservable.clear();
  5164. this.onPointerClickObservable.clear();
  5165. if (this._styleObserver && this._style) {
  5166. this._style.onChangedObservable.remove(this._styleObserver);
  5167. this._styleObserver = null;
  5168. }
  5169. if (this.parent) {
  5170. this.parent.removeControl(this);
  5171. this.parent = null;
  5172. }
  5173. if (this._host) {
  5174. var index = this._host._linkedControls.indexOf(this);
  5175. if (index > -1) {
  5176. this.linkWithMesh(null);
  5177. }
  5178. }
  5179. };
  5180. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_LEFT", {
  5181. /** HORIZONTAL_ALIGNMENT_LEFT */
  5182. get: function () {
  5183. return Control._HORIZONTAL_ALIGNMENT_LEFT;
  5184. },
  5185. enumerable: true,
  5186. configurable: true
  5187. });
  5188. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_RIGHT", {
  5189. /** HORIZONTAL_ALIGNMENT_RIGHT */
  5190. get: function () {
  5191. return Control._HORIZONTAL_ALIGNMENT_RIGHT;
  5192. },
  5193. enumerable: true,
  5194. configurable: true
  5195. });
  5196. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_CENTER", {
  5197. /** HORIZONTAL_ALIGNMENT_CENTER */
  5198. get: function () {
  5199. return Control._HORIZONTAL_ALIGNMENT_CENTER;
  5200. },
  5201. enumerable: true,
  5202. configurable: true
  5203. });
  5204. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_TOP", {
  5205. /** VERTICAL_ALIGNMENT_TOP */
  5206. get: function () {
  5207. return Control._VERTICAL_ALIGNMENT_TOP;
  5208. },
  5209. enumerable: true,
  5210. configurable: true
  5211. });
  5212. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_BOTTOM", {
  5213. /** VERTICAL_ALIGNMENT_BOTTOM */
  5214. get: function () {
  5215. return Control._VERTICAL_ALIGNMENT_BOTTOM;
  5216. },
  5217. enumerable: true,
  5218. configurable: true
  5219. });
  5220. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_CENTER", {
  5221. /** VERTICAL_ALIGNMENT_CENTER */
  5222. get: function () {
  5223. return Control._VERTICAL_ALIGNMENT_CENTER;
  5224. },
  5225. enumerable: true,
  5226. configurable: true
  5227. });
  5228. /** @hidden */
  5229. Control._GetFontOffset = function (font) {
  5230. if (Control._FontHeightSizes[font]) {
  5231. return Control._FontHeightSizes[font];
  5232. }
  5233. var text = document.createElement("span");
  5234. text.innerHTML = "Hg";
  5235. text.style.font = font;
  5236. var block = document.createElement("div");
  5237. block.style.display = "inline-block";
  5238. block.style.width = "1px";
  5239. block.style.height = "0px";
  5240. block.style.verticalAlign = "bottom";
  5241. var div = document.createElement("div");
  5242. div.appendChild(text);
  5243. div.appendChild(block);
  5244. document.body.appendChild(div);
  5245. var fontAscent = 0;
  5246. var fontHeight = 0;
  5247. try {
  5248. fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5249. block.style.verticalAlign = "baseline";
  5250. fontAscent = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5251. }
  5252. finally {
  5253. document.body.removeChild(div);
  5254. }
  5255. var result = { ascent: fontAscent, height: fontHeight, descent: fontHeight - fontAscent };
  5256. Control._FontHeightSizes[font] = result;
  5257. return result;
  5258. };
  5259. /** @hidden */
  5260. Control.drawEllipse = function (x, y, width, height, context) {
  5261. context.translate(x, y);
  5262. context.scale(width, height);
  5263. context.beginPath();
  5264. context.arc(0, 0, 1, 0, 2 * Math.PI);
  5265. context.closePath();
  5266. context.scale(1 / width, 1 / height);
  5267. context.translate(-x, -y);
  5268. };
  5269. /**
  5270. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  5271. */
  5272. Control.AllowAlphaInheritance = false;
  5273. Control._ClipMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5274. // Statics
  5275. Control._HORIZONTAL_ALIGNMENT_LEFT = 0;
  5276. Control._HORIZONTAL_ALIGNMENT_RIGHT = 1;
  5277. Control._HORIZONTAL_ALIGNMENT_CENTER = 2;
  5278. Control._VERTICAL_ALIGNMENT_TOP = 0;
  5279. Control._VERTICAL_ALIGNMENT_BOTTOM = 1;
  5280. Control._VERTICAL_ALIGNMENT_CENTER = 2;
  5281. Control._FontHeightSizes = {};
  5282. /**
  5283. * Creates a stack panel that can be used to render headers
  5284. * @param control defines the control to associate with the header
  5285. * @param text defines the text of the header
  5286. * @param size defines the size of the header
  5287. * @param options defines options used to configure the header
  5288. * @returns a new StackPanel
  5289. * @ignore
  5290. * @hidden
  5291. */
  5292. Control.AddHeader = function () { };
  5293. return Control;
  5294. }());
  5295. /***/ }),
  5296. /***/ "./2D/controls/displayGrid.ts":
  5297. /*!************************************!*\
  5298. !*** ./2D/controls/displayGrid.ts ***!
  5299. \************************************/
  5300. /*! exports provided: DisplayGrid */
  5301. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5302. "use strict";
  5303. __webpack_require__.r(__webpack_exports__);
  5304. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return DisplayGrid; });
  5305. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5306. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5307. /** Class used to render a grid */
  5308. var DisplayGrid = /** @class */ (function (_super) {
  5309. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DisplayGrid, _super);
  5310. /**
  5311. * Creates a new GridDisplayRectangle
  5312. * @param name defines the control name
  5313. */
  5314. function DisplayGrid(name) {
  5315. var _this = _super.call(this, name) || this;
  5316. _this.name = name;
  5317. _this._cellWidth = 20;
  5318. _this._cellHeight = 20;
  5319. _this._minorLineTickness = 1;
  5320. _this._minorLineColor = "DarkGray";
  5321. _this._majorLineTickness = 2;
  5322. _this._majorLineColor = "White";
  5323. _this._majorLineFrequency = 5;
  5324. _this._background = "Black";
  5325. _this._displayMajorLines = true;
  5326. _this._displayMinorLines = true;
  5327. return _this;
  5328. }
  5329. Object.defineProperty(DisplayGrid.prototype, "displayMinorLines", {
  5330. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  5331. get: function () {
  5332. return this._displayMinorLines;
  5333. },
  5334. set: function (value) {
  5335. if (this._displayMinorLines === value) {
  5336. return;
  5337. }
  5338. this._displayMinorLines = value;
  5339. this._markAsDirty();
  5340. },
  5341. enumerable: true,
  5342. configurable: true
  5343. });
  5344. Object.defineProperty(DisplayGrid.prototype, "displayMajorLines", {
  5345. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  5346. get: function () {
  5347. return this._displayMajorLines;
  5348. },
  5349. set: function (value) {
  5350. if (this._displayMajorLines === value) {
  5351. return;
  5352. }
  5353. this._displayMajorLines = value;
  5354. this._markAsDirty();
  5355. },
  5356. enumerable: true,
  5357. configurable: true
  5358. });
  5359. Object.defineProperty(DisplayGrid.prototype, "background", {
  5360. /** Gets or sets background color (Black by default) */
  5361. get: function () {
  5362. return this._background;
  5363. },
  5364. set: function (value) {
  5365. if (this._background === value) {
  5366. return;
  5367. }
  5368. this._background = value;
  5369. this._markAsDirty();
  5370. },
  5371. enumerable: true,
  5372. configurable: true
  5373. });
  5374. Object.defineProperty(DisplayGrid.prototype, "cellWidth", {
  5375. /** Gets or sets the width of each cell (20 by default) */
  5376. get: function () {
  5377. return this._cellWidth;
  5378. },
  5379. set: function (value) {
  5380. this._cellWidth = value;
  5381. this._markAsDirty();
  5382. },
  5383. enumerable: true,
  5384. configurable: true
  5385. });
  5386. Object.defineProperty(DisplayGrid.prototype, "cellHeight", {
  5387. /** Gets or sets the height of each cell (20 by default) */
  5388. get: function () {
  5389. return this._cellHeight;
  5390. },
  5391. set: function (value) {
  5392. this._cellHeight = value;
  5393. this._markAsDirty();
  5394. },
  5395. enumerable: true,
  5396. configurable: true
  5397. });
  5398. Object.defineProperty(DisplayGrid.prototype, "minorLineTickness", {
  5399. /** Gets or sets the tickness of minor lines (1 by default) */
  5400. get: function () {
  5401. return this._minorLineTickness;
  5402. },
  5403. set: function (value) {
  5404. this._minorLineTickness = value;
  5405. this._markAsDirty();
  5406. },
  5407. enumerable: true,
  5408. configurable: true
  5409. });
  5410. Object.defineProperty(DisplayGrid.prototype, "minorLineColor", {
  5411. /** Gets or sets the color of minor lines (DarkGray by default) */
  5412. get: function () {
  5413. return this._minorLineColor;
  5414. },
  5415. set: function (value) {
  5416. this._minorLineColor = value;
  5417. this._markAsDirty();
  5418. },
  5419. enumerable: true,
  5420. configurable: true
  5421. });
  5422. Object.defineProperty(DisplayGrid.prototype, "majorLineTickness", {
  5423. /** Gets or sets the tickness of major lines (2 by default) */
  5424. get: function () {
  5425. return this._majorLineTickness;
  5426. },
  5427. set: function (value) {
  5428. this._majorLineTickness = value;
  5429. this._markAsDirty();
  5430. },
  5431. enumerable: true,
  5432. configurable: true
  5433. });
  5434. Object.defineProperty(DisplayGrid.prototype, "majorLineColor", {
  5435. /** Gets or sets the color of major lines (White by default) */
  5436. get: function () {
  5437. return this._majorLineColor;
  5438. },
  5439. set: function (value) {
  5440. this._majorLineColor = value;
  5441. this._markAsDirty();
  5442. },
  5443. enumerable: true,
  5444. configurable: true
  5445. });
  5446. Object.defineProperty(DisplayGrid.prototype, "majorLineFrequency", {
  5447. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  5448. get: function () {
  5449. return this._majorLineFrequency;
  5450. },
  5451. set: function (value) {
  5452. this._majorLineFrequency = value;
  5453. this._markAsDirty();
  5454. },
  5455. enumerable: true,
  5456. configurable: true
  5457. });
  5458. DisplayGrid.prototype._draw = function (context) {
  5459. context.save();
  5460. this._applyStates(context);
  5461. if (this._isEnabled) {
  5462. if (this._background) {
  5463. context.fillStyle = this._background;
  5464. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5465. }
  5466. var cellCountX = this._currentMeasure.width / this._cellWidth;
  5467. var cellCountY = this._currentMeasure.height / this._cellHeight;
  5468. // Minor lines
  5469. var left = this._currentMeasure.left + this._currentMeasure.width / 2;
  5470. var top_1 = this._currentMeasure.top + this._currentMeasure.height / 2;
  5471. if (this._displayMinorLines) {
  5472. context.strokeStyle = this._minorLineColor;
  5473. context.lineWidth = this._minorLineTickness;
  5474. for (var x = -cellCountX / 2; x < cellCountX / 2; x++) {
  5475. var cellX = left + x * this.cellWidth;
  5476. context.beginPath();
  5477. context.moveTo(cellX, this._currentMeasure.top);
  5478. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5479. context.stroke();
  5480. }
  5481. for (var y = -cellCountY / 2; y < cellCountY / 2; y++) {
  5482. var cellY = top_1 + y * this.cellHeight;
  5483. context.beginPath();
  5484. context.moveTo(this._currentMeasure.left, cellY);
  5485. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5486. context.stroke();
  5487. }
  5488. }
  5489. // Major lines
  5490. if (this._displayMajorLines) {
  5491. context.strokeStyle = this._majorLineColor;
  5492. context.lineWidth = this._majorLineTickness;
  5493. for (var x = -cellCountX / 2 + this._majorLineFrequency; x < cellCountX / 2; x += this._majorLineFrequency) {
  5494. var cellX = left + x * this.cellWidth;
  5495. context.beginPath();
  5496. context.moveTo(cellX, this._currentMeasure.top);
  5497. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5498. context.stroke();
  5499. }
  5500. for (var y = -cellCountY / 2 + this._majorLineFrequency; y < cellCountY / 2; y += this._majorLineFrequency) {
  5501. var cellY = top_1 + y * this.cellHeight;
  5502. context.moveTo(this._currentMeasure.left, cellY);
  5503. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5504. context.closePath();
  5505. context.stroke();
  5506. }
  5507. }
  5508. }
  5509. context.restore();
  5510. };
  5511. DisplayGrid.prototype._getTypeName = function () {
  5512. return "DisplayGrid";
  5513. };
  5514. return DisplayGrid;
  5515. }(_control__WEBPACK_IMPORTED_MODULE_1__["Control"]));
  5516. /***/ }),
  5517. /***/ "./2D/controls/ellipse.ts":
  5518. /*!********************************!*\
  5519. !*** ./2D/controls/ellipse.ts ***!
  5520. \********************************/
  5521. /*! exports provided: Ellipse */
  5522. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5523. "use strict";
  5524. __webpack_require__.r(__webpack_exports__);
  5525. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return Ellipse; });
  5526. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5527. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5528. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5529. /** Class used to create 2D ellipse containers */
  5530. var Ellipse = /** @class */ (function (_super) {
  5531. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Ellipse, _super);
  5532. /**
  5533. * Creates a new Ellipse
  5534. * @param name defines the control name
  5535. */
  5536. function Ellipse(name) {
  5537. var _this = _super.call(this, name) || this;
  5538. _this.name = name;
  5539. _this._thickness = 1;
  5540. return _this;
  5541. }
  5542. Object.defineProperty(Ellipse.prototype, "thickness", {
  5543. /** Gets or sets border thickness */
  5544. get: function () {
  5545. return this._thickness;
  5546. },
  5547. set: function (value) {
  5548. if (this._thickness === value) {
  5549. return;
  5550. }
  5551. this._thickness = value;
  5552. this._markAsDirty();
  5553. },
  5554. enumerable: true,
  5555. configurable: true
  5556. });
  5557. Ellipse.prototype._getTypeName = function () {
  5558. return "Ellipse";
  5559. };
  5560. Ellipse.prototype._localDraw = function (context) {
  5561. context.save();
  5562. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5563. context.shadowColor = this.shadowColor;
  5564. context.shadowBlur = this.shadowBlur;
  5565. context.shadowOffsetX = this.shadowOffsetX;
  5566. context.shadowOffsetY = this.shadowOffsetY;
  5567. }
  5568. _control__WEBPACK_IMPORTED_MODULE_2__["Control"].drawEllipse(this._currentMeasure.left + this._currentMeasure.width / 2, this._currentMeasure.top + this._currentMeasure.height / 2, this._currentMeasure.width / 2 - this._thickness / 2, this._currentMeasure.height / 2 - this._thickness / 2, context);
  5569. if (this._background) {
  5570. context.fillStyle = this._background;
  5571. context.fill();
  5572. }
  5573. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5574. context.shadowBlur = 0;
  5575. context.shadowOffsetX = 0;
  5576. context.shadowOffsetY = 0;
  5577. }
  5578. if (this._thickness) {
  5579. if (this.color) {
  5580. context.strokeStyle = this.color;
  5581. }
  5582. context.lineWidth = this._thickness;
  5583. context.stroke();
  5584. }
  5585. context.restore();
  5586. };
  5587. Ellipse.prototype._additionalProcessing = function (parentMeasure, context) {
  5588. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  5589. this._measureForChildren.width -= 2 * this._thickness;
  5590. this._measureForChildren.height -= 2 * this._thickness;
  5591. this._measureForChildren.left += this._thickness;
  5592. this._measureForChildren.top += this._thickness;
  5593. };
  5594. Ellipse.prototype._clipForChildren = function (context) {
  5595. _control__WEBPACK_IMPORTED_MODULE_2__["Control"].drawEllipse(this._currentMeasure.left + this._currentMeasure.width / 2, this._currentMeasure.top + this._currentMeasure.height / 2, this._currentMeasure.width / 2, this._currentMeasure.height / 2, context);
  5596. context.clip();
  5597. };
  5598. return Ellipse;
  5599. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  5600. /***/ }),
  5601. /***/ "./2D/controls/grid.ts":
  5602. /*!*****************************!*\
  5603. !*** ./2D/controls/grid.ts ***!
  5604. \*****************************/
  5605. /*! exports provided: Grid */
  5606. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5607. "use strict";
  5608. __webpack_require__.r(__webpack_exports__);
  5609. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return Grid; });
  5610. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5611. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5612. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  5613. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5614. /**
  5615. * Class used to create a 2D grid container
  5616. */
  5617. var Grid = /** @class */ (function (_super) {
  5618. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Grid, _super);
  5619. /**
  5620. * Creates a new Grid
  5621. * @param name defines control name
  5622. */
  5623. function Grid(name) {
  5624. var _this = _super.call(this, name) || this;
  5625. _this.name = name;
  5626. _this._rowDefinitions = new Array();
  5627. _this._columnDefinitions = new Array();
  5628. _this._cells = {};
  5629. _this._childControls = new Array();
  5630. return _this;
  5631. }
  5632. Object.defineProperty(Grid.prototype, "columnCount", {
  5633. /**
  5634. * Gets the number of columns
  5635. */
  5636. get: function () {
  5637. return this._columnDefinitions.length;
  5638. },
  5639. enumerable: true,
  5640. configurable: true
  5641. });
  5642. Object.defineProperty(Grid.prototype, "rowCount", {
  5643. /**
  5644. * Gets the number of rows
  5645. */
  5646. get: function () {
  5647. return this._rowDefinitions.length;
  5648. },
  5649. enumerable: true,
  5650. configurable: true
  5651. });
  5652. Object.defineProperty(Grid.prototype, "children", {
  5653. /** Gets the list of children */
  5654. get: function () {
  5655. return this._childControls;
  5656. },
  5657. enumerable: true,
  5658. configurable: true
  5659. });
  5660. /**
  5661. * Gets the definition of a specific row
  5662. * @param index defines the index of the row
  5663. * @returns the row definition
  5664. */
  5665. Grid.prototype.getRowDefinition = function (index) {
  5666. if (index < 0 || index >= this._rowDefinitions.length) {
  5667. return null;
  5668. }
  5669. return this._rowDefinitions[index];
  5670. };
  5671. /**
  5672. * Gets the definition of a specific column
  5673. * @param index defines the index of the column
  5674. * @returns the column definition
  5675. */
  5676. Grid.prototype.getColumnDefinition = function (index) {
  5677. if (index < 0 || index >= this._columnDefinitions.length) {
  5678. return null;
  5679. }
  5680. return this._columnDefinitions[index];
  5681. };
  5682. /**
  5683. * Adds a new row to the grid
  5684. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5685. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  5686. * @returns the current grid
  5687. */
  5688. Grid.prototype.addRowDefinition = function (height, isPixel) {
  5689. if (isPixel === void 0) { isPixel = false; }
  5690. this._rowDefinitions.push(new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](height, isPixel ? _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL : _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PERCENTAGE));
  5691. this._markAsDirty();
  5692. return this;
  5693. };
  5694. /**
  5695. * Adds a new column to the grid
  5696. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5697. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5698. * @returns the current grid
  5699. */
  5700. Grid.prototype.addColumnDefinition = function (width, isPixel) {
  5701. if (isPixel === void 0) { isPixel = false; }
  5702. this._columnDefinitions.push(new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](width, isPixel ? _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL : _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PERCENTAGE));
  5703. this._markAsDirty();
  5704. return this;
  5705. };
  5706. /**
  5707. * Update a row definition
  5708. * @param index defines the index of the row to update
  5709. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5710. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  5711. * @returns the current grid
  5712. */
  5713. Grid.prototype.setRowDefinition = function (index, height, isPixel) {
  5714. if (isPixel === void 0) { isPixel = false; }
  5715. if (index < 0 || index >= this._rowDefinitions.length) {
  5716. return this;
  5717. }
  5718. var current = this._rowDefinitions[index];
  5719. if (current && current.isPixel === isPixel && current.internalValue === height) {
  5720. return this;
  5721. }
  5722. this._rowDefinitions[index] = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](height, isPixel ? _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL : _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PERCENTAGE);
  5723. this._markAsDirty();
  5724. return this;
  5725. };
  5726. /**
  5727. * Update a column definition
  5728. * @param index defines the index of the column to update
  5729. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5730. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5731. * @returns the current grid
  5732. */
  5733. Grid.prototype.setColumnDefinition = function (index, width, isPixel) {
  5734. if (isPixel === void 0) { isPixel = false; }
  5735. if (index < 0 || index >= this._columnDefinitions.length) {
  5736. return this;
  5737. }
  5738. var current = this._columnDefinitions[index];
  5739. if (current && current.isPixel === isPixel && current.internalValue === width) {
  5740. return this;
  5741. }
  5742. this._columnDefinitions[index] = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](width, isPixel ? _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL : _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PERCENTAGE);
  5743. this._markAsDirty();
  5744. return this;
  5745. };
  5746. /**
  5747. * Gets the list of children stored in a specific cell
  5748. * @param row defines the row to check
  5749. * @param column defines the column to check
  5750. * @returns the list of controls
  5751. */
  5752. Grid.prototype.getChildrenAt = function (row, column) {
  5753. var cell = this._cells[row + ":" + column];
  5754. if (!cell) {
  5755. return null;
  5756. }
  5757. return cell.children;
  5758. };
  5759. /**
  5760. * Gets a string representing the child cell info (row x column)
  5761. * @param child defines the control to get info from
  5762. * @returns a string containing the child cell info (row x column)
  5763. */
  5764. Grid.prototype.getChildCellInfo = function (child) {
  5765. return child._tag;
  5766. };
  5767. Grid.prototype._removeCell = function (cell, key) {
  5768. if (!cell) {
  5769. return;
  5770. }
  5771. _super.prototype.removeControl.call(this, cell);
  5772. for (var _i = 0, _a = cell.children; _i < _a.length; _i++) {
  5773. var control = _a[_i];
  5774. var childIndex = this._childControls.indexOf(control);
  5775. if (childIndex !== -1) {
  5776. this._childControls.splice(childIndex, 1);
  5777. }
  5778. }
  5779. delete this._cells[key];
  5780. };
  5781. Grid.prototype._offsetCell = function (previousKey, key) {
  5782. if (!this._cells[key]) {
  5783. return;
  5784. }
  5785. this._cells[previousKey] = this._cells[key];
  5786. for (var _i = 0, _a = this._cells[previousKey].children; _i < _a.length; _i++) {
  5787. var control = _a[_i];
  5788. control._tag = previousKey;
  5789. }
  5790. delete this._cells[key];
  5791. };
  5792. /**
  5793. * Remove a column definition at specified index
  5794. * @param index defines the index of the column to remove
  5795. * @returns the current grid
  5796. */
  5797. Grid.prototype.removeColumnDefinition = function (index) {
  5798. if (index < 0 || index >= this._columnDefinitions.length) {
  5799. return this;
  5800. }
  5801. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5802. var key = x + ":" + index;
  5803. var cell = this._cells[key];
  5804. this._removeCell(cell, key);
  5805. }
  5806. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5807. for (var y = index + 1; y < this._columnDefinitions.length; y++) {
  5808. var previousKey = x + ":" + (y - 1);
  5809. var key = x + ":" + y;
  5810. this._offsetCell(previousKey, key);
  5811. }
  5812. }
  5813. this._columnDefinitions.splice(index, 1);
  5814. this._markAsDirty();
  5815. return this;
  5816. };
  5817. /**
  5818. * Remove a row definition at specified index
  5819. * @param index defines the index of the row to remove
  5820. * @returns the current grid
  5821. */
  5822. Grid.prototype.removeRowDefinition = function (index) {
  5823. if (index < 0 || index >= this._rowDefinitions.length) {
  5824. return this;
  5825. }
  5826. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5827. var key = index + ":" + y;
  5828. var cell = this._cells[key];
  5829. this._removeCell(cell, key);
  5830. }
  5831. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5832. for (var x = index + 1; x < this._rowDefinitions.length; x++) {
  5833. var previousKey = x - 1 + ":" + y;
  5834. var key = x + ":" + y;
  5835. this._offsetCell(previousKey, key);
  5836. }
  5837. }
  5838. this._rowDefinitions.splice(index, 1);
  5839. this._markAsDirty();
  5840. return this;
  5841. };
  5842. /**
  5843. * Adds a new control to the current grid
  5844. * @param control defines the control to add
  5845. * @param row defines the row where to add the control (0 by default)
  5846. * @param column defines the column where to add the control (0 by default)
  5847. * @returns the current grid
  5848. */
  5849. Grid.prototype.addControl = function (control, row, column) {
  5850. if (row === void 0) { row = 0; }
  5851. if (column === void 0) { column = 0; }
  5852. if (this._rowDefinitions.length === 0) {
  5853. // Add default row definition
  5854. this.addRowDefinition(1, false);
  5855. }
  5856. if (this._columnDefinitions.length === 0) {
  5857. // Add default column definition
  5858. this.addColumnDefinition(1, false);
  5859. }
  5860. var x = Math.min(row, this._rowDefinitions.length - 1);
  5861. var y = Math.min(column, this._columnDefinitions.length - 1);
  5862. var key = x + ":" + y;
  5863. var goodContainer = this._cells[key];
  5864. if (!goodContainer) {
  5865. goodContainer = new _container__WEBPACK_IMPORTED_MODULE_1__["Container"](key);
  5866. this._cells[key] = goodContainer;
  5867. goodContainer.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  5868. goodContainer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  5869. _super.prototype.addControl.call(this, goodContainer);
  5870. }
  5871. goodContainer.addControl(control);
  5872. this._childControls.push(control);
  5873. control._tag = key;
  5874. control.parent = this;
  5875. this._markAsDirty();
  5876. return this;
  5877. };
  5878. /**
  5879. * Removes a control from the current container
  5880. * @param control defines the control to remove
  5881. * @returns the current container
  5882. */
  5883. Grid.prototype.removeControl = function (control) {
  5884. var index = this._childControls.indexOf(control);
  5885. if (index !== -1) {
  5886. this._childControls.splice(index, 1);
  5887. }
  5888. var cell = this._cells[control._tag];
  5889. if (cell) {
  5890. cell.removeControl(control);
  5891. }
  5892. this._markAsDirty();
  5893. return this;
  5894. };
  5895. Grid.prototype._getTypeName = function () {
  5896. return "Grid";
  5897. };
  5898. Grid.prototype._getGridDefinitions = function (definitionCallback) {
  5899. var widths = [];
  5900. var heights = [];
  5901. var lefts = [];
  5902. var tops = [];
  5903. var availableWidth = this._currentMeasure.width;
  5904. var globalWidthPercentage = 0;
  5905. var availableHeight = this._currentMeasure.height;
  5906. var globalHeightPercentage = 0;
  5907. // Heights
  5908. var index = 0;
  5909. for (var _i = 0, _a = this._rowDefinitions; _i < _a.length; _i++) {
  5910. var value = _a[_i];
  5911. if (value.isPixel) {
  5912. var height = value.getValue(this._host);
  5913. availableHeight -= height;
  5914. heights[index] = height;
  5915. }
  5916. else {
  5917. globalHeightPercentage += value.internalValue;
  5918. }
  5919. index++;
  5920. }
  5921. var top = 0;
  5922. index = 0;
  5923. for (var _b = 0, _c = this._rowDefinitions; _b < _c.length; _b++) {
  5924. var value = _c[_b];
  5925. tops.push(top);
  5926. if (!value.isPixel) {
  5927. var height = (value.internalValue / globalHeightPercentage) * availableHeight;
  5928. top += height;
  5929. heights[index] = height;
  5930. }
  5931. else {
  5932. top += value.getValue(this._host);
  5933. }
  5934. index++;
  5935. }
  5936. // Widths
  5937. index = 0;
  5938. for (var _d = 0, _e = this._columnDefinitions; _d < _e.length; _d++) {
  5939. var value = _e[_d];
  5940. if (value.isPixel) {
  5941. var width = value.getValue(this._host);
  5942. availableWidth -= width;
  5943. widths[index] = width;
  5944. }
  5945. else {
  5946. globalWidthPercentage += value.internalValue;
  5947. }
  5948. index++;
  5949. }
  5950. var left = 0;
  5951. index = 0;
  5952. for (var _f = 0, _g = this._columnDefinitions; _f < _g.length; _f++) {
  5953. var value = _g[_f];
  5954. lefts.push(left);
  5955. if (!value.isPixel) {
  5956. var width = (value.internalValue / globalWidthPercentage) * availableWidth;
  5957. left += width;
  5958. widths[index] = width;
  5959. }
  5960. else {
  5961. left += value.getValue(this._host);
  5962. }
  5963. index++;
  5964. }
  5965. definitionCallback(lefts, tops, widths, heights);
  5966. };
  5967. Grid.prototype._additionalProcessing = function (parentMeasure, context) {
  5968. var _this = this;
  5969. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  5970. // Setting child sizes
  5971. for (var key in _this._cells) {
  5972. if (!_this._cells.hasOwnProperty(key)) {
  5973. continue;
  5974. }
  5975. var split = key.split(":");
  5976. var x = parseInt(split[0]);
  5977. var y = parseInt(split[1]);
  5978. var cell = _this._cells[key];
  5979. cell.left = lefts[y] + "px";
  5980. cell.top = tops[x] + "px";
  5981. cell.width = widths[y] + "px";
  5982. cell.height = heights[x] + "px";
  5983. }
  5984. });
  5985. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  5986. };
  5987. Grid.prototype._flagDescendantsAsMatrixDirty = function () {
  5988. for (var key in this._cells) {
  5989. if (!this._cells.hasOwnProperty(key)) {
  5990. continue;
  5991. }
  5992. var child = this._cells[key];
  5993. child._markMatrixAsDirty();
  5994. }
  5995. };
  5996. Grid.prototype._renderHighlightSpecific = function (context) {
  5997. var _this = this;
  5998. _super.prototype._renderHighlightSpecific.call(this, context);
  5999. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6000. // Columns
  6001. for (var index = 0; index < lefts.length; index++) {
  6002. var left = _this._currentMeasure.left + lefts[index] + widths[index];
  6003. context.beginPath();
  6004. context.moveTo(left, _this._currentMeasure.top);
  6005. context.lineTo(left, _this._currentMeasure.top + _this._currentMeasure.height);
  6006. context.stroke();
  6007. }
  6008. // Rows
  6009. for (var index = 0; index < tops.length; index++) {
  6010. var top_1 = _this._currentMeasure.top + tops[index] + heights[index];
  6011. context.beginPath();
  6012. context.moveTo(_this._currentMeasure.left, top_1);
  6013. context.lineTo(_this._currentMeasure.left + _this._currentMeasure.width, top_1);
  6014. context.stroke();
  6015. }
  6016. });
  6017. context.restore();
  6018. };
  6019. /** Releases associated resources */
  6020. Grid.prototype.dispose = function () {
  6021. _super.prototype.dispose.call(this);
  6022. for (var _i = 0, _a = this._childControls; _i < _a.length; _i++) {
  6023. var control = _a[_i];
  6024. control.dispose();
  6025. }
  6026. this._childControls = [];
  6027. };
  6028. return Grid;
  6029. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6030. /***/ }),
  6031. /***/ "./2D/controls/image.ts":
  6032. /*!******************************!*\
  6033. !*** ./2D/controls/image.ts ***!
  6034. \******************************/
  6035. /*! exports provided: Image */
  6036. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6037. "use strict";
  6038. __webpack_require__.r(__webpack_exports__);
  6039. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return Image; });
  6040. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6041. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  6042. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6043. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6044. /**
  6045. * Class used to create 2D images
  6046. */
  6047. var Image = /** @class */ (function (_super) {
  6048. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Image, _super);
  6049. /**
  6050. * Creates a new Image
  6051. * @param name defines the control name
  6052. * @param url defines the image url
  6053. */
  6054. function Image(name, url) {
  6055. if (url === void 0) { url = null; }
  6056. var _this = _super.call(this, name) || this;
  6057. _this.name = name;
  6058. _this._loaded = false;
  6059. _this._stretch = Image.STRETCH_FILL;
  6060. _this._autoScale = false;
  6061. _this._sourceLeft = 0;
  6062. _this._sourceTop = 0;
  6063. _this._sourceWidth = 0;
  6064. _this._sourceHeight = 0;
  6065. _this._cellWidth = 0;
  6066. _this._cellHeight = 0;
  6067. _this._cellId = -1;
  6068. _this._populateNinePatchSlicesFromImage = false;
  6069. /**
  6070. * Observable notified when the content is loaded
  6071. */
  6072. _this.onImageLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6073. _this.source = url;
  6074. return _this;
  6075. }
  6076. Object.defineProperty(Image.prototype, "isLoaded", {
  6077. /**
  6078. * Gets a boolean indicating that the content is loaded
  6079. */
  6080. get: function () {
  6081. return this._loaded;
  6082. },
  6083. enumerable: true,
  6084. configurable: true
  6085. });
  6086. Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
  6087. /**
  6088. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  6089. */
  6090. get: function () {
  6091. return this._populateNinePatchSlicesFromImage;
  6092. },
  6093. set: function (value) {
  6094. if (this._populateNinePatchSlicesFromImage === value) {
  6095. return;
  6096. }
  6097. this._populateNinePatchSlicesFromImage = value;
  6098. if (this._populateNinePatchSlicesFromImage && this._loaded) {
  6099. this._extractNinePatchSliceDataFromImage();
  6100. }
  6101. },
  6102. enumerable: true,
  6103. configurable: true
  6104. });
  6105. Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
  6106. /**
  6107. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  6108. * Beware using this as this will comsume more memory as the image has to be stored twice
  6109. */
  6110. get: function () {
  6111. return this._detectPointerOnOpaqueOnly;
  6112. },
  6113. set: function (value) {
  6114. if (this._detectPointerOnOpaqueOnly === value) {
  6115. return;
  6116. }
  6117. this._detectPointerOnOpaqueOnly = value;
  6118. },
  6119. enumerable: true,
  6120. configurable: true
  6121. });
  6122. Object.defineProperty(Image.prototype, "sliceLeft", {
  6123. /**
  6124. * Gets or sets the left value for slicing (9-patch)
  6125. */
  6126. get: function () {
  6127. return this._sliceLeft;
  6128. },
  6129. set: function (value) {
  6130. if (this._sliceLeft === value) {
  6131. return;
  6132. }
  6133. this._sliceLeft = value;
  6134. this._markAsDirty();
  6135. },
  6136. enumerable: true,
  6137. configurable: true
  6138. });
  6139. Object.defineProperty(Image.prototype, "sliceRight", {
  6140. /**
  6141. * Gets or sets the right value for slicing (9-patch)
  6142. */
  6143. get: function () {
  6144. return this._sliceRight;
  6145. },
  6146. set: function (value) {
  6147. if (this._sliceRight === value) {
  6148. return;
  6149. }
  6150. this._sliceRight = value;
  6151. this._markAsDirty();
  6152. },
  6153. enumerable: true,
  6154. configurable: true
  6155. });
  6156. Object.defineProperty(Image.prototype, "sliceTop", {
  6157. /**
  6158. * Gets or sets the top value for slicing (9-patch)
  6159. */
  6160. get: function () {
  6161. return this._sliceTop;
  6162. },
  6163. set: function (value) {
  6164. if (this._sliceTop === value) {
  6165. return;
  6166. }
  6167. this._sliceTop = value;
  6168. this._markAsDirty();
  6169. },
  6170. enumerable: true,
  6171. configurable: true
  6172. });
  6173. Object.defineProperty(Image.prototype, "sliceBottom", {
  6174. /**
  6175. * Gets or sets the bottom value for slicing (9-patch)
  6176. */
  6177. get: function () {
  6178. return this._sliceBottom;
  6179. },
  6180. set: function (value) {
  6181. if (this._sliceBottom === value) {
  6182. return;
  6183. }
  6184. this._sliceBottom = value;
  6185. this._markAsDirty();
  6186. },
  6187. enumerable: true,
  6188. configurable: true
  6189. });
  6190. Object.defineProperty(Image.prototype, "sourceLeft", {
  6191. /**
  6192. * Gets or sets the left coordinate in the source image
  6193. */
  6194. get: function () {
  6195. return this._sourceLeft;
  6196. },
  6197. set: function (value) {
  6198. if (this._sourceLeft === value) {
  6199. return;
  6200. }
  6201. this._sourceLeft = value;
  6202. this._markAsDirty();
  6203. },
  6204. enumerable: true,
  6205. configurable: true
  6206. });
  6207. Object.defineProperty(Image.prototype, "sourceTop", {
  6208. /**
  6209. * Gets or sets the top coordinate in the source image
  6210. */
  6211. get: function () {
  6212. return this._sourceTop;
  6213. },
  6214. set: function (value) {
  6215. if (this._sourceTop === value) {
  6216. return;
  6217. }
  6218. this._sourceTop = value;
  6219. this._markAsDirty();
  6220. },
  6221. enumerable: true,
  6222. configurable: true
  6223. });
  6224. Object.defineProperty(Image.prototype, "sourceWidth", {
  6225. /**
  6226. * Gets or sets the width to capture in the source image
  6227. */
  6228. get: function () {
  6229. return this._sourceWidth;
  6230. },
  6231. set: function (value) {
  6232. if (this._sourceWidth === value) {
  6233. return;
  6234. }
  6235. this._sourceWidth = value;
  6236. this._markAsDirty();
  6237. },
  6238. enumerable: true,
  6239. configurable: true
  6240. });
  6241. Object.defineProperty(Image.prototype, "sourceHeight", {
  6242. /**
  6243. * Gets or sets the height to capture in the source image
  6244. */
  6245. get: function () {
  6246. return this._sourceHeight;
  6247. },
  6248. set: function (value) {
  6249. if (this._sourceHeight === value) {
  6250. return;
  6251. }
  6252. this._sourceHeight = value;
  6253. this._markAsDirty();
  6254. },
  6255. enumerable: true,
  6256. configurable: true
  6257. });
  6258. Object.defineProperty(Image.prototype, "autoScale", {
  6259. /**
  6260. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  6261. * @see http://doc.babylonjs.com/how_to/gui#image
  6262. */
  6263. get: function () {
  6264. return this._autoScale;
  6265. },
  6266. set: function (value) {
  6267. if (this._autoScale === value) {
  6268. return;
  6269. }
  6270. this._autoScale = value;
  6271. if (value && this._loaded) {
  6272. this.synchronizeSizeWithContent();
  6273. }
  6274. },
  6275. enumerable: true,
  6276. configurable: true
  6277. });
  6278. Object.defineProperty(Image.prototype, "stretch", {
  6279. /** Gets or sets the streching mode used by the image */
  6280. get: function () {
  6281. return this._stretch;
  6282. },
  6283. set: function (value) {
  6284. if (this._stretch === value) {
  6285. return;
  6286. }
  6287. this._stretch = value;
  6288. this._markAsDirty();
  6289. },
  6290. enumerable: true,
  6291. configurable: true
  6292. });
  6293. Object.defineProperty(Image.prototype, "domImage", {
  6294. get: function () {
  6295. return this._domImage;
  6296. },
  6297. /**
  6298. * Gets or sets the internal DOM image used to render the control
  6299. */
  6300. set: function (value) {
  6301. var _this = this;
  6302. this._domImage = value;
  6303. this._loaded = false;
  6304. if (this._domImage.width) {
  6305. this._onImageLoaded();
  6306. }
  6307. else {
  6308. this._domImage.onload = function () {
  6309. _this._onImageLoaded();
  6310. };
  6311. }
  6312. },
  6313. enumerable: true,
  6314. configurable: true
  6315. });
  6316. Image.prototype._onImageLoaded = function () {
  6317. this._imageWidth = this._domImage.width;
  6318. this._imageHeight = this._domImage.height;
  6319. this._loaded = true;
  6320. if (this._populateNinePatchSlicesFromImage) {
  6321. this._extractNinePatchSliceDataFromImage();
  6322. }
  6323. if (this._autoScale) {
  6324. this.synchronizeSizeWithContent();
  6325. }
  6326. this.onImageLoadedObservable.notifyObservers(this);
  6327. this._markAsDirty();
  6328. };
  6329. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  6330. if (!Image._WorkingCanvas) {
  6331. Image._WorkingCanvas = document.createElement('canvas');
  6332. }
  6333. var canvas = Image._WorkingCanvas;
  6334. var context = canvas.getContext('2d');
  6335. var width = this._domImage.width;
  6336. var height = this._domImage.height;
  6337. canvas.width = width;
  6338. canvas.height = height;
  6339. context.drawImage(this._domImage, 0, 0, width, height);
  6340. var imageData = context.getImageData(0, 0, width, height);
  6341. // Left and right
  6342. this._sliceLeft = -1;
  6343. this._sliceRight = -1;
  6344. for (var x = 0; x < width; x++) {
  6345. var alpha = imageData.data[x * 4 + 3];
  6346. if (alpha > 127 && this._sliceLeft === -1) {
  6347. this._sliceLeft = x;
  6348. continue;
  6349. }
  6350. if (alpha < 127 && this._sliceLeft > -1) {
  6351. this._sliceRight = x;
  6352. break;
  6353. }
  6354. }
  6355. // top and bottom
  6356. this._sliceTop = -1;
  6357. this._sliceBottom = -1;
  6358. for (var y = 0; y < height; y++) {
  6359. var alpha = imageData.data[y * width * 4 + 3];
  6360. if (alpha > 127 && this._sliceTop === -1) {
  6361. this._sliceTop = y;
  6362. continue;
  6363. }
  6364. if (alpha < 127 && this._sliceTop > -1) {
  6365. this._sliceBottom = y;
  6366. break;
  6367. }
  6368. }
  6369. };
  6370. Object.defineProperty(Image.prototype, "source", {
  6371. /**
  6372. * Gets or sets image source url
  6373. */
  6374. set: function (value) {
  6375. var _this = this;
  6376. if (this._source === value) {
  6377. return;
  6378. }
  6379. this._loaded = false;
  6380. this._source = value;
  6381. this._domImage = document.createElement("img");
  6382. this._domImage.onload = function () {
  6383. _this._onImageLoaded();
  6384. };
  6385. if (value) {
  6386. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  6387. this._domImage.src = value;
  6388. }
  6389. },
  6390. enumerable: true,
  6391. configurable: true
  6392. });
  6393. Object.defineProperty(Image.prototype, "cellWidth", {
  6394. /**
  6395. * Gets or sets the cell width to use when animation sheet is enabled
  6396. * @see http://doc.babylonjs.com/how_to/gui#image
  6397. */
  6398. get: function () {
  6399. return this._cellWidth;
  6400. },
  6401. set: function (value) {
  6402. if (this._cellWidth === value) {
  6403. return;
  6404. }
  6405. this._cellWidth = value;
  6406. this._markAsDirty();
  6407. },
  6408. enumerable: true,
  6409. configurable: true
  6410. });
  6411. Object.defineProperty(Image.prototype, "cellHeight", {
  6412. /**
  6413. * Gets or sets the cell height to use when animation sheet is enabled
  6414. * @see http://doc.babylonjs.com/how_to/gui#image
  6415. */
  6416. get: function () {
  6417. return this._cellHeight;
  6418. },
  6419. set: function (value) {
  6420. if (this._cellHeight === value) {
  6421. return;
  6422. }
  6423. this._cellHeight = value;
  6424. this._markAsDirty();
  6425. },
  6426. enumerable: true,
  6427. configurable: true
  6428. });
  6429. Object.defineProperty(Image.prototype, "cellId", {
  6430. /**
  6431. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  6432. * @see http://doc.babylonjs.com/how_to/gui#image
  6433. */
  6434. get: function () {
  6435. return this._cellId;
  6436. },
  6437. set: function (value) {
  6438. if (this._cellId === value) {
  6439. return;
  6440. }
  6441. this._cellId = value;
  6442. this._markAsDirty();
  6443. },
  6444. enumerable: true,
  6445. configurable: true
  6446. });
  6447. /**
  6448. * Tests if a given coordinates belong to the current control
  6449. * @param x defines x coordinate to test
  6450. * @param y defines y coordinate to test
  6451. * @returns true if the coordinates are inside the control
  6452. */
  6453. Image.prototype.contains = function (x, y) {
  6454. if (!_super.prototype.contains.call(this, x, y)) {
  6455. return false;
  6456. }
  6457. if (!this._detectPointerOnOpaqueOnly || !Image._WorkingCanvas) {
  6458. return true;
  6459. }
  6460. var canvas = Image._WorkingCanvas;
  6461. var context = canvas.getContext("2d");
  6462. var width = this._currentMeasure.width | 0;
  6463. var height = this._currentMeasure.height | 0;
  6464. var imageData = context.getImageData(0, 0, width, height).data;
  6465. x = (x - this._currentMeasure.left) | 0;
  6466. y = (y - this._currentMeasure.top) | 0;
  6467. var pickedPixel = imageData[(x + y * this._currentMeasure.width) * 4 + 3];
  6468. return pickedPixel > 0;
  6469. };
  6470. Image.prototype._getTypeName = function () {
  6471. return "Image";
  6472. };
  6473. /** Force the control to synchronize with its content */
  6474. Image.prototype.synchronizeSizeWithContent = function () {
  6475. if (!this._loaded) {
  6476. return;
  6477. }
  6478. this.width = this._domImage.width + "px";
  6479. this.height = this._domImage.height + "px";
  6480. };
  6481. Image.prototype._processMeasures = function (parentMeasure, context) {
  6482. if (this._loaded) {
  6483. switch (this._stretch) {
  6484. case Image.STRETCH_NONE:
  6485. break;
  6486. case Image.STRETCH_FILL:
  6487. break;
  6488. case Image.STRETCH_UNIFORM:
  6489. break;
  6490. case Image.STRETCH_NINE_PATCH:
  6491. break;
  6492. case Image.STRETCH_EXTEND:
  6493. if (this._autoScale) {
  6494. this.synchronizeSizeWithContent();
  6495. }
  6496. if (this.parent && this.parent.parent) { // Will update root size if root is not the top root
  6497. this.parent.adaptWidthToChildren = true;
  6498. this.parent.adaptHeightToChildren = true;
  6499. }
  6500. break;
  6501. }
  6502. }
  6503. _super.prototype._processMeasures.call(this, parentMeasure, context);
  6504. };
  6505. Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
  6506. if (!this._detectPointerOnOpaqueOnly) {
  6507. return;
  6508. }
  6509. if (!Image._WorkingCanvas) {
  6510. Image._WorkingCanvas = document.createElement('canvas');
  6511. }
  6512. var canvas = Image._WorkingCanvas;
  6513. var width = this._currentMeasure.width;
  6514. var height = this._currentMeasure.height;
  6515. var context = canvas.getContext("2d");
  6516. canvas.width = width;
  6517. canvas.height = height;
  6518. context.clearRect(0, 0, width, height);
  6519. };
  6520. Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
  6521. context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
  6522. if (!this._detectPointerOnOpaqueOnly) {
  6523. return;
  6524. }
  6525. var canvas = Image._WorkingCanvas;
  6526. context = canvas.getContext("2d");
  6527. context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
  6528. };
  6529. Image.prototype._draw = function (context) {
  6530. context.save();
  6531. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  6532. context.shadowColor = this.shadowColor;
  6533. context.shadowBlur = this.shadowBlur;
  6534. context.shadowOffsetX = this.shadowOffsetX;
  6535. context.shadowOffsetY = this.shadowOffsetY;
  6536. }
  6537. var x, y, width, height;
  6538. if (this.cellId == -1) {
  6539. x = this._sourceLeft;
  6540. y = this._sourceTop;
  6541. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  6542. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  6543. }
  6544. else {
  6545. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  6546. var column = (this.cellId / rowCount) >> 0;
  6547. var row = this.cellId % rowCount;
  6548. x = this.cellWidth * row;
  6549. y = this.cellHeight * column;
  6550. width = this.cellWidth;
  6551. height = this.cellHeight;
  6552. }
  6553. this._prepareWorkingCanvasForOpaqueDetection();
  6554. this._applyStates(context);
  6555. if (this._loaded) {
  6556. switch (this._stretch) {
  6557. case Image.STRETCH_NONE:
  6558. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6559. break;
  6560. case Image.STRETCH_FILL:
  6561. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6562. break;
  6563. case Image.STRETCH_UNIFORM:
  6564. var hRatio = this._currentMeasure.width / width;
  6565. var vRatio = this._currentMeasure.height / height;
  6566. var ratio = Math.min(hRatio, vRatio);
  6567. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  6568. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  6569. this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  6570. break;
  6571. case Image.STRETCH_EXTEND:
  6572. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6573. break;
  6574. case Image.STRETCH_NINE_PATCH:
  6575. this._renderNinePatch(context);
  6576. break;
  6577. }
  6578. }
  6579. context.restore();
  6580. };
  6581. Image.prototype._renderCornerPatch = function (context, x, y, width, height, targetX, targetY) {
  6582. this._drawImage(context, x, y, width, height, this._currentMeasure.left + targetX, this._currentMeasure.top + targetY, width, height);
  6583. };
  6584. Image.prototype._renderNinePatch = function (context) {
  6585. var height = this._imageHeight;
  6586. var leftWidth = this._sliceLeft;
  6587. var topHeight = this._sliceTop;
  6588. var bottomHeight = this._imageHeight - this._sliceBottom;
  6589. var rightWidth = this._imageWidth - this._sliceRight;
  6590. var left = 0;
  6591. var top = 0;
  6592. if (this._populateNinePatchSlicesFromImage) {
  6593. left = 1;
  6594. top = 1;
  6595. height -= 2;
  6596. leftWidth -= 1;
  6597. topHeight -= 1;
  6598. bottomHeight -= 1;
  6599. rightWidth -= 1;
  6600. }
  6601. var centerWidth = this._sliceRight - this._sliceLeft + 1;
  6602. var targetCenterWidth = this._currentMeasure.width - rightWidth - this.sliceLeft + 1;
  6603. var targetTopHeight = this._currentMeasure.height - height + this._sliceBottom;
  6604. // Corners
  6605. this._renderCornerPatch(context, left, top, leftWidth, topHeight, 0, 0);
  6606. this._renderCornerPatch(context, left, this._sliceBottom, leftWidth, height - this._sliceBottom, 0, targetTopHeight);
  6607. this._renderCornerPatch(context, this._sliceRight, top, rightWidth, topHeight, this._currentMeasure.width - rightWidth, 0);
  6608. this._renderCornerPatch(context, this._sliceRight, this._sliceBottom, rightWidth, height - this._sliceBottom, this._currentMeasure.width - rightWidth, targetTopHeight);
  6609. // Center
  6610. this._drawImage(context, this._sliceLeft, this._sliceTop, centerWidth, this._sliceBottom - this._sliceTop + 1, this._currentMeasure.left + leftWidth, this._currentMeasure.top + topHeight, targetCenterWidth, targetTopHeight - topHeight + 1);
  6611. // Borders
  6612. this._drawImage(context, left, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  6613. this._drawImage(context, this._sliceRight, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left + this._currentMeasure.width - rightWidth, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  6614. this._drawImage(context, this._sliceLeft, top, centerWidth, topHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top, targetCenterWidth, topHeight);
  6615. this._drawImage(context, this._sliceLeft, this._sliceBottom, centerWidth, bottomHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top + targetTopHeight, targetCenterWidth, bottomHeight);
  6616. };
  6617. Image.prototype.dispose = function () {
  6618. _super.prototype.dispose.call(this);
  6619. this.onImageLoadedObservable.clear();
  6620. };
  6621. Image._WorkingCanvas = null;
  6622. // Static
  6623. /** STRETCH_NONE */
  6624. Image.STRETCH_NONE = 0;
  6625. /** STRETCH_FILL */
  6626. Image.STRETCH_FILL = 1;
  6627. /** STRETCH_UNIFORM */
  6628. Image.STRETCH_UNIFORM = 2;
  6629. /** STRETCH_EXTEND */
  6630. Image.STRETCH_EXTEND = 3;
  6631. /** NINE_PATCH */
  6632. Image.STRETCH_NINE_PATCH = 4;
  6633. return Image;
  6634. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  6635. /***/ }),
  6636. /***/ "./2D/controls/index.ts":
  6637. /*!******************************!*\
  6638. !*** ./2D/controls/index.ts ***!
  6639. \******************************/
  6640. /*! exports provided: Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, name */
  6641. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6642. "use strict";
  6643. __webpack_require__.r(__webpack_exports__);
  6644. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  6645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  6646. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  6647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  6648. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  6649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  6650. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  6651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  6652. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  6654. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  6655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  6656. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  6657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]; });
  6658. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  6659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_7__["Image"]; });
  6660. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_8__["InputText"]; });
  6662. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  6663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_9__["InputPassword"]; });
  6664. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  6665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_10__["Line"]; });
  6666. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  6667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_11__["MultiLine"]; });
  6668. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  6669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_12__["RadioButton"]; });
  6670. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  6671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_13__["StackPanel"]; });
  6672. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  6673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectorGroup"]; });
  6674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["CheckboxGroup"]; });
  6675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["RadioGroup"]; });
  6676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SliderGroup"]; });
  6677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectionPanel"]; });
  6678. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  6679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__["ScrollViewer"]; });
  6680. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  6681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextWrapping"]; });
  6682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextBlock"]; });
  6683. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  6684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["KeyPropertySet"]; });
  6685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["VirtualKeyboard"]; });
  6686. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  6687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_18__["Rectangle"]; });
  6688. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  6689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_19__["DisplayGrid"]; });
  6690. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  6691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__["BaseSlider"]; });
  6692. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  6693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_21__["Slider"]; });
  6694. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  6695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__["ImageBasedSlider"]; });
  6696. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  6697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_23__["name"]; });
  6698. /***/ }),
  6699. /***/ "./2D/controls/inputPassword.ts":
  6700. /*!**************************************!*\
  6701. !*** ./2D/controls/inputPassword.ts ***!
  6702. \**************************************/
  6703. /*! exports provided: InputPassword */
  6704. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6705. "use strict";
  6706. __webpack_require__.r(__webpack_exports__);
  6707. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  6708. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6709. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6710. /**
  6711. * Class used to create a password control
  6712. */
  6713. var InputPassword = /** @class */ (function (_super) {
  6714. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InputPassword, _super);
  6715. function InputPassword() {
  6716. return _super !== null && _super.apply(this, arguments) || this;
  6717. }
  6718. InputPassword.prototype._beforeRenderText = function (text) {
  6719. var txt = "";
  6720. for (var i = 0; i < text.length; i++) {
  6721. txt += "\u2022";
  6722. }
  6723. return txt;
  6724. };
  6725. return InputPassword;
  6726. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  6727. /***/ }),
  6728. /***/ "./2D/controls/inputText.ts":
  6729. /*!**********************************!*\
  6730. !*** ./2D/controls/inputText.ts ***!
  6731. \**********************************/
  6732. /*! exports provided: InputText */
  6733. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6734. "use strict";
  6735. __webpack_require__.r(__webpack_exports__);
  6736. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  6737. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6738. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  6739. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6740. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6741. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  6742. /**
  6743. * Class used to create input text control
  6744. */
  6745. var InputText = /** @class */ (function (_super) {
  6746. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InputText, _super);
  6747. /**
  6748. * Creates a new InputText
  6749. * @param name defines the control name
  6750. * @param text defines the text of the control
  6751. */
  6752. function InputText(name, text) {
  6753. if (text === void 0) { text = ""; }
  6754. var _this = _super.call(this, name) || this;
  6755. _this.name = name;
  6756. _this._text = "";
  6757. _this._placeholderText = "";
  6758. _this._background = "#222222";
  6759. _this._focusedBackground = "#000000";
  6760. _this._focusedColor = "white";
  6761. _this._placeholderColor = "gray";
  6762. _this._thickness = 1;
  6763. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  6764. _this._autoStretchWidth = true;
  6765. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  6766. _this._isFocused = false;
  6767. _this._blinkIsEven = false;
  6768. _this._cursorOffset = 0;
  6769. _this._deadKey = false;
  6770. _this._addKey = true;
  6771. _this._currentKey = "";
  6772. _this._isTextHighlightOn = false;
  6773. _this._textHighlightColor = "#d5e0ff";
  6774. _this._highligherOpacity = 0.4;
  6775. _this._highlightedText = "";
  6776. _this._startHighlightIndex = 0;
  6777. _this._endHighlightIndex = 0;
  6778. _this._cursorIndex = -1;
  6779. _this._onFocusSelectAll = false;
  6780. _this._isPointerDown = false;
  6781. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  6782. _this.promptMessage = "Please enter text:";
  6783. /** Observable raised when the text changes */
  6784. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6785. /** Observable raised just before an entered character is to be added */
  6786. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6787. /** Observable raised when the control gets the focus */
  6788. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6789. /** Observable raised when the control loses the focus */
  6790. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6791. /**Observable raised when the text is highlighted */
  6792. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6793. /**Observable raised when copy event is triggered */
  6794. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6795. /** Observable raised when cut event is triggered */
  6796. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6797. /** Observable raised when paste event is triggered */
  6798. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6799. /** Observable raised when a key event was processed */
  6800. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6801. _this.text = text;
  6802. _this.isPointerBlocker = true;
  6803. return _this;
  6804. }
  6805. Object.defineProperty(InputText.prototype, "maxWidth", {
  6806. /** Gets or sets the maximum width allowed by the control */
  6807. get: function () {
  6808. return this._maxWidth.toString(this._host);
  6809. },
  6810. set: function (value) {
  6811. if (this._maxWidth.toString(this._host) === value) {
  6812. return;
  6813. }
  6814. if (this._maxWidth.fromString(value)) {
  6815. this._markAsDirty();
  6816. }
  6817. },
  6818. enumerable: true,
  6819. configurable: true
  6820. });
  6821. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  6822. /** Gets the maximum width allowed by the control in pixels */
  6823. get: function () {
  6824. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  6825. },
  6826. enumerable: true,
  6827. configurable: true
  6828. });
  6829. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  6830. /** Gets or sets the text highlighter transparency; default: 0.4 */
  6831. get: function () {
  6832. return this._highligherOpacity;
  6833. },
  6834. set: function (value) {
  6835. if (this._highligherOpacity === value) {
  6836. return;
  6837. }
  6838. this._highligherOpacity = value;
  6839. this._markAsDirty();
  6840. },
  6841. enumerable: true,
  6842. configurable: true
  6843. });
  6844. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  6845. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  6846. get: function () {
  6847. return this._onFocusSelectAll;
  6848. },
  6849. set: function (value) {
  6850. if (this._onFocusSelectAll === value) {
  6851. return;
  6852. }
  6853. this._onFocusSelectAll = value;
  6854. this._markAsDirty();
  6855. },
  6856. enumerable: true,
  6857. configurable: true
  6858. });
  6859. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  6860. /** Gets or sets the text hightlight color */
  6861. get: function () {
  6862. return this._textHighlightColor;
  6863. },
  6864. set: function (value) {
  6865. if (this._textHighlightColor === value) {
  6866. return;
  6867. }
  6868. this._textHighlightColor = value;
  6869. this._markAsDirty();
  6870. },
  6871. enumerable: true,
  6872. configurable: true
  6873. });
  6874. Object.defineProperty(InputText.prototype, "margin", {
  6875. /** Gets or sets control margin */
  6876. get: function () {
  6877. return this._margin.toString(this._host);
  6878. },
  6879. set: function (value) {
  6880. if (this._margin.toString(this._host) === value) {
  6881. return;
  6882. }
  6883. if (this._margin.fromString(value)) {
  6884. this._markAsDirty();
  6885. }
  6886. },
  6887. enumerable: true,
  6888. configurable: true
  6889. });
  6890. Object.defineProperty(InputText.prototype, "marginInPixels", {
  6891. /** Gets control margin in pixels */
  6892. get: function () {
  6893. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  6894. },
  6895. enumerable: true,
  6896. configurable: true
  6897. });
  6898. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  6899. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  6900. get: function () {
  6901. return this._autoStretchWidth;
  6902. },
  6903. set: function (value) {
  6904. if (this._autoStretchWidth === value) {
  6905. return;
  6906. }
  6907. this._autoStretchWidth = value;
  6908. this._markAsDirty();
  6909. },
  6910. enumerable: true,
  6911. configurable: true
  6912. });
  6913. Object.defineProperty(InputText.prototype, "thickness", {
  6914. /** Gets or sets border thickness */
  6915. get: function () {
  6916. return this._thickness;
  6917. },
  6918. set: function (value) {
  6919. if (this._thickness === value) {
  6920. return;
  6921. }
  6922. this._thickness = value;
  6923. this._markAsDirty();
  6924. },
  6925. enumerable: true,
  6926. configurable: true
  6927. });
  6928. Object.defineProperty(InputText.prototype, "focusedBackground", {
  6929. /** Gets or sets the background color when focused */
  6930. get: function () {
  6931. return this._focusedBackground;
  6932. },
  6933. set: function (value) {
  6934. if (this._focusedBackground === value) {
  6935. return;
  6936. }
  6937. this._focusedBackground = value;
  6938. this._markAsDirty();
  6939. },
  6940. enumerable: true,
  6941. configurable: true
  6942. });
  6943. Object.defineProperty(InputText.prototype, "focusedColor", {
  6944. /** Gets or sets the background color when focused */
  6945. get: function () {
  6946. return this._focusedColor;
  6947. },
  6948. set: function (value) {
  6949. if (this._focusedColor === value) {
  6950. return;
  6951. }
  6952. this._focusedColor = value;
  6953. this._markAsDirty();
  6954. },
  6955. enumerable: true,
  6956. configurable: true
  6957. });
  6958. Object.defineProperty(InputText.prototype, "background", {
  6959. /** Gets or sets the background color */
  6960. get: function () {
  6961. return this._background;
  6962. },
  6963. set: function (value) {
  6964. if (this._background === value) {
  6965. return;
  6966. }
  6967. this._background = value;
  6968. this._markAsDirty();
  6969. },
  6970. enumerable: true,
  6971. configurable: true
  6972. });
  6973. Object.defineProperty(InputText.prototype, "placeholderColor", {
  6974. /** Gets or sets the placeholder color */
  6975. get: function () {
  6976. return this._placeholderColor;
  6977. },
  6978. set: function (value) {
  6979. if (this._placeholderColor === value) {
  6980. return;
  6981. }
  6982. this._placeholderColor = value;
  6983. this._markAsDirty();
  6984. },
  6985. enumerable: true,
  6986. configurable: true
  6987. });
  6988. Object.defineProperty(InputText.prototype, "placeholderText", {
  6989. /** Gets or sets the text displayed when the control is empty */
  6990. get: function () {
  6991. return this._placeholderText;
  6992. },
  6993. set: function (value) {
  6994. if (this._placeholderText === value) {
  6995. return;
  6996. }
  6997. this._placeholderText = value;
  6998. this._markAsDirty();
  6999. },
  7000. enumerable: true,
  7001. configurable: true
  7002. });
  7003. Object.defineProperty(InputText.prototype, "deadKey", {
  7004. /** Gets or sets the dead key flag */
  7005. get: function () {
  7006. return this._deadKey;
  7007. },
  7008. set: function (flag) {
  7009. this._deadKey = flag;
  7010. },
  7011. enumerable: true,
  7012. configurable: true
  7013. });
  7014. Object.defineProperty(InputText.prototype, "highlightedText", {
  7015. /** Gets or sets the highlight text */
  7016. get: function () {
  7017. return this._highlightedText;
  7018. },
  7019. set: function (text) {
  7020. if (this._highlightedText === text) {
  7021. return;
  7022. }
  7023. this._highlightedText = text;
  7024. this._markAsDirty();
  7025. },
  7026. enumerable: true,
  7027. configurable: true
  7028. });
  7029. Object.defineProperty(InputText.prototype, "addKey", {
  7030. /** Gets or sets if the current key should be added */
  7031. get: function () {
  7032. return this._addKey;
  7033. },
  7034. set: function (flag) {
  7035. this._addKey = flag;
  7036. },
  7037. enumerable: true,
  7038. configurable: true
  7039. });
  7040. Object.defineProperty(InputText.prototype, "currentKey", {
  7041. /** Gets or sets the value of the current key being entered */
  7042. get: function () {
  7043. return this._currentKey;
  7044. },
  7045. set: function (key) {
  7046. this._currentKey = key;
  7047. },
  7048. enumerable: true,
  7049. configurable: true
  7050. });
  7051. Object.defineProperty(InputText.prototype, "text", {
  7052. /** Gets or sets the text displayed in the control */
  7053. get: function () {
  7054. return this._text;
  7055. },
  7056. set: function (value) {
  7057. var valueAsString = value.toString(); // Forcing convertion
  7058. if (this._text === valueAsString) {
  7059. return;
  7060. }
  7061. this._text = valueAsString;
  7062. this._markAsDirty();
  7063. this.onTextChangedObservable.notifyObservers(this);
  7064. },
  7065. enumerable: true,
  7066. configurable: true
  7067. });
  7068. Object.defineProperty(InputText.prototype, "width", {
  7069. /** Gets or sets control width */
  7070. get: function () {
  7071. return this._width.toString(this._host);
  7072. },
  7073. set: function (value) {
  7074. if (this._width.toString(this._host) === value) {
  7075. return;
  7076. }
  7077. if (this._width.fromString(value)) {
  7078. this._markAsDirty();
  7079. }
  7080. this.autoStretchWidth = false;
  7081. },
  7082. enumerable: true,
  7083. configurable: true
  7084. });
  7085. /** @hidden */
  7086. InputText.prototype.onBlur = function () {
  7087. this._isFocused = false;
  7088. this._scrollLeft = null;
  7089. this._cursorOffset = 0;
  7090. clearTimeout(this._blinkTimeout);
  7091. this._markAsDirty();
  7092. this.onBlurObservable.notifyObservers(this);
  7093. this._host.unRegisterClipboardEvents();
  7094. if (this._onClipboardObserver) {
  7095. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  7096. }
  7097. var scene = this._host.getScene();
  7098. if (this._onPointerDblTapObserver && scene) {
  7099. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  7100. }
  7101. };
  7102. /** @hidden */
  7103. InputText.prototype.onFocus = function () {
  7104. var _this = this;
  7105. if (!this._isEnabled) {
  7106. return;
  7107. }
  7108. this._scrollLeft = null;
  7109. this._isFocused = true;
  7110. this._blinkIsEven = false;
  7111. this._cursorOffset = 0;
  7112. this._markAsDirty();
  7113. this.onFocusObservable.notifyObservers(this);
  7114. if (navigator.userAgent.indexOf("Mobile") !== -1) {
  7115. var value = prompt(this.promptMessage);
  7116. if (value !== null) {
  7117. this.text = value;
  7118. }
  7119. this._host.focusedControl = null;
  7120. return;
  7121. }
  7122. this._host.registerClipboardEvents();
  7123. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  7124. // process clipboard event, can be configured.
  7125. switch (clipboardInfo.type) {
  7126. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  7127. _this._onCopyText(clipboardInfo.event);
  7128. _this.onTextCopyObservable.notifyObservers(_this);
  7129. break;
  7130. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  7131. _this._onCutText(clipboardInfo.event);
  7132. _this.onTextCutObservable.notifyObservers(_this);
  7133. break;
  7134. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  7135. _this._onPasteText(clipboardInfo.event);
  7136. _this.onTextPasteObservable.notifyObservers(_this);
  7137. break;
  7138. default: return;
  7139. }
  7140. });
  7141. var scene = this._host.getScene();
  7142. if (scene) {
  7143. //register the pointer double tap event
  7144. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  7145. if (!_this._isFocused) {
  7146. return;
  7147. }
  7148. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  7149. _this._processDblClick(pointerInfo);
  7150. }
  7151. });
  7152. }
  7153. if (this._onFocusSelectAll) {
  7154. this._selectAllText();
  7155. }
  7156. };
  7157. InputText.prototype._getTypeName = function () {
  7158. return "InputText";
  7159. };
  7160. /**
  7161. * Function called to get the list of controls that should not steal the focus from this control
  7162. * @returns an array of controls
  7163. */
  7164. InputText.prototype.keepsFocusWith = function () {
  7165. if (!this._connectedVirtualKeyboard) {
  7166. return null;
  7167. }
  7168. return [this._connectedVirtualKeyboard];
  7169. };
  7170. /** @hidden */
  7171. InputText.prototype.processKey = function (keyCode, key, evt) {
  7172. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  7173. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  7174. return;
  7175. }
  7176. //select all
  7177. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  7178. this._selectAllText();
  7179. evt.preventDefault();
  7180. return;
  7181. }
  7182. // Specific cases
  7183. switch (keyCode) {
  7184. case 32: //SPACE
  7185. key = " "; //ie11 key for space is "Spacebar"
  7186. break;
  7187. case 191: //SLASH
  7188. if (evt) {
  7189. evt.preventDefault();
  7190. }
  7191. break;
  7192. case 8: // BACKSPACE
  7193. if (this._text && this._text.length > 0) {
  7194. //delete the highlighted text
  7195. if (this._isTextHighlightOn) {
  7196. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7197. this._isTextHighlightOn = false;
  7198. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7199. this._blinkIsEven = false;
  7200. if (evt) {
  7201. evt.preventDefault();
  7202. }
  7203. return;
  7204. }
  7205. //delete single character
  7206. if (this._cursorOffset === 0) {
  7207. this.text = this._text.substr(0, this._text.length - 1);
  7208. }
  7209. else {
  7210. var deletePosition = this._text.length - this._cursorOffset;
  7211. if (deletePosition > 0) {
  7212. this.text = this._text.slice(0, deletePosition - 1) + this._text.slice(deletePosition);
  7213. }
  7214. }
  7215. }
  7216. if (evt) {
  7217. evt.preventDefault();
  7218. }
  7219. return;
  7220. case 46: // DELETE
  7221. if (this._isTextHighlightOn) {
  7222. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7223. var decrementor = (this._endHighlightIndex - this._startHighlightIndex);
  7224. while (decrementor > 0 && this._cursorOffset > 0) {
  7225. this._cursorOffset--;
  7226. }
  7227. this._isTextHighlightOn = false;
  7228. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7229. if (evt) {
  7230. evt.preventDefault();
  7231. }
  7232. return;
  7233. }
  7234. if (this._text && this._text.length > 0 && this._cursorOffset > 0) {
  7235. var deletePosition = this._text.length - this._cursorOffset;
  7236. this.text = this._text.slice(0, deletePosition) + this._text.slice(deletePosition + 1);
  7237. this._cursorOffset--;
  7238. }
  7239. if (evt) {
  7240. evt.preventDefault();
  7241. }
  7242. return;
  7243. case 13: // RETURN
  7244. this._host.focusedControl = null;
  7245. this._isTextHighlightOn = false;
  7246. return;
  7247. case 35: // END
  7248. this._cursorOffset = 0;
  7249. this._blinkIsEven = false;
  7250. this._isTextHighlightOn = false;
  7251. this._markAsDirty();
  7252. return;
  7253. case 36: // HOME
  7254. this._cursorOffset = this._text.length;
  7255. this._blinkIsEven = false;
  7256. this._isTextHighlightOn = false;
  7257. this._markAsDirty();
  7258. return;
  7259. case 37: // LEFT
  7260. this._cursorOffset++;
  7261. if (this._cursorOffset > this._text.length) {
  7262. this._cursorOffset = this._text.length;
  7263. }
  7264. if (evt && evt.shiftKey) {
  7265. // update the cursor
  7266. this._blinkIsEven = false;
  7267. // shift + ctrl/cmd + <-
  7268. if (evt.ctrlKey || evt.metaKey) {
  7269. if (!this._isTextHighlightOn) {
  7270. if (this._text.length === this._cursorOffset) {
  7271. return;
  7272. }
  7273. else {
  7274. this._endHighlightIndex = this._text.length - this._cursorOffset + 1;
  7275. }
  7276. }
  7277. this._startHighlightIndex = 0;
  7278. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7279. this._cursorOffset = this._text.length;
  7280. this._isTextHighlightOn = true;
  7281. this._markAsDirty();
  7282. return;
  7283. }
  7284. //store the starting point
  7285. if (!this._isTextHighlightOn) {
  7286. this._isTextHighlightOn = true;
  7287. this._cursorIndex = (this._cursorOffset >= this._text.length) ? this._text.length : this._cursorOffset - 1;
  7288. }
  7289. //if text is already highlighted
  7290. else if (this._cursorIndex === -1) {
  7291. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7292. this._cursorOffset = (this._startHighlightIndex === 0) ? this._text.length : this._text.length - this._startHighlightIndex + 1;
  7293. }
  7294. //set the highlight indexes
  7295. if (this._cursorIndex < this._cursorOffset) {
  7296. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7297. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7298. }
  7299. else if (this._cursorIndex > this._cursorOffset) {
  7300. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7301. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7302. }
  7303. else {
  7304. this._isTextHighlightOn = false;
  7305. }
  7306. this._markAsDirty();
  7307. return;
  7308. }
  7309. if (this._isTextHighlightOn) {
  7310. this._cursorOffset = this._text.length - this._startHighlightIndex;
  7311. this._isTextHighlightOn = false;
  7312. }
  7313. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7314. this._cursorOffset = this.text.length;
  7315. evt.preventDefault();
  7316. }
  7317. this._blinkIsEven = false;
  7318. this._isTextHighlightOn = false;
  7319. this._cursorIndex = -1;
  7320. this._markAsDirty();
  7321. return;
  7322. case 39: // RIGHT
  7323. this._cursorOffset--;
  7324. if (this._cursorOffset < 0) {
  7325. this._cursorOffset = 0;
  7326. }
  7327. if (evt && evt.shiftKey) {
  7328. //update the cursor
  7329. this._blinkIsEven = false;
  7330. //shift + ctrl/cmd + ->
  7331. if (evt.ctrlKey || evt.metaKey) {
  7332. if (!this._isTextHighlightOn) {
  7333. if (this._cursorOffset === 0) {
  7334. return;
  7335. }
  7336. else {
  7337. this._startHighlightIndex = this._text.length - this._cursorOffset - 1;
  7338. }
  7339. }
  7340. this._endHighlightIndex = this._text.length;
  7341. this._isTextHighlightOn = true;
  7342. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7343. this._cursorOffset = 0;
  7344. this._markAsDirty();
  7345. return;
  7346. }
  7347. if (!this._isTextHighlightOn) {
  7348. this._isTextHighlightOn = true;
  7349. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  7350. }
  7351. //if text is already highlighted
  7352. else if (this._cursorIndex === -1) {
  7353. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7354. this._cursorOffset = (this._text.length === this._endHighlightIndex) ? 0 : this._text.length - this._endHighlightIndex - 1;
  7355. }
  7356. //set the highlight indexes
  7357. if (this._cursorIndex < this._cursorOffset) {
  7358. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7359. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7360. }
  7361. else if (this._cursorIndex > this._cursorOffset) {
  7362. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7363. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7364. }
  7365. else {
  7366. this._isTextHighlightOn = false;
  7367. }
  7368. this._markAsDirty();
  7369. return;
  7370. }
  7371. if (this._isTextHighlightOn) {
  7372. this._cursorOffset = this._text.length - this._endHighlightIndex;
  7373. this._isTextHighlightOn = false;
  7374. }
  7375. //ctr + ->
  7376. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7377. this._cursorOffset = 0;
  7378. evt.preventDefault();
  7379. }
  7380. this._blinkIsEven = false;
  7381. this._isTextHighlightOn = false;
  7382. this._cursorIndex = -1;
  7383. this._markAsDirty();
  7384. return;
  7385. case 222: // Dead
  7386. if (evt) {
  7387. evt.preventDefault();
  7388. }
  7389. this._cursorIndex = -1;
  7390. this.deadKey = true;
  7391. break;
  7392. }
  7393. // Printable characters
  7394. if (key &&
  7395. ((keyCode === -1) || // Direct access
  7396. (keyCode === 32) || // Space
  7397. (keyCode > 47 && keyCode < 64) || // Numbers
  7398. (keyCode > 64 && keyCode < 91) || // Letters
  7399. (keyCode > 159 && keyCode < 193) || // Special characters
  7400. (keyCode > 218 && keyCode < 223) || // Special characters
  7401. (keyCode > 95 && keyCode < 112))) { // Numpad
  7402. this._currentKey = key;
  7403. this.onBeforeKeyAddObservable.notifyObservers(this);
  7404. key = this._currentKey;
  7405. if (this._addKey) {
  7406. if (this._isTextHighlightOn) {
  7407. this.text = this._text.slice(0, this._startHighlightIndex) + key + this._text.slice(this._endHighlightIndex);
  7408. this._cursorOffset = this.text.length - (this._startHighlightIndex + 1);
  7409. this._isTextHighlightOn = false;
  7410. this._blinkIsEven = false;
  7411. this._markAsDirty();
  7412. }
  7413. else if (this._cursorOffset === 0) {
  7414. this.text += key;
  7415. }
  7416. else {
  7417. var insertPosition = this._text.length - this._cursorOffset;
  7418. this.text = this._text.slice(0, insertPosition) + key + this._text.slice(insertPosition);
  7419. }
  7420. }
  7421. }
  7422. };
  7423. /** @hidden */
  7424. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  7425. //update the cursor
  7426. this._blinkIsEven = false;
  7427. if (this._cursorIndex === -1) {
  7428. this._cursorIndex = offset;
  7429. }
  7430. else {
  7431. if (this._cursorIndex < this._cursorOffset) {
  7432. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7433. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7434. }
  7435. else if (this._cursorIndex > this._cursorOffset) {
  7436. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7437. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7438. }
  7439. else {
  7440. this._isTextHighlightOn = false;
  7441. this._markAsDirty();
  7442. return;
  7443. }
  7444. }
  7445. this._isTextHighlightOn = true;
  7446. this._markAsDirty();
  7447. };
  7448. /** @hidden */
  7449. InputText.prototype._processDblClick = function (evt) {
  7450. //pre-find the start and end index of the word under cursor, speeds up the rendering
  7451. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7452. this._endHighlightIndex = this._startHighlightIndex;
  7453. var rWord = /\w+/g, moveLeft, moveRight;
  7454. do {
  7455. moveRight = this._endHighlightIndex < this._text.length && (this._text[this._endHighlightIndex].search(rWord) !== -1) ? ++this._endHighlightIndex : 0;
  7456. moveLeft = this._startHighlightIndex > 0 && (this._text[this._startHighlightIndex - 1].search(rWord) !== -1) ? --this._startHighlightIndex : 0;
  7457. } while (moveLeft || moveRight);
  7458. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7459. this.onTextHighlightObservable.notifyObservers(this);
  7460. this._isTextHighlightOn = true;
  7461. this._clickedCoordinate = null;
  7462. this._blinkIsEven = true;
  7463. this._cursorIndex = -1;
  7464. this._markAsDirty();
  7465. };
  7466. /** @hidden */
  7467. InputText.prototype._selectAllText = function () {
  7468. this._blinkIsEven = true;
  7469. this._isTextHighlightOn = true;
  7470. this._startHighlightIndex = 0;
  7471. this._endHighlightIndex = this._text.length;
  7472. this._cursorOffset = this._text.length;
  7473. this._cursorIndex = -1;
  7474. this._markAsDirty();
  7475. };
  7476. /**
  7477. * Handles the keyboard event
  7478. * @param evt Defines the KeyboardEvent
  7479. */
  7480. InputText.prototype.processKeyboard = function (evt) {
  7481. // process pressed key
  7482. this.processKey(evt.keyCode, evt.key, evt);
  7483. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  7484. };
  7485. /** @hidden */
  7486. InputText.prototype._onCopyText = function (ev) {
  7487. this._isTextHighlightOn = false;
  7488. //when write permission to clipbaord data is denied
  7489. try {
  7490. ev.clipboardData.setData("text/plain", this._highlightedText);
  7491. }
  7492. catch (_a) { } //pass
  7493. this._host.clipboardData = this._highlightedText;
  7494. };
  7495. /** @hidden */
  7496. InputText.prototype._onCutText = function (ev) {
  7497. if (!this._highlightedText) {
  7498. return;
  7499. }
  7500. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7501. this._isTextHighlightOn = false;
  7502. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7503. //when write permission to clipbaord data is denied
  7504. try {
  7505. ev.clipboardData.setData("text/plain", this._highlightedText);
  7506. }
  7507. catch (_a) { } //pass
  7508. this._host.clipboardData = this._highlightedText;
  7509. this._highlightedText = "";
  7510. };
  7511. /** @hidden */
  7512. InputText.prototype._onPasteText = function (ev) {
  7513. var data = "";
  7514. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  7515. data = ev.clipboardData.getData("text/plain");
  7516. }
  7517. else {
  7518. //get the cached data; returns blank string by default
  7519. data = this._host.clipboardData;
  7520. }
  7521. var insertPosition = this._text.length - this._cursorOffset;
  7522. this.text = this._text.slice(0, insertPosition) + data + this._text.slice(insertPosition);
  7523. };
  7524. InputText.prototype._draw = function (context) {
  7525. var _this = this;
  7526. context.save();
  7527. this._applyStates(context);
  7528. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7529. context.shadowColor = this.shadowColor;
  7530. context.shadowBlur = this.shadowBlur;
  7531. context.shadowOffsetX = this.shadowOffsetX;
  7532. context.shadowOffsetY = this.shadowOffsetY;
  7533. }
  7534. // Background
  7535. if (this._isFocused) {
  7536. if (this._focusedBackground) {
  7537. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  7538. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7539. }
  7540. }
  7541. else if (this._background) {
  7542. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  7543. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7544. }
  7545. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7546. context.shadowBlur = 0;
  7547. context.shadowOffsetX = 0;
  7548. context.shadowOffsetY = 0;
  7549. }
  7550. if (!this._fontOffset) {
  7551. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  7552. }
  7553. // Text
  7554. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  7555. if (this.color) {
  7556. context.fillStyle = this.color;
  7557. }
  7558. var text = this._beforeRenderText(this._text);
  7559. if (!this._isFocused && !this._text && this._placeholderText) {
  7560. text = this._placeholderText;
  7561. if (this._placeholderColor) {
  7562. context.fillStyle = this._placeholderColor;
  7563. }
  7564. }
  7565. this._textWidth = context.measureText(text).width;
  7566. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  7567. if (this._autoStretchWidth) {
  7568. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  7569. }
  7570. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  7571. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  7572. context.save();
  7573. context.beginPath();
  7574. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  7575. context.clip();
  7576. if (this._isFocused && this._textWidth > availableWidth) {
  7577. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  7578. if (!this._scrollLeft) {
  7579. this._scrollLeft = textLeft;
  7580. }
  7581. }
  7582. else {
  7583. this._scrollLeft = clipTextLeft;
  7584. }
  7585. context.fillText(text, this._scrollLeft, this._currentMeasure.top + rootY);
  7586. // Cursor
  7587. if (this._isFocused) {
  7588. // Need to move cursor
  7589. if (this._clickedCoordinate) {
  7590. var rightPosition = this._scrollLeft + this._textWidth;
  7591. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  7592. var currentSize = 0;
  7593. this._cursorOffset = 0;
  7594. var previousDist = 0;
  7595. do {
  7596. if (this._cursorOffset) {
  7597. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  7598. }
  7599. this._cursorOffset++;
  7600. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  7601. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  7602. // Find closest move
  7603. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  7604. this._cursorOffset--;
  7605. }
  7606. this._blinkIsEven = false;
  7607. this._clickedCoordinate = null;
  7608. }
  7609. // Render cursor
  7610. if (!this._blinkIsEven) {
  7611. var cursorOffsetText = this.text.substr(this._text.length - this._cursorOffset);
  7612. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  7613. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  7614. if (cursorLeft < clipTextLeft) {
  7615. this._scrollLeft += (clipTextLeft - cursorLeft);
  7616. cursorLeft = clipTextLeft;
  7617. this._markAsDirty();
  7618. }
  7619. else if (cursorLeft > clipTextLeft + availableWidth) {
  7620. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  7621. cursorLeft = clipTextLeft + availableWidth;
  7622. this._markAsDirty();
  7623. }
  7624. if (!this._isTextHighlightOn) {
  7625. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  7626. }
  7627. }
  7628. clearTimeout(this._blinkTimeout);
  7629. this._blinkTimeout = setTimeout(function () {
  7630. _this._blinkIsEven = !_this._blinkIsEven;
  7631. _this._markAsDirty();
  7632. }, 500);
  7633. //show the highlighted text
  7634. if (this._isTextHighlightOn) {
  7635. clearTimeout(this._blinkTimeout);
  7636. var highlightCursorOffsetWidth = context.measureText(this.text.substring(this._startHighlightIndex)).width;
  7637. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  7638. this._highlightedText = this.text.substring(this._startHighlightIndex, this._endHighlightIndex);
  7639. var width = context.measureText(this.text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  7640. if (highlightCursorLeft < clipTextLeft) {
  7641. width = width - (clipTextLeft - highlightCursorLeft);
  7642. if (!width) {
  7643. // when using left arrow on text.length > availableWidth;
  7644. // assigns the width of the first letter after clipTextLeft
  7645. width = context.measureText(this.text.charAt(this.text.length - this._cursorOffset)).width;
  7646. }
  7647. highlightCursorLeft = clipTextLeft;
  7648. }
  7649. //for transparancy
  7650. context.globalAlpha = this._highligherOpacity;
  7651. context.fillStyle = this._textHighlightColor;
  7652. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  7653. context.globalAlpha = 1.0;
  7654. }
  7655. }
  7656. context.restore();
  7657. // Border
  7658. if (this._thickness) {
  7659. if (this._isFocused) {
  7660. if (this.focusedColor) {
  7661. context.strokeStyle = this.focusedColor;
  7662. }
  7663. }
  7664. else {
  7665. if (this.color) {
  7666. context.strokeStyle = this.color;
  7667. }
  7668. }
  7669. context.lineWidth = this._thickness;
  7670. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  7671. }
  7672. context.restore();
  7673. };
  7674. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  7675. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  7676. return false;
  7677. }
  7678. this._clickedCoordinate = coordinates.x;
  7679. this._isTextHighlightOn = false;
  7680. this._highlightedText = "";
  7681. this._cursorIndex = -1;
  7682. this._isPointerDown = true;
  7683. this._host._capturingControl[pointerId] = this;
  7684. if (this._host.focusedControl === this) {
  7685. // Move cursor
  7686. clearTimeout(this._blinkTimeout);
  7687. this._markAsDirty();
  7688. return true;
  7689. }
  7690. if (!this._isEnabled) {
  7691. return false;
  7692. }
  7693. this._host.focusedControl = this;
  7694. return true;
  7695. };
  7696. InputText.prototype._onPointerMove = function (target, coordinates) {
  7697. if (this._host.focusedControl === this && this._isPointerDown) {
  7698. this._clickedCoordinate = coordinates.x;
  7699. this._markAsDirty();
  7700. this._updateValueFromCursorIndex(this._cursorOffset);
  7701. }
  7702. _super.prototype._onPointerMove.call(this, target, coordinates);
  7703. };
  7704. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  7705. this._isPointerDown = false;
  7706. delete this._host._capturingControl[pointerId];
  7707. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  7708. };
  7709. InputText.prototype._beforeRenderText = function (text) {
  7710. return text;
  7711. };
  7712. InputText.prototype.dispose = function () {
  7713. _super.prototype.dispose.call(this);
  7714. this.onBlurObservable.clear();
  7715. this.onFocusObservable.clear();
  7716. this.onTextChangedObservable.clear();
  7717. this.onTextCopyObservable.clear();
  7718. this.onTextCutObservable.clear();
  7719. this.onTextPasteObservable.clear();
  7720. this.onTextHighlightObservable.clear();
  7721. this.onKeyboardEventProcessedObservable.clear();
  7722. };
  7723. return InputText;
  7724. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7725. /***/ }),
  7726. /***/ "./2D/controls/line.ts":
  7727. /*!*****************************!*\
  7728. !*** ./2D/controls/line.ts ***!
  7729. \*****************************/
  7730. /*! exports provided: Line */
  7731. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7732. "use strict";
  7733. __webpack_require__.r(__webpack_exports__);
  7734. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  7735. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7736. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  7737. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  7738. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7739. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7740. /** Class used to render 2D lines */
  7741. var Line = /** @class */ (function (_super) {
  7742. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Line, _super);
  7743. /**
  7744. * Creates a new Line
  7745. * @param name defines the control name
  7746. */
  7747. function Line(name) {
  7748. var _this = _super.call(this, name) || this;
  7749. _this.name = name;
  7750. _this._lineWidth = 1;
  7751. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7752. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7753. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7754. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7755. _this._dash = new Array();
  7756. _this.isHitTestVisible = false;
  7757. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  7758. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  7759. return _this;
  7760. }
  7761. Object.defineProperty(Line.prototype, "dash", {
  7762. /** Gets or sets the dash pattern */
  7763. get: function () {
  7764. return this._dash;
  7765. },
  7766. set: function (value) {
  7767. if (this._dash === value) {
  7768. return;
  7769. }
  7770. this._dash = value;
  7771. this._markAsDirty();
  7772. },
  7773. enumerable: true,
  7774. configurable: true
  7775. });
  7776. Object.defineProperty(Line.prototype, "connectedControl", {
  7777. /** Gets or sets the control connected with the line end */
  7778. get: function () {
  7779. return this._connectedControl;
  7780. },
  7781. set: function (value) {
  7782. var _this = this;
  7783. if (this._connectedControl === value) {
  7784. return;
  7785. }
  7786. if (this._connectedControlDirtyObserver && this._connectedControl) {
  7787. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  7788. this._connectedControlDirtyObserver = null;
  7789. }
  7790. if (value) {
  7791. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  7792. }
  7793. this._connectedControl = value;
  7794. this._markAsDirty();
  7795. },
  7796. enumerable: true,
  7797. configurable: true
  7798. });
  7799. Object.defineProperty(Line.prototype, "x1", {
  7800. /** Gets or sets start coordinates on X axis */
  7801. get: function () {
  7802. return this._x1.toString(this._host);
  7803. },
  7804. set: function (value) {
  7805. if (this._x1.toString(this._host) === value) {
  7806. return;
  7807. }
  7808. if (this._x1.fromString(value)) {
  7809. this._markAsDirty();
  7810. }
  7811. },
  7812. enumerable: true,
  7813. configurable: true
  7814. });
  7815. Object.defineProperty(Line.prototype, "y1", {
  7816. /** Gets or sets start coordinates on Y axis */
  7817. get: function () {
  7818. return this._y1.toString(this._host);
  7819. },
  7820. set: function (value) {
  7821. if (this._y1.toString(this._host) === value) {
  7822. return;
  7823. }
  7824. if (this._y1.fromString(value)) {
  7825. this._markAsDirty();
  7826. }
  7827. },
  7828. enumerable: true,
  7829. configurable: true
  7830. });
  7831. Object.defineProperty(Line.prototype, "x2", {
  7832. /** Gets or sets end coordinates on X axis */
  7833. get: function () {
  7834. return this._x2.toString(this._host);
  7835. },
  7836. set: function (value) {
  7837. if (this._x2.toString(this._host) === value) {
  7838. return;
  7839. }
  7840. if (this._x2.fromString(value)) {
  7841. this._markAsDirty();
  7842. }
  7843. },
  7844. enumerable: true,
  7845. configurable: true
  7846. });
  7847. Object.defineProperty(Line.prototype, "y2", {
  7848. /** Gets or sets end coordinates on Y axis */
  7849. get: function () {
  7850. return this._y2.toString(this._host);
  7851. },
  7852. set: function (value) {
  7853. if (this._y2.toString(this._host) === value) {
  7854. return;
  7855. }
  7856. if (this._y2.fromString(value)) {
  7857. this._markAsDirty();
  7858. }
  7859. },
  7860. enumerable: true,
  7861. configurable: true
  7862. });
  7863. Object.defineProperty(Line.prototype, "lineWidth", {
  7864. /** Gets or sets line width */
  7865. get: function () {
  7866. return this._lineWidth;
  7867. },
  7868. set: function (value) {
  7869. if (this._lineWidth === value) {
  7870. return;
  7871. }
  7872. this._lineWidth = value;
  7873. this._markAsDirty();
  7874. },
  7875. enumerable: true,
  7876. configurable: true
  7877. });
  7878. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  7879. /** Gets or sets horizontal alignment */
  7880. set: function (value) {
  7881. return;
  7882. },
  7883. enumerable: true,
  7884. configurable: true
  7885. });
  7886. Object.defineProperty(Line.prototype, "verticalAlignment", {
  7887. /** Gets or sets vertical alignment */
  7888. set: function (value) {
  7889. return;
  7890. },
  7891. enumerable: true,
  7892. configurable: true
  7893. });
  7894. Object.defineProperty(Line.prototype, "_effectiveX2", {
  7895. get: function () {
  7896. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  7897. },
  7898. enumerable: true,
  7899. configurable: true
  7900. });
  7901. Object.defineProperty(Line.prototype, "_effectiveY2", {
  7902. get: function () {
  7903. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  7904. },
  7905. enumerable: true,
  7906. configurable: true
  7907. });
  7908. Line.prototype._getTypeName = function () {
  7909. return "Line";
  7910. };
  7911. Line.prototype._draw = function (context) {
  7912. context.save();
  7913. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7914. context.shadowColor = this.shadowColor;
  7915. context.shadowBlur = this.shadowBlur;
  7916. context.shadowOffsetX = this.shadowOffsetX;
  7917. context.shadowOffsetY = this.shadowOffsetY;
  7918. }
  7919. this._applyStates(context);
  7920. context.strokeStyle = this.color;
  7921. context.lineWidth = this._lineWidth;
  7922. context.setLineDash(this._dash);
  7923. context.beginPath();
  7924. context.moveTo(this._x1.getValue(this._host), this._y1.getValue(this._host));
  7925. context.lineTo(this._effectiveX2, this._effectiveY2);
  7926. context.stroke();
  7927. context.restore();
  7928. };
  7929. Line.prototype._measure = function () {
  7930. // Width / Height
  7931. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  7932. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  7933. };
  7934. Line.prototype._computeAlignment = function (parentMeasure, context) {
  7935. this._currentMeasure.left = Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  7936. this._currentMeasure.top = Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  7937. };
  7938. /**
  7939. * Move one end of the line given 3D cartesian coordinates.
  7940. * @param position Targeted world position
  7941. * @param scene Scene
  7942. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  7943. */
  7944. Line.prototype.moveToVector3 = function (position, scene, end) {
  7945. if (end === void 0) { end = false; }
  7946. if (!this._host || this.parent !== this._host._rootContainer) {
  7947. babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  7948. return;
  7949. }
  7950. var globalViewport = this._host._getGlobalViewport(scene);
  7951. var projectedPosition = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  7952. this._moveToProjectedPosition(projectedPosition, end);
  7953. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  7954. this.notRenderable = true;
  7955. return;
  7956. }
  7957. this.notRenderable = false;
  7958. };
  7959. /**
  7960. * Move one end of the line to a position in screen absolute space.
  7961. * @param projectedPosition Position in screen absolute space (X, Y)
  7962. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  7963. */
  7964. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  7965. if (end === void 0) { end = false; }
  7966. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  7967. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  7968. if (end) {
  7969. this.x2 = x;
  7970. this.y2 = y;
  7971. this._x2.ignoreAdaptiveScaling = true;
  7972. this._y2.ignoreAdaptiveScaling = true;
  7973. }
  7974. else {
  7975. this.x1 = x;
  7976. this.y1 = y;
  7977. this._x1.ignoreAdaptiveScaling = true;
  7978. this._y1.ignoreAdaptiveScaling = true;
  7979. }
  7980. };
  7981. return Line;
  7982. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7983. /***/ }),
  7984. /***/ "./2D/controls/multiLine.ts":
  7985. /*!**********************************!*\
  7986. !*** ./2D/controls/multiLine.ts ***!
  7987. \**********************************/
  7988. /*! exports provided: MultiLine */
  7989. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7990. "use strict";
  7991. __webpack_require__.r(__webpack_exports__);
  7992. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  7993. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7994. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Misc/observable");
  7995. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  7996. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7997. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  7998. /**
  7999. * Class used to create multi line control
  8000. */
  8001. var MultiLine = /** @class */ (function (_super) {
  8002. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiLine, _super);
  8003. /**
  8004. * Creates a new MultiLine
  8005. * @param name defines the control name
  8006. */
  8007. function MultiLine(name) {
  8008. var _this = _super.call(this, name) || this;
  8009. _this.name = name;
  8010. _this._lineWidth = 1;
  8011. /** Function called when a point is updated */
  8012. _this.onPointUpdate = function () {
  8013. _this._markAsDirty();
  8014. };
  8015. _this.isHitTestVisible = false;
  8016. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8017. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8018. _this._dash = [];
  8019. _this._points = [];
  8020. return _this;
  8021. }
  8022. Object.defineProperty(MultiLine.prototype, "dash", {
  8023. /** Gets or sets dash pattern */
  8024. get: function () {
  8025. return this._dash;
  8026. },
  8027. set: function (value) {
  8028. if (this._dash === value) {
  8029. return;
  8030. }
  8031. this._dash = value;
  8032. this._markAsDirty();
  8033. },
  8034. enumerable: true,
  8035. configurable: true
  8036. });
  8037. /**
  8038. * Gets point stored at specified index
  8039. * @param index defines the index to look for
  8040. * @returns the requested point if found
  8041. */
  8042. MultiLine.prototype.getAt = function (index) {
  8043. if (!this._points[index]) {
  8044. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  8045. }
  8046. return this._points[index];
  8047. };
  8048. /**
  8049. * Adds new points to the point collection
  8050. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  8051. * @returns the list of created MultiLinePoint
  8052. */
  8053. MultiLine.prototype.add = function () {
  8054. var _this = this;
  8055. var items = [];
  8056. for (var _i = 0; _i < arguments.length; _i++) {
  8057. items[_i] = arguments[_i];
  8058. }
  8059. return items.map(function (item) { return _this.push(item); });
  8060. };
  8061. /**
  8062. * Adds a new point to the point collection
  8063. * @param item defines the item (mesh, control or 2d coordiantes) to add
  8064. * @returns the created MultiLinePoint
  8065. */
  8066. MultiLine.prototype.push = function (item) {
  8067. var point = this.getAt(this._points.length);
  8068. if (item == null) {
  8069. return point;
  8070. }
  8071. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  8072. point.mesh = item;
  8073. }
  8074. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  8075. point.control = item;
  8076. }
  8077. else if (item.x != null && item.y != null) {
  8078. point.x = item.x;
  8079. point.y = item.y;
  8080. }
  8081. return point;
  8082. };
  8083. /**
  8084. * Remove a specific value or point from the active point collection
  8085. * @param value defines the value or point to remove
  8086. */
  8087. MultiLine.prototype.remove = function (value) {
  8088. var index;
  8089. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  8090. index = this._points.indexOf(value);
  8091. if (index === -1) {
  8092. return;
  8093. }
  8094. }
  8095. else {
  8096. index = value;
  8097. }
  8098. var point = this._points[index];
  8099. if (!point) {
  8100. return;
  8101. }
  8102. point.dispose();
  8103. this._points.splice(index, 1);
  8104. };
  8105. /**
  8106. * Resets this object to initial state (no point)
  8107. */
  8108. MultiLine.prototype.reset = function () {
  8109. while (this._points.length > 0) {
  8110. this.remove(this._points.length - 1);
  8111. }
  8112. };
  8113. /**
  8114. * Resets all links
  8115. */
  8116. MultiLine.prototype.resetLinks = function () {
  8117. this._points.forEach(function (point) {
  8118. if (point != null) {
  8119. point.resetLinks();
  8120. }
  8121. });
  8122. };
  8123. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  8124. /** Gets or sets line width */
  8125. get: function () {
  8126. return this._lineWidth;
  8127. },
  8128. set: function (value) {
  8129. if (this._lineWidth === value) {
  8130. return;
  8131. }
  8132. this._lineWidth = value;
  8133. this._markAsDirty();
  8134. },
  8135. enumerable: true,
  8136. configurable: true
  8137. });
  8138. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  8139. set: function (value) {
  8140. return;
  8141. },
  8142. enumerable: true,
  8143. configurable: true
  8144. });
  8145. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  8146. set: function (value) {
  8147. return;
  8148. },
  8149. enumerable: true,
  8150. configurable: true
  8151. });
  8152. MultiLine.prototype._getTypeName = function () {
  8153. return "MultiLine";
  8154. };
  8155. MultiLine.prototype._draw = function (context) {
  8156. context.save();
  8157. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8158. context.shadowColor = this.shadowColor;
  8159. context.shadowBlur = this.shadowBlur;
  8160. context.shadowOffsetX = this.shadowOffsetX;
  8161. context.shadowOffsetY = this.shadowOffsetY;
  8162. }
  8163. this._applyStates(context);
  8164. context.strokeStyle = this.color;
  8165. context.lineWidth = this._lineWidth;
  8166. context.setLineDash(this._dash);
  8167. context.beginPath();
  8168. var first = true; //first index is not necessarily 0
  8169. this._points.forEach(function (point) {
  8170. if (!point) {
  8171. return;
  8172. }
  8173. if (first) {
  8174. context.moveTo(point._point.x, point._point.y);
  8175. first = false;
  8176. }
  8177. else {
  8178. context.lineTo(point._point.x, point._point.y);
  8179. }
  8180. });
  8181. context.stroke();
  8182. context.restore();
  8183. };
  8184. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  8185. var _this = this;
  8186. this._minX = null;
  8187. this._minY = null;
  8188. this._maxX = null;
  8189. this._maxY = null;
  8190. this._points.forEach(function (point, index) {
  8191. if (!point) {
  8192. return;
  8193. }
  8194. point.translate();
  8195. if (_this._minX == null || point._point.x < _this._minX) {
  8196. _this._minX = point._point.x;
  8197. }
  8198. if (_this._minY == null || point._point.y < _this._minY) {
  8199. _this._minY = point._point.y;
  8200. }
  8201. if (_this._maxX == null || point._point.x > _this._maxX) {
  8202. _this._maxX = point._point.x;
  8203. }
  8204. if (_this._maxY == null || point._point.y > _this._maxY) {
  8205. _this._maxY = point._point.y;
  8206. }
  8207. });
  8208. if (this._minX == null) {
  8209. this._minX = 0;
  8210. }
  8211. if (this._minY == null) {
  8212. this._minY = 0;
  8213. }
  8214. if (this._maxX == null) {
  8215. this._maxX = 0;
  8216. }
  8217. if (this._maxY == null) {
  8218. this._maxY = 0;
  8219. }
  8220. };
  8221. MultiLine.prototype._measure = function () {
  8222. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  8223. return;
  8224. }
  8225. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  8226. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  8227. };
  8228. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  8229. if (this._minX == null || this._minY == null) {
  8230. return;
  8231. }
  8232. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  8233. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  8234. };
  8235. MultiLine.prototype.dispose = function () {
  8236. this.reset();
  8237. _super.prototype.dispose.call(this);
  8238. };
  8239. return MultiLine;
  8240. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8241. /***/ }),
  8242. /***/ "./2D/controls/radioButton.ts":
  8243. /*!************************************!*\
  8244. !*** ./2D/controls/radioButton.ts ***!
  8245. \************************************/
  8246. /*! exports provided: RadioButton */
  8247. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8248. "use strict";
  8249. __webpack_require__.r(__webpack_exports__);
  8250. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  8251. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8252. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  8253. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  8254. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8255. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  8256. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  8257. /**
  8258. * Class used to create radio button controls
  8259. */
  8260. var RadioButton = /** @class */ (function (_super) {
  8261. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RadioButton, _super);
  8262. /**
  8263. * Creates a new RadioButton
  8264. * @param name defines the control name
  8265. */
  8266. function RadioButton(name) {
  8267. var _this = _super.call(this, name) || this;
  8268. _this.name = name;
  8269. _this._isChecked = false;
  8270. _this._background = "black";
  8271. _this._checkSizeRatio = 0.8;
  8272. _this._thickness = 1;
  8273. /** Gets or sets group name */
  8274. _this.group = "";
  8275. /** Observable raised when isChecked is changed */
  8276. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  8277. _this.isPointerBlocker = true;
  8278. return _this;
  8279. }
  8280. Object.defineProperty(RadioButton.prototype, "thickness", {
  8281. /** Gets or sets border thickness */
  8282. get: function () {
  8283. return this._thickness;
  8284. },
  8285. set: function (value) {
  8286. if (this._thickness === value) {
  8287. return;
  8288. }
  8289. this._thickness = value;
  8290. this._markAsDirty();
  8291. },
  8292. enumerable: true,
  8293. configurable: true
  8294. });
  8295. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  8296. /** Gets or sets a value indicating the ratio between overall size and check size */
  8297. get: function () {
  8298. return this._checkSizeRatio;
  8299. },
  8300. set: function (value) {
  8301. value = Math.max(Math.min(1, value), 0);
  8302. if (this._checkSizeRatio === value) {
  8303. return;
  8304. }
  8305. this._checkSizeRatio = value;
  8306. this._markAsDirty();
  8307. },
  8308. enumerable: true,
  8309. configurable: true
  8310. });
  8311. Object.defineProperty(RadioButton.prototype, "background", {
  8312. /** Gets or sets background color */
  8313. get: function () {
  8314. return this._background;
  8315. },
  8316. set: function (value) {
  8317. if (this._background === value) {
  8318. return;
  8319. }
  8320. this._background = value;
  8321. this._markAsDirty();
  8322. },
  8323. enumerable: true,
  8324. configurable: true
  8325. });
  8326. Object.defineProperty(RadioButton.prototype, "isChecked", {
  8327. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  8328. get: function () {
  8329. return this._isChecked;
  8330. },
  8331. set: function (value) {
  8332. var _this = this;
  8333. if (this._isChecked === value) {
  8334. return;
  8335. }
  8336. this._isChecked = value;
  8337. this._markAsDirty();
  8338. this.onIsCheckedChangedObservable.notifyObservers(value);
  8339. if (this._isChecked && this._host) {
  8340. // Update all controls from same group
  8341. this._host.executeOnAllControls(function (control) {
  8342. if (control === _this) {
  8343. return;
  8344. }
  8345. if (control.group === undefined) {
  8346. return;
  8347. }
  8348. var childRadio = control;
  8349. if (childRadio.group === _this.group) {
  8350. childRadio.isChecked = false;
  8351. }
  8352. });
  8353. }
  8354. },
  8355. enumerable: true,
  8356. configurable: true
  8357. });
  8358. RadioButton.prototype._getTypeName = function () {
  8359. return "RadioButton";
  8360. };
  8361. RadioButton.prototype._draw = function (context) {
  8362. context.save();
  8363. this._applyStates(context);
  8364. var actualWidth = this._currentMeasure.width - this._thickness;
  8365. var actualHeight = this._currentMeasure.height - this._thickness;
  8366. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8367. context.shadowColor = this.shadowColor;
  8368. context.shadowBlur = this.shadowBlur;
  8369. context.shadowOffsetX = this.shadowOffsetX;
  8370. context.shadowOffsetY = this.shadowOffsetY;
  8371. }
  8372. // Outer
  8373. _control__WEBPACK_IMPORTED_MODULE_2__["Control"].drawEllipse(this._currentMeasure.left + this._currentMeasure.width / 2, this._currentMeasure.top + this._currentMeasure.height / 2, this._currentMeasure.width / 2 - this._thickness / 2, this._currentMeasure.height / 2 - this._thickness / 2, context);
  8374. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8375. context.fill();
  8376. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8377. context.shadowBlur = 0;
  8378. context.shadowOffsetX = 0;
  8379. context.shadowOffsetY = 0;
  8380. }
  8381. context.strokeStyle = this.color;
  8382. context.lineWidth = this._thickness;
  8383. context.stroke();
  8384. // Inner
  8385. if (this._isChecked) {
  8386. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  8387. var offsetWidth = actualWidth * this._checkSizeRatio;
  8388. var offseHeight = actualHeight * this._checkSizeRatio;
  8389. _control__WEBPACK_IMPORTED_MODULE_2__["Control"].drawEllipse(this._currentMeasure.left + this._currentMeasure.width / 2, this._currentMeasure.top + this._currentMeasure.height / 2, offsetWidth / 2 - this._thickness / 2, offseHeight / 2 - this._thickness / 2, context);
  8390. context.fill();
  8391. }
  8392. context.restore();
  8393. };
  8394. // Events
  8395. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8396. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8397. return false;
  8398. }
  8399. if (!this.isChecked) {
  8400. this.isChecked = true;
  8401. }
  8402. return true;
  8403. };
  8404. /**
  8405. * Utility function to easily create a radio button with a header
  8406. * @param title defines the label to use for the header
  8407. * @param group defines the group to use for the radio button
  8408. * @param isChecked defines the initial state of the radio button
  8409. * @param onValueChanged defines the callback to call when value changes
  8410. * @returns a StackPanel containing the radio button and a textBlock
  8411. */
  8412. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  8413. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  8414. panel.isVertical = false;
  8415. panel.height = "30px";
  8416. var radio = new RadioButton();
  8417. radio.width = "20px";
  8418. radio.height = "20px";
  8419. radio.isChecked = isChecked;
  8420. radio.color = "green";
  8421. radio.group = group;
  8422. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  8423. panel.addControl(radio);
  8424. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  8425. header.text = title;
  8426. header.width = "180px";
  8427. header.paddingLeft = "5px";
  8428. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8429. header.color = "white";
  8430. panel.addControl(header);
  8431. return panel;
  8432. };
  8433. return RadioButton;
  8434. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8435. /***/ }),
  8436. /***/ "./2D/controls/rectangle.ts":
  8437. /*!**********************************!*\
  8438. !*** ./2D/controls/rectangle.ts ***!
  8439. \**********************************/
  8440. /*! exports provided: Rectangle */
  8441. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8442. "use strict";
  8443. __webpack_require__.r(__webpack_exports__);
  8444. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  8445. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8446. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  8447. /** Class used to create rectangle container */
  8448. var Rectangle = /** @class */ (function (_super) {
  8449. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Rectangle, _super);
  8450. /**
  8451. * Creates a new Rectangle
  8452. * @param name defines the control name
  8453. */
  8454. function Rectangle(name) {
  8455. var _this = _super.call(this, name) || this;
  8456. _this.name = name;
  8457. _this._thickness = 1;
  8458. _this._cornerRadius = 0;
  8459. return _this;
  8460. }
  8461. Object.defineProperty(Rectangle.prototype, "thickness", {
  8462. /** Gets or sets border thickness */
  8463. get: function () {
  8464. return this._thickness;
  8465. },
  8466. set: function (value) {
  8467. if (this._thickness === value) {
  8468. return;
  8469. }
  8470. this._thickness = value;
  8471. this._markAsDirty();
  8472. },
  8473. enumerable: true,
  8474. configurable: true
  8475. });
  8476. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  8477. /** Gets or sets the corner radius angle */
  8478. get: function () {
  8479. return this._cornerRadius;
  8480. },
  8481. set: function (value) {
  8482. if (value < 0) {
  8483. value = 0;
  8484. }
  8485. if (this._cornerRadius === value) {
  8486. return;
  8487. }
  8488. this._cornerRadius = value;
  8489. this._markAsDirty();
  8490. },
  8491. enumerable: true,
  8492. configurable: true
  8493. });
  8494. Rectangle.prototype._getTypeName = function () {
  8495. return "Rectangle";
  8496. };
  8497. Rectangle.prototype._localDraw = function (context) {
  8498. context.save();
  8499. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8500. context.shadowColor = this.shadowColor;
  8501. context.shadowBlur = this.shadowBlur;
  8502. context.shadowOffsetX = this.shadowOffsetX;
  8503. context.shadowOffsetY = this.shadowOffsetY;
  8504. }
  8505. if (this._background) {
  8506. context.fillStyle = this._background;
  8507. if (this._cornerRadius) {
  8508. this._drawRoundedRect(context, this._thickness / 2);
  8509. context.fill();
  8510. }
  8511. else {
  8512. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8513. }
  8514. }
  8515. if (this._thickness) {
  8516. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8517. context.shadowBlur = 0;
  8518. context.shadowOffsetX = 0;
  8519. context.shadowOffsetY = 0;
  8520. }
  8521. if (this.color) {
  8522. context.strokeStyle = this.color;
  8523. }
  8524. context.lineWidth = this._thickness;
  8525. if (this._cornerRadius) {
  8526. this._drawRoundedRect(context, this._thickness / 2);
  8527. context.stroke();
  8528. }
  8529. else {
  8530. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8531. }
  8532. }
  8533. context.restore();
  8534. };
  8535. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  8536. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8537. this._measureForChildren.width -= 2 * this._thickness;
  8538. this._measureForChildren.height -= 2 * this._thickness;
  8539. this._measureForChildren.left += this._thickness;
  8540. this._measureForChildren.top += this._thickness;
  8541. };
  8542. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  8543. if (offset === void 0) { offset = 0; }
  8544. var x = this._currentMeasure.left + offset;
  8545. var y = this._currentMeasure.top + offset;
  8546. var width = this._currentMeasure.width - offset * 2;
  8547. var height = this._currentMeasure.height - offset * 2;
  8548. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  8549. context.beginPath();
  8550. context.moveTo(x + radius, y);
  8551. context.lineTo(x + width - radius, y);
  8552. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  8553. context.lineTo(x + width, y + height - radius);
  8554. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  8555. context.lineTo(x + radius, y + height);
  8556. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  8557. context.lineTo(x, y + radius);
  8558. context.quadraticCurveTo(x, y, x + radius, y);
  8559. context.closePath();
  8560. };
  8561. Rectangle.prototype._clipForChildren = function (context) {
  8562. if (this._cornerRadius) {
  8563. this._drawRoundedRect(context, this._thickness);
  8564. context.clip();
  8565. }
  8566. };
  8567. return Rectangle;
  8568. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  8569. /***/ }),
  8570. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  8571. /*!***************************************************!*\
  8572. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  8573. \***************************************************/
  8574. /*! exports provided: ScrollViewer */
  8575. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8576. "use strict";
  8577. __webpack_require__.r(__webpack_exports__);
  8578. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  8579. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8580. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Events/pointerEvents */ "babylonjs/Misc/observable");
  8581. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__);
  8582. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  8583. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  8584. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8585. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  8586. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  8587. /**
  8588. * Class used to hold a viewer window and sliders in a grid
  8589. */
  8590. var ScrollViewer = /** @class */ (function (_super) {
  8591. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScrollViewer, _super);
  8592. /**
  8593. * Creates a new ScrollViewer
  8594. * @param name of ScrollViewer
  8595. */
  8596. function ScrollViewer(name) {
  8597. var _this = _super.call(this, name) || this;
  8598. _this._barSize = 20;
  8599. _this._pointerIsOver = false;
  8600. _this._wheelPrecision = 0.05;
  8601. _this.onDirtyObservable.add(function () {
  8602. _this._horizontalBarSpace.color = _this.color;
  8603. _this._verticalBarSpace.color = _this.color;
  8604. _this._dragSpace.color = _this.color;
  8605. });
  8606. _this.onPointerEnterObservable.add(function () {
  8607. _this._pointerIsOver = true;
  8608. });
  8609. _this.onPointerOutObservable.add(function () {
  8610. _this._pointerIsOver = false;
  8611. });
  8612. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_3__["Grid"]();
  8613. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8614. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8615. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__["_ScrollViewerWindow"]();
  8616. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8617. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8618. _this._grid.addColumnDefinition(1);
  8619. _this._grid.addColumnDefinition(0, true);
  8620. _this._grid.addRowDefinition(1);
  8621. _this._grid.addRowDefinition(0, true);
  8622. _super.prototype.addControl.call(_this, _this._grid);
  8623. _this._grid.addControl(_this._window, 0, 0);
  8624. _this._verticalBar.paddingLeft = 0;
  8625. _this._verticalBar.width = "100%";
  8626. _this._verticalBar.height = "100%";
  8627. _this._verticalBar.barOffset = 0;
  8628. _this._verticalBar.value = 0;
  8629. _this._verticalBar.maximum = 1;
  8630. _this._verticalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8631. _this._verticalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8632. _this._verticalBar.isVertical = true;
  8633. _this._verticalBar.rotation = Math.PI;
  8634. _this._verticalBar.isVisible = false;
  8635. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8636. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8637. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8638. _this._verticalBarSpace.thickness = 1;
  8639. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  8640. _this._verticalBarSpace.addControl(_this._verticalBar);
  8641. _this._verticalBar.onValueChangedObservable.add(function (value) {
  8642. _this._window.top = value * _this._endTop + "px";
  8643. });
  8644. _this._horizontalBar.paddingLeft = 0;
  8645. _this._horizontalBar.width = "100%";
  8646. _this._horizontalBar.height = "100%";
  8647. _this._horizontalBar.barOffset = 0;
  8648. _this._horizontalBar.value = 0;
  8649. _this._horizontalBar.maximum = 1;
  8650. _this._horizontalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8651. _this._horizontalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8652. _this._horizontalBar.isVisible = false;
  8653. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8654. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8655. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8656. _this._horizontalBarSpace.thickness = 1;
  8657. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  8658. _this._horizontalBarSpace.addControl(_this._horizontalBar);
  8659. _this._horizontalBar.onValueChangedObservable.add(function (value) {
  8660. _this._window.left = value * _this._endLeft + "px";
  8661. });
  8662. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8663. _this._dragSpace.thickness = 1;
  8664. _this._grid.addControl(_this._dragSpace, 1, 1);
  8665. // Colors
  8666. _this.barColor = "grey";
  8667. _this.barBackground = "transparent";
  8668. return _this;
  8669. }
  8670. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  8671. /**
  8672. * Gets the horizontal scrollbar
  8673. */
  8674. get: function () {
  8675. return this._horizontalBar;
  8676. },
  8677. enumerable: true,
  8678. configurable: true
  8679. });
  8680. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  8681. /**
  8682. * Gets the vertical scrollbar
  8683. */
  8684. get: function () {
  8685. return this._verticalBar;
  8686. },
  8687. enumerable: true,
  8688. configurable: true
  8689. });
  8690. /**
  8691. * Adds a new control to the current container
  8692. * @param control defines the control to add
  8693. * @returns the current container
  8694. */
  8695. ScrollViewer.prototype.addControl = function (control) {
  8696. if (!control) {
  8697. return this;
  8698. }
  8699. this._window.addControl(control);
  8700. return this;
  8701. };
  8702. /**
  8703. * Removes a control from the current container
  8704. * @param control defines the control to remove
  8705. * @returns the current container
  8706. */
  8707. ScrollViewer.prototype.removeControl = function (control) {
  8708. this._window.removeControl(control);
  8709. return this;
  8710. };
  8711. Object.defineProperty(ScrollViewer.prototype, "children", {
  8712. /** Gets the list of children */
  8713. get: function () {
  8714. return this._window.children;
  8715. },
  8716. enumerable: true,
  8717. configurable: true
  8718. });
  8719. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  8720. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  8721. var child = _a[_i];
  8722. child._markMatrixAsDirty();
  8723. }
  8724. };
  8725. /** Reset the scroll viewer window to initial size */
  8726. ScrollViewer.prototype.resetWindow = function () {
  8727. this._window.width = "100%";
  8728. this._window.height = "100%";
  8729. };
  8730. ScrollViewer.prototype._getTypeName = function () {
  8731. return "ScrollViewer";
  8732. };
  8733. ScrollViewer.prototype._buildClientSizes = function () {
  8734. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8735. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8736. this._clientWidth = this._window.parentClientWidth;
  8737. this._clientHeight = this._window.parentClientHeight;
  8738. };
  8739. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  8740. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8741. this._buildClientSizes();
  8742. };
  8743. ScrollViewer.prototype._postMeasure = function () {
  8744. _super.prototype._postMeasure.call(this);
  8745. this._updateScroller();
  8746. };
  8747. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  8748. /**
  8749. * Gets or sets the mouse wheel precision
  8750. * from 0 to 1 with a default value of 0.05
  8751. * */
  8752. get: function () {
  8753. return this._wheelPrecision;
  8754. },
  8755. set: function (value) {
  8756. if (this._wheelPrecision === value) {
  8757. return;
  8758. }
  8759. if (value < 0) {
  8760. value = 0;
  8761. }
  8762. if (value > 1) {
  8763. value = 1;
  8764. }
  8765. this._wheelPrecision = value;
  8766. },
  8767. enumerable: true,
  8768. configurable: true
  8769. });
  8770. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  8771. /** Gets or sets the bar color */
  8772. get: function () {
  8773. return this._barColor;
  8774. },
  8775. set: function (color) {
  8776. if (this._barColor === color) {
  8777. return;
  8778. }
  8779. this._barColor = color;
  8780. this._horizontalBar.color = color;
  8781. this._verticalBar.color = color;
  8782. },
  8783. enumerable: true,
  8784. configurable: true
  8785. });
  8786. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  8787. /** Gets or sets the size of the bar */
  8788. get: function () {
  8789. return this._barSize;
  8790. },
  8791. set: function (value) {
  8792. if (this._barSize === value) {
  8793. return;
  8794. }
  8795. this._barSize = value;
  8796. this._markAsDirty();
  8797. if (this._horizontalBar.isVisible) {
  8798. this._grid.setRowDefinition(1, this._barSize, true);
  8799. }
  8800. if (this._verticalBar.isVisible) {
  8801. this._grid.setColumnDefinition(1, this._barSize, true);
  8802. }
  8803. },
  8804. enumerable: true,
  8805. configurable: true
  8806. });
  8807. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  8808. /** Gets or sets the bar background */
  8809. get: function () {
  8810. return this._barBackground;
  8811. },
  8812. set: function (color) {
  8813. if (this._barBackground === color) {
  8814. return;
  8815. }
  8816. this._barBackground = color;
  8817. this._horizontalBar.background = color;
  8818. this._verticalBar.background = color;
  8819. this._dragSpace.background = color;
  8820. },
  8821. enumerable: true,
  8822. configurable: true
  8823. });
  8824. /** @hidden */
  8825. ScrollViewer.prototype._updateScroller = function () {
  8826. var windowContentsWidth = this._window._currentMeasure.width;
  8827. var windowContentsHeight = this._window._currentMeasure.height;
  8828. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth) {
  8829. this._grid.setRowDefinition(1, 0, true);
  8830. this._horizontalBar.isVisible = false;
  8831. this._horizontalBar.value = 0;
  8832. this._rebuildLayout = true;
  8833. }
  8834. else if (!this._horizontalBar.isVisible && windowContentsWidth > this._clientWidth) {
  8835. this._grid.setRowDefinition(1, this._barSize, true);
  8836. this._horizontalBar.isVisible = true;
  8837. this._rebuildLayout = true;
  8838. }
  8839. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight) {
  8840. this._grid.setColumnDefinition(1, 0, true);
  8841. this._verticalBar.isVisible = false;
  8842. this._verticalBar.value = 0;
  8843. this._rebuildLayout = true;
  8844. }
  8845. else if (!this._verticalBar.isVisible && windowContentsHeight > this._clientHeight) {
  8846. this._grid.setColumnDefinition(1, this._barSize, true);
  8847. this._verticalBar.isVisible = true;
  8848. this._rebuildLayout = true;
  8849. }
  8850. this._buildClientSizes();
  8851. this._endLeft = this._clientWidth - windowContentsWidth;
  8852. this._endTop = this._clientHeight - windowContentsHeight;
  8853. var newLeft = this._horizontalBar.value * this._endLeft + "px";
  8854. var newTop = this._verticalBar.value * this._endTop + "px";
  8855. if (newLeft !== this._window.left) {
  8856. this._window.left = newLeft;
  8857. this._rebuildLayout = true;
  8858. }
  8859. if (newTop !== this._window.top) {
  8860. this._window.top = newTop;
  8861. this._rebuildLayout = true;
  8862. }
  8863. var horizontalMultiplicator = this._clientWidth / windowContentsWidth;
  8864. var verticalMultiplicator = this._clientHeight / windowContentsHeight;
  8865. this._horizontalBar.thumbWidth = (this._clientWidth * horizontalMultiplicator) + "px";
  8866. this._verticalBar.thumbWidth = (this._clientHeight * verticalMultiplicator) + "px";
  8867. };
  8868. ScrollViewer.prototype._link = function (host) {
  8869. _super.prototype._link.call(this, host);
  8870. this._attachWheel();
  8871. };
  8872. /** @hidden */
  8873. ScrollViewer.prototype._attachWheel = function () {
  8874. var _this = this;
  8875. if (this._onPointerObserver) {
  8876. return;
  8877. }
  8878. var scene = this._host.getScene();
  8879. this._onPointerObserver = scene.onPointerObservable.add(function (pi, state) {
  8880. if (!_this._pointerIsOver || pi.type !== babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  8881. return;
  8882. }
  8883. if (_this._verticalBar.isVisible == true) {
  8884. if (pi.event.deltaY < 0 && _this._verticalBar.value > 0) {
  8885. _this._verticalBar.value -= _this._wheelPrecision;
  8886. }
  8887. else if (pi.event.deltaY > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  8888. _this._verticalBar.value += _this._wheelPrecision;
  8889. }
  8890. }
  8891. if (_this._horizontalBar.isVisible == true) {
  8892. if (pi.event.deltaX < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  8893. _this._horizontalBar.value += _this._wheelPrecision;
  8894. }
  8895. else if (pi.event.deltaX > 0 && _this._horizontalBar.value > 0) {
  8896. _this._horizontalBar.value -= _this._wheelPrecision;
  8897. }
  8898. }
  8899. });
  8900. };
  8901. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  8902. if (!this.isHighlighted) {
  8903. return;
  8904. }
  8905. _super.prototype._renderHighlightSpecific.call(this, context);
  8906. this._grid._renderHighlightSpecific(context);
  8907. context.restore();
  8908. };
  8909. /** Releases associated resources */
  8910. ScrollViewer.prototype.dispose = function () {
  8911. var scene = this._host.getScene();
  8912. if (scene && this._onPointerObserver) {
  8913. scene.onPointerObservable.remove(this._onPointerObserver);
  8914. this._onPointerObserver = null;
  8915. }
  8916. _super.prototype.dispose.call(this);
  8917. };
  8918. return ScrollViewer;
  8919. }(_rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]));
  8920. /***/ }),
  8921. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  8922. /*!*********************************************************!*\
  8923. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  8924. \*********************************************************/
  8925. /*! exports provided: _ScrollViewerWindow */
  8926. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8927. "use strict";
  8928. __webpack_require__.r(__webpack_exports__);
  8929. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  8930. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8931. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  8932. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  8933. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8934. /**
  8935. * Class used to hold a the container for ScrollViewer
  8936. * @hidden
  8937. */
  8938. var _ScrollViewerWindow = /** @class */ (function (_super) {
  8939. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](_ScrollViewerWindow, _super);
  8940. /**
  8941. * Creates a new ScrollViewerWindow
  8942. * @param name of ScrollViewerWindow
  8943. */
  8944. function _ScrollViewerWindow(name) {
  8945. return _super.call(this, name) || this;
  8946. }
  8947. _ScrollViewerWindow.prototype._getTypeName = function () {
  8948. return "ScrollViewerWindow";
  8949. };
  8950. /** @hidden */
  8951. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  8952. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8953. this._measureForChildren.left = this._currentMeasure.left;
  8954. this._measureForChildren.top = this._currentMeasure.top;
  8955. this._measureForChildren.width = parentMeasure.width;
  8956. this._measureForChildren.height = parentMeasure.height;
  8957. };
  8958. _ScrollViewerWindow.prototype._postMeasure = function () {
  8959. var maxWidth = this.parentClientWidth;
  8960. var maxHeight = this.parentClientHeight;
  8961. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  8962. var child = _a[_i];
  8963. if (!child.isVisible || child.notRenderable) {
  8964. continue;
  8965. }
  8966. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  8967. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  8968. }
  8969. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  8970. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  8971. }
  8972. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width);
  8973. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height);
  8974. }
  8975. if (this._currentMeasure.width !== maxWidth) {
  8976. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  8977. this._currentMeasure.width = maxWidth;
  8978. this._rebuildLayout = true;
  8979. this._isDirty = true;
  8980. }
  8981. if (this._currentMeasure.height !== maxHeight) {
  8982. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  8983. this._currentMeasure.height = maxHeight;
  8984. this._rebuildLayout = true;
  8985. this._isDirty = true;
  8986. }
  8987. _super.prototype._postMeasure.call(this);
  8988. };
  8989. return _ScrollViewerWindow;
  8990. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  8991. /***/ }),
  8992. /***/ "./2D/controls/selector.ts":
  8993. /*!*********************************!*\
  8994. !*** ./2D/controls/selector.ts ***!
  8995. \*********************************/
  8996. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  8997. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8998. "use strict";
  8999. __webpack_require__.r(__webpack_exports__);
  9000. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  9001. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  9002. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  9003. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  9004. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  9005. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9006. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  9007. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  9008. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  9009. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  9010. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  9011. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  9012. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  9013. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  9014. /** Class used to create a RadioGroup
  9015. * which contains groups of radio buttons
  9016. */
  9017. var SelectorGroup = /** @class */ (function () {
  9018. /**
  9019. * Creates a new SelectorGroup
  9020. * @param name of group, used as a group heading
  9021. */
  9022. function SelectorGroup(
  9023. /** name of SelectorGroup */
  9024. name) {
  9025. this.name = name;
  9026. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9027. this._selectors = new Array();
  9028. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9029. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9030. this._groupHeader = this._addGroupHeader(name);
  9031. }
  9032. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  9033. /** Gets the groupPanel of the SelectorGroup */
  9034. get: function () {
  9035. return this._groupPanel;
  9036. },
  9037. enumerable: true,
  9038. configurable: true
  9039. });
  9040. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  9041. /** Gets the selectors array */
  9042. get: function () {
  9043. return this._selectors;
  9044. },
  9045. enumerable: true,
  9046. configurable: true
  9047. });
  9048. Object.defineProperty(SelectorGroup.prototype, "header", {
  9049. /** Gets and sets the group header */
  9050. get: function () {
  9051. return this._groupHeader.text;
  9052. },
  9053. set: function (label) {
  9054. if (this._groupHeader.text === "label") {
  9055. return;
  9056. }
  9057. this._groupHeader.text = label;
  9058. },
  9059. enumerable: true,
  9060. configurable: true
  9061. });
  9062. /** @hidden */
  9063. SelectorGroup.prototype._addGroupHeader = function (text) {
  9064. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  9065. groupHeading.width = 0.9;
  9066. groupHeading.height = "30px";
  9067. groupHeading.textWrapping = true;
  9068. groupHeading.color = "black";
  9069. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9070. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9071. groupHeading.left = "2px";
  9072. this._groupPanel.addControl(groupHeading);
  9073. return groupHeading;
  9074. };
  9075. /** @hidden*/
  9076. SelectorGroup.prototype._getSelector = function (selectorNb) {
  9077. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9078. return;
  9079. }
  9080. return this._selectors[selectorNb];
  9081. };
  9082. /** Removes the selector at the given position
  9083. * @param selectorNb the position of the selector within the group
  9084. */
  9085. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  9086. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9087. return;
  9088. }
  9089. this._groupPanel.removeControl(this._selectors[selectorNb]);
  9090. this._selectors.splice(selectorNb, 1);
  9091. };
  9092. return SelectorGroup;
  9093. }());
  9094. /** Class used to create a CheckboxGroup
  9095. * which contains groups of checkbox buttons
  9096. */
  9097. var CheckboxGroup = /** @class */ (function (_super) {
  9098. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CheckboxGroup, _super);
  9099. function CheckboxGroup() {
  9100. return _super !== null && _super.apply(this, arguments) || this;
  9101. }
  9102. /** Adds a checkbox as a control
  9103. * @param text is the label for the selector
  9104. * @param func is the function called when the Selector is checked
  9105. * @param checked is true when Selector is checked
  9106. */
  9107. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  9108. if (func === void 0) { func = function (s) { }; }
  9109. if (checked === void 0) { checked = false; }
  9110. var checked = checked || false;
  9111. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  9112. button.width = "20px";
  9113. button.height = "20px";
  9114. button.color = "#364249";
  9115. button.background = "#CCCCCC";
  9116. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9117. button.onIsCheckedChangedObservable.add(function (state) {
  9118. func(state);
  9119. });
  9120. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  9121. _selector.height = "30px";
  9122. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9123. _selector.left = "4px";
  9124. this.groupPanel.addControl(_selector);
  9125. this.selectors.push(_selector);
  9126. button.isChecked = checked;
  9127. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9128. button.color = this.groupPanel.parent.parent.buttonColor;
  9129. button.background = this.groupPanel.parent.parent.buttonBackground;
  9130. }
  9131. };
  9132. /** @hidden */
  9133. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9134. this.selectors[selectorNb].children[1].text = label;
  9135. };
  9136. /** @hidden */
  9137. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9138. this.selectors[selectorNb].children[1].color = color;
  9139. };
  9140. /** @hidden */
  9141. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9142. this.selectors[selectorNb].children[0].color = color;
  9143. };
  9144. /** @hidden */
  9145. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9146. this.selectors[selectorNb].children[0].background = color;
  9147. };
  9148. return CheckboxGroup;
  9149. }(SelectorGroup));
  9150. /** Class used to create a RadioGroup
  9151. * which contains groups of radio buttons
  9152. */
  9153. var RadioGroup = /** @class */ (function (_super) {
  9154. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RadioGroup, _super);
  9155. function RadioGroup() {
  9156. var _this = _super !== null && _super.apply(this, arguments) || this;
  9157. _this._selectNb = 0;
  9158. return _this;
  9159. }
  9160. /** Adds a radio button as a control
  9161. * @param label is the label for the selector
  9162. * @param func is the function called when the Selector is checked
  9163. * @param checked is true when Selector is checked
  9164. */
  9165. RadioGroup.prototype.addRadio = function (label, func, checked) {
  9166. if (func === void 0) { func = function (n) { }; }
  9167. if (checked === void 0) { checked = false; }
  9168. var nb = this._selectNb++;
  9169. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  9170. button.name = label;
  9171. button.width = "20px";
  9172. button.height = "20px";
  9173. button.color = "#364249";
  9174. button.background = "#CCCCCC";
  9175. button.group = this.name;
  9176. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9177. button.onIsCheckedChangedObservable.add(function (state) {
  9178. if (state) {
  9179. func(nb);
  9180. }
  9181. });
  9182. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  9183. _selector.height = "30px";
  9184. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9185. _selector.left = "4px";
  9186. this.groupPanel.addControl(_selector);
  9187. this.selectors.push(_selector);
  9188. button.isChecked = checked;
  9189. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9190. button.color = this.groupPanel.parent.parent.buttonColor;
  9191. button.background = this.groupPanel.parent.parent.buttonBackground;
  9192. }
  9193. };
  9194. /** @hidden */
  9195. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9196. this.selectors[selectorNb].children[1].text = label;
  9197. };
  9198. /** @hidden */
  9199. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9200. this.selectors[selectorNb].children[1].color = color;
  9201. };
  9202. /** @hidden */
  9203. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9204. this.selectors[selectorNb].children[0].color = color;
  9205. };
  9206. /** @hidden */
  9207. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9208. this.selectors[selectorNb].children[0].background = color;
  9209. };
  9210. return RadioGroup;
  9211. }(SelectorGroup));
  9212. /** Class used to create a SliderGroup
  9213. * which contains groups of slider buttons
  9214. */
  9215. var SliderGroup = /** @class */ (function (_super) {
  9216. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SliderGroup, _super);
  9217. function SliderGroup() {
  9218. return _super !== null && _super.apply(this, arguments) || this;
  9219. }
  9220. /**
  9221. * Adds a slider to the SelectorGroup
  9222. * @param label is the label for the SliderBar
  9223. * @param func is the function called when the Slider moves
  9224. * @param unit is a string describing the units used, eg degrees or metres
  9225. * @param min is the minimum value for the Slider
  9226. * @param max is the maximum value for the Slider
  9227. * @param value is the start value for the Slider between min and max
  9228. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  9229. */
  9230. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  9231. if (func === void 0) { func = function (v) { }; }
  9232. if (unit === void 0) { unit = "Units"; }
  9233. if (min === void 0) { min = 0; }
  9234. if (max === void 0) { max = 0; }
  9235. if (value === void 0) { value = 0; }
  9236. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  9237. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  9238. button.name = unit;
  9239. button.value = value;
  9240. button.minimum = min;
  9241. button.maximum = max;
  9242. button.width = 0.9;
  9243. button.height = "20px";
  9244. button.color = "#364249";
  9245. button.background = "#CCCCCC";
  9246. button.borderColor = "black";
  9247. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9248. button.left = "4px";
  9249. button.paddingBottom = "4px";
  9250. button.onValueChangedObservable.add(function (value) {
  9251. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  9252. func(value);
  9253. });
  9254. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  9255. _selector.height = "60px";
  9256. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9257. _selector.left = "4px";
  9258. _selector.children[0].name = label;
  9259. this.groupPanel.addControl(_selector);
  9260. this.selectors.push(_selector);
  9261. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9262. button.color = this.groupPanel.parent.parent.buttonColor;
  9263. button.background = this.groupPanel.parent.parent.buttonBackground;
  9264. }
  9265. };
  9266. /** @hidden */
  9267. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9268. this.selectors[selectorNb].children[0].name = label;
  9269. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  9270. };
  9271. /** @hidden */
  9272. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9273. this.selectors[selectorNb].children[0].color = color;
  9274. };
  9275. /** @hidden */
  9276. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9277. this.selectors[selectorNb].children[1].color = color;
  9278. };
  9279. /** @hidden */
  9280. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9281. this.selectors[selectorNb].children[1].background = color;
  9282. };
  9283. return SliderGroup;
  9284. }(SelectorGroup));
  9285. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  9286. * @see http://doc.babylonjs.com/how_to/selector
  9287. */
  9288. var SelectionPanel = /** @class */ (function (_super) {
  9289. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SelectionPanel, _super);
  9290. /**
  9291. * Creates a new SelectionPanel
  9292. * @param name of SelectionPanel
  9293. * @param groups is an array of SelectionGroups
  9294. */
  9295. function SelectionPanel(
  9296. /** name of SelectionPanel */
  9297. name,
  9298. /** an array of SelectionGroups */
  9299. groups) {
  9300. if (groups === void 0) { groups = []; }
  9301. var _this = _super.call(this, name) || this;
  9302. _this.name = name;
  9303. _this.groups = groups;
  9304. _this._buttonColor = "#364249";
  9305. _this._buttonBackground = "#CCCCCC";
  9306. _this._headerColor = "black";
  9307. _this._barColor = "white";
  9308. _this._barHeight = "2px";
  9309. _this._spacerHeight = "20px";
  9310. _this._bars = new Array();
  9311. _this._groups = groups;
  9312. _this.thickness = 2;
  9313. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9314. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9315. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9316. _this._panel.top = 5;
  9317. _this._panel.left = 5;
  9318. _this._panel.width = 0.95;
  9319. if (groups.length > 0) {
  9320. for (var i = 0; i < groups.length - 1; i++) {
  9321. _this._panel.addControl(groups[i].groupPanel);
  9322. _this._addSpacer();
  9323. }
  9324. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  9325. }
  9326. _this.addControl(_this._panel);
  9327. return _this;
  9328. }
  9329. SelectionPanel.prototype._getTypeName = function () {
  9330. return "SelectionPanel";
  9331. };
  9332. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  9333. /** Gets or sets the headerColor */
  9334. get: function () {
  9335. return this._headerColor;
  9336. },
  9337. set: function (color) {
  9338. if (this._headerColor === color) {
  9339. return;
  9340. }
  9341. this._headerColor = color;
  9342. this._setHeaderColor();
  9343. },
  9344. enumerable: true,
  9345. configurable: true
  9346. });
  9347. SelectionPanel.prototype._setHeaderColor = function () {
  9348. for (var i = 0; i < this._groups.length; i++) {
  9349. this._groups[i].groupPanel.children[0].color = this._headerColor;
  9350. }
  9351. };
  9352. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  9353. /** Gets or sets the button color */
  9354. get: function () {
  9355. return this._buttonColor;
  9356. },
  9357. set: function (color) {
  9358. if (this._buttonColor === color) {
  9359. return;
  9360. }
  9361. this._buttonColor = color;
  9362. this._setbuttonColor();
  9363. },
  9364. enumerable: true,
  9365. configurable: true
  9366. });
  9367. SelectionPanel.prototype._setbuttonColor = function () {
  9368. for (var i = 0; i < this._groups.length; i++) {
  9369. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9370. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  9371. }
  9372. }
  9373. };
  9374. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  9375. /** Gets or sets the label color */
  9376. get: function () {
  9377. return this._labelColor;
  9378. },
  9379. set: function (color) {
  9380. if (this._labelColor === color) {
  9381. return;
  9382. }
  9383. this._labelColor = color;
  9384. this._setLabelColor();
  9385. },
  9386. enumerable: true,
  9387. configurable: true
  9388. });
  9389. SelectionPanel.prototype._setLabelColor = function () {
  9390. for (var i = 0; i < this._groups.length; i++) {
  9391. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9392. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  9393. }
  9394. }
  9395. };
  9396. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  9397. /** Gets or sets the button background */
  9398. get: function () {
  9399. return this._buttonBackground;
  9400. },
  9401. set: function (color) {
  9402. if (this._buttonBackground === color) {
  9403. return;
  9404. }
  9405. this._buttonBackground = color;
  9406. this._setButtonBackground();
  9407. },
  9408. enumerable: true,
  9409. configurable: true
  9410. });
  9411. SelectionPanel.prototype._setButtonBackground = function () {
  9412. for (var i = 0; i < this._groups.length; i++) {
  9413. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9414. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  9415. }
  9416. }
  9417. };
  9418. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  9419. /** Gets or sets the color of separator bar */
  9420. get: function () {
  9421. return this._barColor;
  9422. },
  9423. set: function (color) {
  9424. if (this._barColor === color) {
  9425. return;
  9426. }
  9427. this._barColor = color;
  9428. this._setBarColor();
  9429. },
  9430. enumerable: true,
  9431. configurable: true
  9432. });
  9433. SelectionPanel.prototype._setBarColor = function () {
  9434. for (var i = 0; i < this._bars.length; i++) {
  9435. this._bars[i].children[0].background = this._barColor;
  9436. }
  9437. };
  9438. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  9439. /** Gets or sets the height of separator bar */
  9440. get: function () {
  9441. return this._barHeight;
  9442. },
  9443. set: function (value) {
  9444. if (this._barHeight === value) {
  9445. return;
  9446. }
  9447. this._barHeight = value;
  9448. this._setBarHeight();
  9449. },
  9450. enumerable: true,
  9451. configurable: true
  9452. });
  9453. SelectionPanel.prototype._setBarHeight = function () {
  9454. for (var i = 0; i < this._bars.length; i++) {
  9455. this._bars[i].children[0].height = this._barHeight;
  9456. }
  9457. };
  9458. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  9459. /** Gets or sets the height of spacers*/
  9460. get: function () {
  9461. return this._spacerHeight;
  9462. },
  9463. set: function (value) {
  9464. if (this._spacerHeight === value) {
  9465. return;
  9466. }
  9467. this._spacerHeight = value;
  9468. this._setSpacerHeight();
  9469. },
  9470. enumerable: true,
  9471. configurable: true
  9472. });
  9473. SelectionPanel.prototype._setSpacerHeight = function () {
  9474. for (var i = 0; i < this._bars.length; i++) {
  9475. this._bars[i].height = this._spacerHeight;
  9476. }
  9477. };
  9478. /** Adds a bar between groups */
  9479. SelectionPanel.prototype._addSpacer = function () {
  9480. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  9481. separator.width = 1;
  9482. separator.height = this._spacerHeight;
  9483. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9484. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9485. bar.width = 1;
  9486. bar.height = this._barHeight;
  9487. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9488. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9489. bar.background = this._barColor;
  9490. bar.color = "transparent";
  9491. separator.addControl(bar);
  9492. this._panel.addControl(separator);
  9493. this._bars.push(separator);
  9494. };
  9495. /** Add a group to the selection panel
  9496. * @param group is the selector group to add
  9497. */
  9498. SelectionPanel.prototype.addGroup = function (group) {
  9499. if (this._groups.length > 0) {
  9500. this._addSpacer();
  9501. }
  9502. this._panel.addControl(group.groupPanel);
  9503. this._groups.push(group);
  9504. group.groupPanel.children[0].color = this._headerColor;
  9505. for (var j = 0; j < group.selectors.length; j++) {
  9506. group._setSelectorButtonColor(j, this._buttonColor);
  9507. group._setSelectorButtonBackground(j, this._buttonBackground);
  9508. }
  9509. };
  9510. /** Remove the group from the given position
  9511. * @param groupNb is the position of the group in the list
  9512. */
  9513. SelectionPanel.prototype.removeGroup = function (groupNb) {
  9514. if (groupNb < 0 || groupNb >= this._groups.length) {
  9515. return;
  9516. }
  9517. var group = this._groups[groupNb];
  9518. this._panel.removeControl(group.groupPanel);
  9519. this._groups.splice(groupNb, 1);
  9520. if (groupNb < this._bars.length) {
  9521. this._panel.removeControl(this._bars[groupNb]);
  9522. this._bars.splice(groupNb, 1);
  9523. }
  9524. };
  9525. /** Change a group header label
  9526. * @param label is the new group header label
  9527. * @param groupNb is the number of the group to relabel
  9528. * */
  9529. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  9530. if (groupNb < 0 || groupNb >= this._groups.length) {
  9531. return;
  9532. }
  9533. var group = this._groups[groupNb];
  9534. group.groupPanel.children[0].text = label;
  9535. };
  9536. /** Change selector label to the one given
  9537. * @param label is the new selector label
  9538. * @param groupNb is the number of the groupcontaining the selector
  9539. * @param selectorNb is the number of the selector within a group to relabel
  9540. * */
  9541. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  9542. if (groupNb < 0 || groupNb >= this._groups.length) {
  9543. return;
  9544. }
  9545. var group = this._groups[groupNb];
  9546. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9547. return;
  9548. }
  9549. group._setSelectorLabel(selectorNb, label);
  9550. };
  9551. /** For a given group position remove the selector at the given position
  9552. * @param groupNb is the number of the group to remove the selector from
  9553. * @param selectorNb is the number of the selector within the group
  9554. */
  9555. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  9556. if (groupNb < 0 || groupNb >= this._groups.length) {
  9557. return;
  9558. }
  9559. var group = this._groups[groupNb];
  9560. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9561. return;
  9562. }
  9563. group.removeSelector(selectorNb);
  9564. };
  9565. /** For a given group position of correct type add a checkbox button
  9566. * @param groupNb is the number of the group to remove the selector from
  9567. * @param label is the label for the selector
  9568. * @param func is the function called when the Selector is checked
  9569. * @param checked is true when Selector is checked
  9570. */
  9571. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  9572. if (func === void 0) { func = function () { }; }
  9573. if (checked === void 0) { checked = false; }
  9574. if (groupNb < 0 || groupNb >= this._groups.length) {
  9575. return;
  9576. }
  9577. var group = this._groups[groupNb];
  9578. group.addCheckbox(label, func, checked);
  9579. };
  9580. /** For a given group position of correct type add a radio button
  9581. * @param groupNb is the number of the group to remove the selector from
  9582. * @param label is the label for the selector
  9583. * @param func is the function called when the Selector is checked
  9584. * @param checked is true when Selector is checked
  9585. */
  9586. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  9587. if (func === void 0) { func = function () { }; }
  9588. if (checked === void 0) { checked = false; }
  9589. if (groupNb < 0 || groupNb >= this._groups.length) {
  9590. return;
  9591. }
  9592. var group = this._groups[groupNb];
  9593. group.addRadio(label, func, checked);
  9594. };
  9595. /**
  9596. * For a given slider group add a slider
  9597. * @param groupNb is the number of the group to add the slider to
  9598. * @param label is the label for the Slider
  9599. * @param func is the function called when the Slider moves
  9600. * @param unit is a string describing the units used, eg degrees or metres
  9601. * @param min is the minimum value for the Slider
  9602. * @param max is the maximum value for the Slider
  9603. * @param value is the start value for the Slider between min and max
  9604. * @param onVal is the function used to format the value displayed, eg radians to degrees
  9605. */
  9606. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  9607. if (func === void 0) { func = function () { }; }
  9608. if (unit === void 0) { unit = "Units"; }
  9609. if (min === void 0) { min = 0; }
  9610. if (max === void 0) { max = 0; }
  9611. if (value === void 0) { value = 0; }
  9612. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  9613. if (groupNb < 0 || groupNb >= this._groups.length) {
  9614. return;
  9615. }
  9616. var group = this._groups[groupNb];
  9617. group.addSlider(label, func, unit, min, max, value, onVal);
  9618. };
  9619. return SelectionPanel;
  9620. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  9621. /***/ }),
  9622. /***/ "./2D/controls/sliders/baseSlider.ts":
  9623. /*!*******************************************!*\
  9624. !*** ./2D/controls/sliders/baseSlider.ts ***!
  9625. \*******************************************/
  9626. /*! exports provided: BaseSlider */
  9627. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9628. "use strict";
  9629. __webpack_require__.r(__webpack_exports__);
  9630. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  9631. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9632. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  9633. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  9634. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9635. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9636. /**
  9637. * Class used to create slider controls
  9638. */
  9639. var BaseSlider = /** @class */ (function (_super) {
  9640. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BaseSlider, _super);
  9641. /**
  9642. * Creates a new BaseSlider
  9643. * @param name defines the control name
  9644. */
  9645. function BaseSlider(name) {
  9646. var _this = _super.call(this, name) || this;
  9647. _this.name = name;
  9648. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9649. _this._minimum = 0;
  9650. _this._maximum = 100;
  9651. _this._value = 50;
  9652. _this._isVertical = false;
  9653. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9654. _this._isThumbClamped = false;
  9655. _this._displayThumb = true;
  9656. // Shared rendering info
  9657. _this._effectiveBarOffset = 0;
  9658. /** Observable raised when the sldier value changes */
  9659. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  9660. // Events
  9661. _this._pointerIsDown = false;
  9662. _this.isPointerBlocker = true;
  9663. return _this;
  9664. }
  9665. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  9666. /** Gets or sets a boolean indicating if the thumb must be rendered */
  9667. get: function () {
  9668. return this._displayThumb;
  9669. },
  9670. set: function (value) {
  9671. if (this._displayThumb === value) {
  9672. return;
  9673. }
  9674. this._displayThumb = value;
  9675. this._markAsDirty();
  9676. },
  9677. enumerable: true,
  9678. configurable: true
  9679. });
  9680. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  9681. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  9682. get: function () {
  9683. return this._barOffset.toString(this._host);
  9684. },
  9685. set: function (value) {
  9686. if (this._barOffset.toString(this._host) === value) {
  9687. return;
  9688. }
  9689. if (this._barOffset.fromString(value)) {
  9690. this._markAsDirty();
  9691. }
  9692. },
  9693. enumerable: true,
  9694. configurable: true
  9695. });
  9696. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  9697. /** Gets main bar offset in pixels*/
  9698. get: function () {
  9699. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9700. },
  9701. enumerable: true,
  9702. configurable: true
  9703. });
  9704. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  9705. /** Gets or sets thumb width */
  9706. get: function () {
  9707. return this._thumbWidth.toString(this._host);
  9708. },
  9709. set: function (value) {
  9710. if (this._thumbWidth.toString(this._host) === value) {
  9711. return;
  9712. }
  9713. if (this._thumbWidth.fromString(value)) {
  9714. this._markAsDirty();
  9715. }
  9716. },
  9717. enumerable: true,
  9718. configurable: true
  9719. });
  9720. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  9721. /** Gets thumb width in pixels */
  9722. get: function () {
  9723. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9724. },
  9725. enumerable: true,
  9726. configurable: true
  9727. });
  9728. Object.defineProperty(BaseSlider.prototype, "minimum", {
  9729. /** Gets or sets minimum value */
  9730. get: function () {
  9731. return this._minimum;
  9732. },
  9733. set: function (value) {
  9734. if (this._minimum === value) {
  9735. return;
  9736. }
  9737. this._minimum = value;
  9738. this._markAsDirty();
  9739. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9740. },
  9741. enumerable: true,
  9742. configurable: true
  9743. });
  9744. Object.defineProperty(BaseSlider.prototype, "maximum", {
  9745. /** Gets or sets maximum value */
  9746. get: function () {
  9747. return this._maximum;
  9748. },
  9749. set: function (value) {
  9750. if (this._maximum === value) {
  9751. return;
  9752. }
  9753. this._maximum = value;
  9754. this._markAsDirty();
  9755. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9756. },
  9757. enumerable: true,
  9758. configurable: true
  9759. });
  9760. Object.defineProperty(BaseSlider.prototype, "value", {
  9761. /** Gets or sets current value */
  9762. get: function () {
  9763. return this._value;
  9764. },
  9765. set: function (value) {
  9766. value = Math.max(Math.min(value, this._maximum), this._minimum);
  9767. if (this._value === value) {
  9768. return;
  9769. }
  9770. this._value = value;
  9771. this._markAsDirty();
  9772. this.onValueChangedObservable.notifyObservers(this._value);
  9773. },
  9774. enumerable: true,
  9775. configurable: true
  9776. });
  9777. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  9778. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  9779. get: function () {
  9780. return this._isVertical;
  9781. },
  9782. set: function (value) {
  9783. if (this._isVertical === value) {
  9784. return;
  9785. }
  9786. this._isVertical = value;
  9787. this._markAsDirty();
  9788. },
  9789. enumerable: true,
  9790. configurable: true
  9791. });
  9792. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  9793. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  9794. get: function () {
  9795. return this._isThumbClamped;
  9796. },
  9797. set: function (value) {
  9798. if (this._isThumbClamped === value) {
  9799. return;
  9800. }
  9801. this._isThumbClamped = value;
  9802. this._markAsDirty();
  9803. },
  9804. enumerable: true,
  9805. configurable: true
  9806. });
  9807. BaseSlider.prototype._getTypeName = function () {
  9808. return "BaseSlider";
  9809. };
  9810. BaseSlider.prototype._getThumbPosition = function () {
  9811. if (this.isVertical) {
  9812. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  9813. }
  9814. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  9815. };
  9816. BaseSlider.prototype._getThumbThickness = function (type) {
  9817. var thumbThickness = 0;
  9818. switch (type) {
  9819. case "circle":
  9820. if (this._thumbWidth.isPixel) {
  9821. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  9822. }
  9823. else {
  9824. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  9825. }
  9826. break;
  9827. case "rectangle":
  9828. if (this._thumbWidth.isPixel) {
  9829. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  9830. }
  9831. else {
  9832. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  9833. }
  9834. }
  9835. return thumbThickness;
  9836. };
  9837. BaseSlider.prototype._prepareRenderingData = function (type) {
  9838. // Main bar
  9839. this._effectiveBarOffset = 0;
  9840. this._renderLeft = this._currentMeasure.left;
  9841. this._renderTop = this._currentMeasure.top;
  9842. this._renderWidth = this._currentMeasure.width;
  9843. this._renderHeight = this._currentMeasure.height;
  9844. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  9845. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  9846. this._effectiveThumbThickness = this._getThumbThickness(type);
  9847. if (this.displayThumb) {
  9848. this._backgroundBoxLength -= this._effectiveThumbThickness;
  9849. }
  9850. //throw error when height is less than width for vertical slider
  9851. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  9852. console.error("Height should be greater than width");
  9853. return;
  9854. }
  9855. if (this._barOffset.isPixel) {
  9856. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  9857. }
  9858. else {
  9859. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  9860. }
  9861. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  9862. if (this.isVertical) {
  9863. this._renderLeft += this._effectiveBarOffset;
  9864. if (!this.isThumbClamped && this.displayThumb) {
  9865. this._renderTop += (this._effectiveThumbThickness / 2);
  9866. }
  9867. this._renderHeight = this._backgroundBoxLength;
  9868. this._renderWidth = this._backgroundBoxThickness;
  9869. }
  9870. else {
  9871. this._renderTop += this._effectiveBarOffset;
  9872. if (!this.isThumbClamped && this.displayThumb) {
  9873. this._renderLeft += (this._effectiveThumbThickness / 2);
  9874. }
  9875. this._renderHeight = this._backgroundBoxThickness;
  9876. this._renderWidth = this._backgroundBoxLength;
  9877. }
  9878. };
  9879. /** @hidden */
  9880. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  9881. if (this.rotation != 0) {
  9882. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  9883. x = this._transformedPosition.x;
  9884. y = this._transformedPosition.y;
  9885. }
  9886. if (this._isVertical) {
  9887. this.value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  9888. }
  9889. else {
  9890. this.value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  9891. }
  9892. };
  9893. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  9894. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  9895. return false;
  9896. }
  9897. this._pointerIsDown = true;
  9898. this._updateValueFromPointer(coordinates.x, coordinates.y);
  9899. this._host._capturingControl[pointerId] = this;
  9900. return true;
  9901. };
  9902. BaseSlider.prototype._onPointerMove = function (target, coordinates) {
  9903. if (this._pointerIsDown) {
  9904. this._updateValueFromPointer(coordinates.x, coordinates.y);
  9905. }
  9906. _super.prototype._onPointerMove.call(this, target, coordinates);
  9907. };
  9908. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  9909. this._pointerIsDown = false;
  9910. delete this._host._capturingControl[pointerId];
  9911. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  9912. };
  9913. return BaseSlider;
  9914. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  9915. /***/ }),
  9916. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  9917. /*!*************************************************!*\
  9918. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  9919. \*************************************************/
  9920. /*! exports provided: ImageBasedSlider */
  9921. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9922. "use strict";
  9923. __webpack_require__.r(__webpack_exports__);
  9924. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  9925. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9926. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  9927. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  9928. /**
  9929. * Class used to create slider controls based on images
  9930. */
  9931. var ImageBasedSlider = /** @class */ (function (_super) {
  9932. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageBasedSlider, _super);
  9933. /**
  9934. * Creates a new ImageBasedSlider
  9935. * @param name defines the control name
  9936. */
  9937. function ImageBasedSlider(name) {
  9938. var _this = _super.call(this, name) || this;
  9939. _this.name = name;
  9940. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  9941. return _this;
  9942. }
  9943. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  9944. get: function () {
  9945. return this._displayThumb && this.thumbImage != null;
  9946. },
  9947. set: function (value) {
  9948. if (this._displayThumb === value) {
  9949. return;
  9950. }
  9951. this._displayThumb = value;
  9952. this._markAsDirty();
  9953. },
  9954. enumerable: true,
  9955. configurable: true
  9956. });
  9957. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  9958. /**
  9959. * Gets or sets the image used to render the background
  9960. */
  9961. get: function () {
  9962. return this._backgroundImage;
  9963. },
  9964. set: function (value) {
  9965. var _this = this;
  9966. if (this._backgroundImage === value) {
  9967. return;
  9968. }
  9969. this._backgroundImage = value;
  9970. if (value && !value.isLoaded) {
  9971. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  9972. }
  9973. this._markAsDirty();
  9974. },
  9975. enumerable: true,
  9976. configurable: true
  9977. });
  9978. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  9979. /**
  9980. * Gets or sets the image used to render the value bar
  9981. */
  9982. get: function () {
  9983. return this._valueBarImage;
  9984. },
  9985. set: function (value) {
  9986. var _this = this;
  9987. if (this._valueBarImage === value) {
  9988. return;
  9989. }
  9990. this._valueBarImage = value;
  9991. if (value && !value.isLoaded) {
  9992. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  9993. }
  9994. this._markAsDirty();
  9995. },
  9996. enumerable: true,
  9997. configurable: true
  9998. });
  9999. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  10000. /**
  10001. * Gets or sets the image used to render the thumb
  10002. */
  10003. get: function () {
  10004. return this._thumbImage;
  10005. },
  10006. set: function (value) {
  10007. var _this = this;
  10008. if (this._thumbImage === value) {
  10009. return;
  10010. }
  10011. this._thumbImage = value;
  10012. if (value && !value.isLoaded) {
  10013. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10014. }
  10015. this._markAsDirty();
  10016. },
  10017. enumerable: true,
  10018. configurable: true
  10019. });
  10020. ImageBasedSlider.prototype._getTypeName = function () {
  10021. return "ImageBasedSlider";
  10022. };
  10023. ImageBasedSlider.prototype._draw = function (context) {
  10024. context.save();
  10025. this._applyStates(context);
  10026. this._prepareRenderingData("rectangle");
  10027. var thumbPosition = this._getThumbPosition();
  10028. var left = this._renderLeft;
  10029. var top = this._renderTop;
  10030. var width = this._renderWidth;
  10031. var height = this._renderHeight;
  10032. // Background
  10033. if (this._backgroundImage) {
  10034. this._tempMeasure.copyFromFloats(left, top, width, height);
  10035. if (this.isThumbClamped && this.displayThumb) {
  10036. if (this.isVertical) {
  10037. this._tempMeasure.height += this._effectiveThumbThickness;
  10038. }
  10039. else {
  10040. this._tempMeasure.width += this._effectiveThumbThickness;
  10041. }
  10042. }
  10043. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  10044. this._backgroundImage._draw(context);
  10045. }
  10046. // Bar
  10047. if (this._valueBarImage) {
  10048. if (this.isVertical) {
  10049. if (this.isThumbClamped && this.displayThumb) {
  10050. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10051. }
  10052. else {
  10053. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  10054. }
  10055. }
  10056. else {
  10057. if (this.isThumbClamped && this.displayThumb) {
  10058. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  10059. }
  10060. else {
  10061. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  10062. }
  10063. }
  10064. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  10065. this._valueBarImage._draw(context);
  10066. }
  10067. // Thumb
  10068. if (this.displayThumb) {
  10069. if (this.isVertical) {
  10070. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10071. }
  10072. else {
  10073. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10074. }
  10075. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  10076. this._thumbImage._draw(context);
  10077. }
  10078. context.restore();
  10079. };
  10080. return ImageBasedSlider;
  10081. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10082. /***/ }),
  10083. /***/ "./2D/controls/sliders/scrollBar.ts":
  10084. /*!******************************************!*\
  10085. !*** ./2D/controls/sliders/scrollBar.ts ***!
  10086. \******************************************/
  10087. /*! exports provided: ScrollBar */
  10088. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10089. "use strict";
  10090. __webpack_require__.r(__webpack_exports__);
  10091. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  10092. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10093. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10094. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10095. /**
  10096. * Class used to create slider controls
  10097. */
  10098. var ScrollBar = /** @class */ (function (_super) {
  10099. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScrollBar, _super);
  10100. /**
  10101. * Creates a new Slider
  10102. * @param name defines the control name
  10103. */
  10104. function ScrollBar(name) {
  10105. var _this = _super.call(this, name) || this;
  10106. _this.name = name;
  10107. _this._background = "black";
  10108. _this._borderColor = "white";
  10109. _this._thumbMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10110. return _this;
  10111. }
  10112. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  10113. /** Gets or sets border color */
  10114. get: function () {
  10115. return this._borderColor;
  10116. },
  10117. set: function (value) {
  10118. if (this._borderColor === value) {
  10119. return;
  10120. }
  10121. this._borderColor = value;
  10122. this._markAsDirty();
  10123. },
  10124. enumerable: true,
  10125. configurable: true
  10126. });
  10127. Object.defineProperty(ScrollBar.prototype, "background", {
  10128. /** Gets or sets background color */
  10129. get: function () {
  10130. return this._background;
  10131. },
  10132. set: function (value) {
  10133. if (this._background === value) {
  10134. return;
  10135. }
  10136. this._background = value;
  10137. this._markAsDirty();
  10138. },
  10139. enumerable: true,
  10140. configurable: true
  10141. });
  10142. ScrollBar.prototype._getTypeName = function () {
  10143. return "Scrollbar";
  10144. };
  10145. ScrollBar.prototype._getThumbThickness = function () {
  10146. var thumbThickness = 0;
  10147. if (this._thumbWidth.isPixel) {
  10148. thumbThickness = this._thumbWidth.getValue(this._host);
  10149. }
  10150. else {
  10151. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10152. }
  10153. return thumbThickness;
  10154. };
  10155. ScrollBar.prototype._draw = function (context) {
  10156. context.save();
  10157. this._applyStates(context);
  10158. this._prepareRenderingData("rectangle");
  10159. var left = this._renderLeft;
  10160. var thumbPosition = this._getThumbPosition();
  10161. context.fillStyle = this._background;
  10162. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  10163. // Value bar
  10164. context.fillStyle = this.color;
  10165. // Thumb
  10166. if (this.isVertical) {
  10167. this._thumbMeasure.left = left - this._effectiveBarOffset;
  10168. this._thumbMeasure.top = this._currentMeasure.top + thumbPosition;
  10169. this._thumbMeasure.width = this._currentMeasure.width;
  10170. this._thumbMeasure.height = this._effectiveThumbThickness;
  10171. }
  10172. else {
  10173. this._thumbMeasure.left = this._currentMeasure.left + thumbPosition;
  10174. this._thumbMeasure.top = this._currentMeasure.top;
  10175. this._thumbMeasure.width = this._effectiveThumbThickness;
  10176. this._thumbMeasure.height = this._currentMeasure.height;
  10177. }
  10178. context.fillRect(this._thumbMeasure.left, this._thumbMeasure.top, this._thumbMeasure.width, this._thumbMeasure.height);
  10179. context.restore();
  10180. };
  10181. /** @hidden */
  10182. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  10183. if (this.rotation != 0) {
  10184. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10185. x = this._transformedPosition.x;
  10186. y = this._transformedPosition.y;
  10187. }
  10188. if (this._first) {
  10189. this._first = false;
  10190. this._originX = x;
  10191. this._originY = y;
  10192. // Check if move is required
  10193. if (x < this._thumbMeasure.left || x > this._thumbMeasure.left + this._thumbMeasure.width || y < this._thumbMeasure.top || y > this._thumbMeasure.top + this._thumbMeasure.height) {
  10194. if (this.isVertical) {
  10195. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  10196. }
  10197. else {
  10198. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  10199. }
  10200. }
  10201. }
  10202. // Delta mode
  10203. var delta = 0;
  10204. if (this.isVertical) {
  10205. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  10206. }
  10207. else {
  10208. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  10209. }
  10210. this.value += delta * (this.maximum - this.minimum);
  10211. this._originX = x;
  10212. this._originY = y;
  10213. };
  10214. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10215. this._first = true;
  10216. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  10217. };
  10218. return ScrollBar;
  10219. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10220. /***/ }),
  10221. /***/ "./2D/controls/sliders/slider.ts":
  10222. /*!***************************************!*\
  10223. !*** ./2D/controls/sliders/slider.ts ***!
  10224. \***************************************/
  10225. /*! exports provided: Slider */
  10226. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10227. "use strict";
  10228. __webpack_require__.r(__webpack_exports__);
  10229. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  10230. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10231. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10232. /**
  10233. * Class used to create slider controls
  10234. */
  10235. var Slider = /** @class */ (function (_super) {
  10236. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Slider, _super);
  10237. /**
  10238. * Creates a new Slider
  10239. * @param name defines the control name
  10240. */
  10241. function Slider(name) {
  10242. var _this = _super.call(this, name) || this;
  10243. _this.name = name;
  10244. _this._background = "black";
  10245. _this._borderColor = "white";
  10246. _this._isThumbCircle = false;
  10247. _this._displayValueBar = true;
  10248. return _this;
  10249. }
  10250. Object.defineProperty(Slider.prototype, "displayValueBar", {
  10251. /** Gets or sets a boolean indicating if the value bar must be rendered */
  10252. get: function () {
  10253. return this._displayValueBar;
  10254. },
  10255. set: function (value) {
  10256. if (this._displayValueBar === value) {
  10257. return;
  10258. }
  10259. this._displayValueBar = value;
  10260. this._markAsDirty();
  10261. },
  10262. enumerable: true,
  10263. configurable: true
  10264. });
  10265. Object.defineProperty(Slider.prototype, "borderColor", {
  10266. /** Gets or sets border color */
  10267. get: function () {
  10268. return this._borderColor;
  10269. },
  10270. set: function (value) {
  10271. if (this._borderColor === value) {
  10272. return;
  10273. }
  10274. this._borderColor = value;
  10275. this._markAsDirty();
  10276. },
  10277. enumerable: true,
  10278. configurable: true
  10279. });
  10280. Object.defineProperty(Slider.prototype, "background", {
  10281. /** Gets or sets background color */
  10282. get: function () {
  10283. return this._background;
  10284. },
  10285. set: function (value) {
  10286. if (this._background === value) {
  10287. return;
  10288. }
  10289. this._background = value;
  10290. this._markAsDirty();
  10291. },
  10292. enumerable: true,
  10293. configurable: true
  10294. });
  10295. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  10296. /** Gets or sets a boolean indicating if the thumb should be round or square */
  10297. get: function () {
  10298. return this._isThumbCircle;
  10299. },
  10300. set: function (value) {
  10301. if (this._isThumbCircle === value) {
  10302. return;
  10303. }
  10304. this._isThumbCircle = value;
  10305. this._markAsDirty();
  10306. },
  10307. enumerable: true,
  10308. configurable: true
  10309. });
  10310. Slider.prototype._getTypeName = function () {
  10311. return "Slider";
  10312. };
  10313. Slider.prototype._draw = function (context) {
  10314. context.save();
  10315. this._applyStates(context);
  10316. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  10317. var left = this._renderLeft;
  10318. var top = this._renderTop;
  10319. var width = this._renderWidth;
  10320. var height = this._renderHeight;
  10321. var radius = 0;
  10322. if (this.isThumbClamped && this.isThumbCircle) {
  10323. if (this.isVertical) {
  10324. top += (this._effectiveThumbThickness / 2);
  10325. }
  10326. else {
  10327. left += (this._effectiveThumbThickness / 2);
  10328. }
  10329. radius = this._backgroundBoxThickness / 2;
  10330. }
  10331. else {
  10332. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  10333. }
  10334. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10335. context.shadowColor = this.shadowColor;
  10336. context.shadowBlur = this.shadowBlur;
  10337. context.shadowOffsetX = this.shadowOffsetX;
  10338. context.shadowOffsetY = this.shadowOffsetY;
  10339. }
  10340. var thumbPosition = this._getThumbPosition();
  10341. context.fillStyle = this._background;
  10342. if (this.isVertical) {
  10343. if (this.isThumbClamped) {
  10344. if (this.isThumbCircle) {
  10345. context.beginPath();
  10346. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  10347. context.fill();
  10348. context.fillRect(left, top, width, height);
  10349. }
  10350. else {
  10351. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  10352. }
  10353. }
  10354. else {
  10355. context.fillRect(left, top, width, height);
  10356. }
  10357. }
  10358. else {
  10359. if (this.isThumbClamped) {
  10360. if (this.isThumbCircle) {
  10361. context.beginPath();
  10362. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10363. context.fill();
  10364. context.fillRect(left, top, width, height);
  10365. }
  10366. else {
  10367. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  10368. }
  10369. }
  10370. else {
  10371. context.fillRect(left, top, width, height);
  10372. }
  10373. }
  10374. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10375. context.shadowBlur = 0;
  10376. context.shadowOffsetX = 0;
  10377. context.shadowOffsetY = 0;
  10378. }
  10379. // Value bar
  10380. context.fillStyle = this.color;
  10381. if (this._displayValueBar) {
  10382. if (this.isVertical) {
  10383. if (this.isThumbClamped) {
  10384. if (this.isThumbCircle) {
  10385. context.beginPath();
  10386. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  10387. context.fill();
  10388. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10389. }
  10390. else {
  10391. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10392. }
  10393. }
  10394. else {
  10395. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10396. }
  10397. }
  10398. else {
  10399. if (this.isThumbClamped) {
  10400. if (this.isThumbCircle) {
  10401. context.beginPath();
  10402. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  10403. context.fill();
  10404. context.fillRect(left, top, thumbPosition, height);
  10405. }
  10406. else {
  10407. context.fillRect(left, top, thumbPosition, height);
  10408. }
  10409. }
  10410. else {
  10411. context.fillRect(left, top, thumbPosition, height);
  10412. }
  10413. }
  10414. }
  10415. // Thumb
  10416. if (this.displayThumb) {
  10417. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10418. context.shadowColor = this.shadowColor;
  10419. context.shadowBlur = this.shadowBlur;
  10420. context.shadowOffsetX = this.shadowOffsetX;
  10421. context.shadowOffsetY = this.shadowOffsetY;
  10422. }
  10423. if (this._isThumbCircle) {
  10424. context.beginPath();
  10425. if (this.isVertical) {
  10426. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  10427. }
  10428. else {
  10429. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10430. }
  10431. context.fill();
  10432. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10433. context.shadowBlur = 0;
  10434. context.shadowOffsetX = 0;
  10435. context.shadowOffsetY = 0;
  10436. }
  10437. context.strokeStyle = this._borderColor;
  10438. context.stroke();
  10439. }
  10440. else {
  10441. if (this.isVertical) {
  10442. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10443. }
  10444. else {
  10445. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10446. }
  10447. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10448. context.shadowBlur = 0;
  10449. context.shadowOffsetX = 0;
  10450. context.shadowOffsetY = 0;
  10451. }
  10452. context.strokeStyle = this._borderColor;
  10453. if (this.isVertical) {
  10454. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10455. }
  10456. else {
  10457. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10458. }
  10459. }
  10460. }
  10461. context.restore();
  10462. };
  10463. return Slider;
  10464. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10465. /***/ }),
  10466. /***/ "./2D/controls/stackPanel.ts":
  10467. /*!***********************************!*\
  10468. !*** ./2D/controls/stackPanel.ts ***!
  10469. \***********************************/
  10470. /*! exports provided: StackPanel */
  10471. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10472. "use strict";
  10473. __webpack_require__.r(__webpack_exports__);
  10474. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  10475. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10476. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  10477. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  10478. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  10479. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10480. /**
  10481. * Class used to create a 2D stack panel container
  10482. */
  10483. var StackPanel = /** @class */ (function (_super) {
  10484. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StackPanel, _super);
  10485. /**
  10486. * Creates a new StackPanel
  10487. * @param name defines control name
  10488. */
  10489. function StackPanel(name) {
  10490. var _this = _super.call(this, name) || this;
  10491. _this.name = name;
  10492. _this._isVertical = true;
  10493. _this._manualWidth = false;
  10494. _this._manualHeight = false;
  10495. _this._doNotTrackManualChanges = false;
  10496. return _this;
  10497. }
  10498. Object.defineProperty(StackPanel.prototype, "isVertical", {
  10499. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  10500. get: function () {
  10501. return this._isVertical;
  10502. },
  10503. set: function (value) {
  10504. if (this._isVertical === value) {
  10505. return;
  10506. }
  10507. this._isVertical = value;
  10508. this._markAsDirty();
  10509. },
  10510. enumerable: true,
  10511. configurable: true
  10512. });
  10513. Object.defineProperty(StackPanel.prototype, "width", {
  10514. get: function () {
  10515. return this._width.toString(this._host);
  10516. },
  10517. /**
  10518. * Gets or sets panel width.
  10519. * This value should not be set when in horizontal mode as it will be computed automatically
  10520. */
  10521. set: function (value) {
  10522. if (!this._doNotTrackManualChanges) {
  10523. this._manualWidth = true;
  10524. }
  10525. if (this._width.toString(this._host) === value) {
  10526. return;
  10527. }
  10528. if (this._width.fromString(value)) {
  10529. this._markAsDirty();
  10530. }
  10531. },
  10532. enumerable: true,
  10533. configurable: true
  10534. });
  10535. Object.defineProperty(StackPanel.prototype, "height", {
  10536. get: function () {
  10537. return this._height.toString(this._host);
  10538. },
  10539. /**
  10540. * Gets or sets panel height.
  10541. * This value should not be set when in vertical mode as it will be computed automatically
  10542. */
  10543. set: function (value) {
  10544. if (!this._doNotTrackManualChanges) {
  10545. this._manualHeight = true;
  10546. }
  10547. if (this._height.toString(this._host) === value) {
  10548. return;
  10549. }
  10550. if (this._height.fromString(value)) {
  10551. this._markAsDirty();
  10552. }
  10553. },
  10554. enumerable: true,
  10555. configurable: true
  10556. });
  10557. StackPanel.prototype._getTypeName = function () {
  10558. return "StackPanel";
  10559. };
  10560. /** @hidden */
  10561. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  10562. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10563. var child = _a[_i];
  10564. if (this._isVertical) {
  10565. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10566. }
  10567. else {
  10568. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10569. }
  10570. }
  10571. _super.prototype._preMeasure.call(this, parentMeasure, context);
  10572. };
  10573. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  10574. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  10575. this._measureForChildren.copyFrom(parentMeasure);
  10576. this._measureForChildren.left = this._currentMeasure.left;
  10577. this._measureForChildren.top = this._currentMeasure.top;
  10578. if (!this.isVertical || this._manualWidth) {
  10579. this._measureForChildren.width = this._currentMeasure.width;
  10580. }
  10581. if (this.isVertical || this._manualHeight) {
  10582. this._measureForChildren.height = this._currentMeasure.height;
  10583. }
  10584. };
  10585. StackPanel.prototype._postMeasure = function () {
  10586. var stackWidth = 0;
  10587. var stackHeight = 0;
  10588. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10589. var child = _a[_i];
  10590. if (!child.isVisible || child.notRenderable) {
  10591. continue;
  10592. }
  10593. if (this._isVertical) {
  10594. if (child.top !== stackHeight + "px") {
  10595. child.top = stackHeight + "px";
  10596. this._rebuildLayout = true;
  10597. child._top.ignoreAdaptiveScaling = true;
  10598. }
  10599. if (child._height.isPercentage) {
  10600. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Warn("Control (Name:" + child.name + ", UniqueId:" + child.uniqueId + ") is using height in percentage mode inside a vertical StackPanel");
  10601. }
  10602. else {
  10603. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  10604. }
  10605. }
  10606. else {
  10607. if (child.left !== stackWidth + "px") {
  10608. child.left = stackWidth + "px";
  10609. this._rebuildLayout = true;
  10610. child._left.ignoreAdaptiveScaling = true;
  10611. }
  10612. if (child._width.isPercentage) {
  10613. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Warn("Control (Name:" + child.name + ", UniqueId:" + child.uniqueId + ") is using width in percentage mode inside a horizontal StackPanel");
  10614. }
  10615. else {
  10616. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  10617. }
  10618. }
  10619. }
  10620. this._doNotTrackManualChanges = true;
  10621. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  10622. // User can now define their own height and width for stack panel.
  10623. var panelWidthChanged = false;
  10624. var panelHeightChanged = false;
  10625. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  10626. var previousHeight = this.height;
  10627. this.height = stackHeight + "px";
  10628. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  10629. }
  10630. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  10631. var previousWidth = this.width;
  10632. this.width = stackWidth + "px";
  10633. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  10634. }
  10635. if (panelHeightChanged) {
  10636. this._height.ignoreAdaptiveScaling = true;
  10637. }
  10638. if (panelWidthChanged) {
  10639. this._width.ignoreAdaptiveScaling = true;
  10640. }
  10641. this._doNotTrackManualChanges = false;
  10642. if (panelWidthChanged || panelHeightChanged) {
  10643. this._rebuildLayout = true;
  10644. }
  10645. _super.prototype._postMeasure.call(this);
  10646. };
  10647. return StackPanel;
  10648. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  10649. /***/ }),
  10650. /***/ "./2D/controls/statics.ts":
  10651. /*!********************************!*\
  10652. !*** ./2D/controls/statics.ts ***!
  10653. \********************************/
  10654. /*! exports provided: name */
  10655. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10656. "use strict";
  10657. __webpack_require__.r(__webpack_exports__);
  10658. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  10659. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10660. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  10661. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  10662. /**
  10663. * Forcing an export so that this code will execute
  10664. * @hidden
  10665. */
  10666. var name = "Statics";
  10667. /**
  10668. * Creates a stack panel that can be used to render headers
  10669. * @param control defines the control to associate with the header
  10670. * @param text defines the text of the header
  10671. * @param size defines the size of the header
  10672. * @param options defines options used to configure the header
  10673. * @returns a new StackPanel
  10674. */
  10675. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  10676. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  10677. var isHorizontal = options ? options.isHorizontal : true;
  10678. var controlFirst = options ? options.controlFirst : true;
  10679. panel.isVertical = !isHorizontal;
  10680. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  10681. header.text = text;
  10682. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10683. if (isHorizontal) {
  10684. header.width = size;
  10685. }
  10686. else {
  10687. header.height = size;
  10688. }
  10689. if (controlFirst) {
  10690. panel.addControl(control);
  10691. panel.addControl(header);
  10692. header.paddingLeft = "5px";
  10693. }
  10694. else {
  10695. panel.addControl(header);
  10696. panel.addControl(control);
  10697. header.paddingRight = "5px";
  10698. }
  10699. header.shadowBlur = control.shadowBlur;
  10700. header.shadowColor = control.shadowColor;
  10701. header.shadowOffsetX = control.shadowOffsetX;
  10702. header.shadowOffsetY = control.shadowOffsetY;
  10703. return panel;
  10704. };
  10705. /***/ }),
  10706. /***/ "./2D/controls/textBlock.ts":
  10707. /*!**********************************!*\
  10708. !*** ./2D/controls/textBlock.ts ***!
  10709. \**********************************/
  10710. /*! exports provided: TextWrapping, TextBlock */
  10711. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10712. "use strict";
  10713. __webpack_require__.r(__webpack_exports__);
  10714. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  10715. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  10716. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10717. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  10718. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  10719. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  10720. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10721. /**
  10722. * Enum that determines the text-wrapping mode to use.
  10723. */
  10724. var TextWrapping;
  10725. (function (TextWrapping) {
  10726. /**
  10727. * Clip the text when it's larger than Control.width; this is the default mode.
  10728. */
  10729. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  10730. /**
  10731. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  10732. */
  10733. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  10734. /**
  10735. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  10736. */
  10737. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  10738. })(TextWrapping || (TextWrapping = {}));
  10739. /**
  10740. * Class used to create text block control
  10741. */
  10742. var TextBlock = /** @class */ (function (_super) {
  10743. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextBlock, _super);
  10744. /**
  10745. * Creates a new TextBlock object
  10746. * @param name defines the name of the control
  10747. * @param text defines the text to display (emptry string by default)
  10748. */
  10749. function TextBlock(
  10750. /**
  10751. * Defines the name of the control
  10752. */
  10753. name, text) {
  10754. if (text === void 0) { text = ""; }
  10755. var _this = _super.call(this, name) || this;
  10756. _this.name = name;
  10757. _this._text = "";
  10758. _this._textWrapping = TextWrapping.Clip;
  10759. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  10760. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  10761. _this._resizeToFit = false;
  10762. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  10763. _this._outlineWidth = 0;
  10764. _this._outlineColor = "white";
  10765. /**
  10766. * An event triggered after the text is changed
  10767. */
  10768. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10769. /**
  10770. * An event triggered after the text was broken up into lines
  10771. */
  10772. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10773. _this.text = text;
  10774. return _this;
  10775. }
  10776. Object.defineProperty(TextBlock.prototype, "lines", {
  10777. /**
  10778. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  10779. */
  10780. get: function () {
  10781. return this._lines;
  10782. },
  10783. enumerable: true,
  10784. configurable: true
  10785. });
  10786. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  10787. /**
  10788. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  10789. */
  10790. get: function () {
  10791. return this._resizeToFit;
  10792. },
  10793. /**
  10794. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  10795. */
  10796. set: function (value) {
  10797. if (this._resizeToFit === value) {
  10798. return;
  10799. }
  10800. this._resizeToFit = value;
  10801. if (this._resizeToFit) {
  10802. this._width.ignoreAdaptiveScaling = true;
  10803. this._height.ignoreAdaptiveScaling = true;
  10804. }
  10805. this._markAsDirty();
  10806. },
  10807. enumerable: true,
  10808. configurable: true
  10809. });
  10810. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  10811. /**
  10812. * Gets or sets a boolean indicating if text must be wrapped
  10813. */
  10814. get: function () {
  10815. return this._textWrapping;
  10816. },
  10817. /**
  10818. * Gets or sets a boolean indicating if text must be wrapped
  10819. */
  10820. set: function (value) {
  10821. if (this._textWrapping === value) {
  10822. return;
  10823. }
  10824. this._textWrapping = +value;
  10825. this._markAsDirty();
  10826. },
  10827. enumerable: true,
  10828. configurable: true
  10829. });
  10830. Object.defineProperty(TextBlock.prototype, "text", {
  10831. /**
  10832. * Gets or sets text to display
  10833. */
  10834. get: function () {
  10835. return this._text;
  10836. },
  10837. /**
  10838. * Gets or sets text to display
  10839. */
  10840. set: function (value) {
  10841. if (this._text === value) {
  10842. return;
  10843. }
  10844. this._text = value;
  10845. this._markAsDirty();
  10846. this.onTextChangedObservable.notifyObservers(this);
  10847. },
  10848. enumerable: true,
  10849. configurable: true
  10850. });
  10851. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  10852. /**
  10853. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  10854. */
  10855. get: function () {
  10856. return this._textHorizontalAlignment;
  10857. },
  10858. /**
  10859. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  10860. */
  10861. set: function (value) {
  10862. if (this._textHorizontalAlignment === value) {
  10863. return;
  10864. }
  10865. this._textHorizontalAlignment = value;
  10866. this._markAsDirty();
  10867. },
  10868. enumerable: true,
  10869. configurable: true
  10870. });
  10871. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  10872. /**
  10873. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  10874. */
  10875. get: function () {
  10876. return this._textVerticalAlignment;
  10877. },
  10878. /**
  10879. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  10880. */
  10881. set: function (value) {
  10882. if (this._textVerticalAlignment === value) {
  10883. return;
  10884. }
  10885. this._textVerticalAlignment = value;
  10886. this._markAsDirty();
  10887. },
  10888. enumerable: true,
  10889. configurable: true
  10890. });
  10891. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  10892. /**
  10893. * Gets or sets line spacing value
  10894. */
  10895. get: function () {
  10896. return this._lineSpacing.toString(this._host);
  10897. },
  10898. /**
  10899. * Gets or sets line spacing value
  10900. */
  10901. set: function (value) {
  10902. if (this._lineSpacing.fromString(value)) {
  10903. this._markAsDirty();
  10904. }
  10905. },
  10906. enumerable: true,
  10907. configurable: true
  10908. });
  10909. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  10910. /**
  10911. * Gets or sets outlineWidth of the text to display
  10912. */
  10913. get: function () {
  10914. return this._outlineWidth;
  10915. },
  10916. /**
  10917. * Gets or sets outlineWidth of the text to display
  10918. */
  10919. set: function (value) {
  10920. if (this._outlineWidth === value) {
  10921. return;
  10922. }
  10923. this._outlineWidth = value;
  10924. this._markAsDirty();
  10925. },
  10926. enumerable: true,
  10927. configurable: true
  10928. });
  10929. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  10930. /**
  10931. * Gets or sets outlineColor of the text to display
  10932. */
  10933. get: function () {
  10934. return this._outlineColor;
  10935. },
  10936. /**
  10937. * Gets or sets outlineColor of the text to display
  10938. */
  10939. set: function (value) {
  10940. if (this._outlineColor === value) {
  10941. return;
  10942. }
  10943. this._outlineColor = value;
  10944. this._markAsDirty();
  10945. },
  10946. enumerable: true,
  10947. configurable: true
  10948. });
  10949. TextBlock.prototype._getTypeName = function () {
  10950. return "TextBlock";
  10951. };
  10952. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  10953. if (!this._fontOffset) {
  10954. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  10955. }
  10956. _super.prototype._processMeasures.call(this, parentMeasure, context);
  10957. // Prepare lines
  10958. this._lines = this._breakLines(this._currentMeasure.width, context);
  10959. this.onLinesReadyObservable.notifyObservers(this);
  10960. var maxLineWidth = 0;
  10961. for (var i = 0; i < this._lines.length; i++) {
  10962. var line = this._lines[i];
  10963. if (line.width > maxLineWidth) {
  10964. maxLineWidth = line.width;
  10965. }
  10966. }
  10967. if (this._resizeToFit) {
  10968. if (this._textWrapping === TextWrapping.Clip) {
  10969. var newWidth = this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth;
  10970. if (newWidth !== this._width.internalValue) {
  10971. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  10972. this._rebuildLayout = true;
  10973. }
  10974. }
  10975. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length;
  10976. if (newHeight !== this._height.internalValue) {
  10977. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  10978. this._rebuildLayout = true;
  10979. }
  10980. }
  10981. };
  10982. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  10983. var width = this._currentMeasure.width;
  10984. var x = 0;
  10985. switch (this._textHorizontalAlignment) {
  10986. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  10987. x = 0;
  10988. break;
  10989. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  10990. x = width - textWidth;
  10991. break;
  10992. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  10993. x = (width - textWidth) / 2;
  10994. break;
  10995. }
  10996. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10997. context.shadowColor = this.shadowColor;
  10998. context.shadowBlur = this.shadowBlur;
  10999. context.shadowOffsetX = this.shadowOffsetX;
  11000. context.shadowOffsetY = this.shadowOffsetY;
  11001. }
  11002. if (this.outlineWidth) {
  11003. context.strokeText(text, this._currentMeasure.left + x, y);
  11004. }
  11005. context.fillText(text, this._currentMeasure.left + x, y);
  11006. };
  11007. /** @hidden */
  11008. TextBlock.prototype._draw = function (context) {
  11009. context.save();
  11010. this._applyStates(context);
  11011. // Render lines
  11012. this._renderLines(context);
  11013. context.restore();
  11014. };
  11015. TextBlock.prototype._applyStates = function (context) {
  11016. _super.prototype._applyStates.call(this, context);
  11017. if (this.outlineWidth) {
  11018. context.lineWidth = this.outlineWidth;
  11019. context.strokeStyle = this.outlineColor;
  11020. }
  11021. };
  11022. TextBlock.prototype._breakLines = function (refWidth, context) {
  11023. var lines = [];
  11024. var _lines = this.text.split("\n");
  11025. if (this._textWrapping === TextWrapping.Ellipsis) {
  11026. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  11027. var _line = _lines_1[_i];
  11028. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  11029. }
  11030. }
  11031. else if (this._textWrapping === TextWrapping.WordWrap) {
  11032. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  11033. var _line = _lines_2[_a];
  11034. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  11035. }
  11036. }
  11037. else {
  11038. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  11039. var _line = _lines_3[_b];
  11040. lines.push(this._parseLine(_line, context));
  11041. }
  11042. }
  11043. return lines;
  11044. };
  11045. TextBlock.prototype._parseLine = function (line, context) {
  11046. if (line === void 0) { line = ''; }
  11047. return { text: line, width: context.measureText(line).width };
  11048. };
  11049. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  11050. if (line === void 0) { line = ''; }
  11051. var lineWidth = context.measureText(line).width;
  11052. if (lineWidth > width) {
  11053. line += '…';
  11054. }
  11055. while (line.length > 2 && lineWidth > width) {
  11056. line = line.slice(0, -2) + '…';
  11057. lineWidth = context.measureText(line).width;
  11058. }
  11059. return { text: line, width: lineWidth };
  11060. };
  11061. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  11062. if (line === void 0) { line = ''; }
  11063. var lines = [];
  11064. var words = line.split(' ');
  11065. var lineWidth = 0;
  11066. for (var n = 0; n < words.length; n++) {
  11067. var testLine = n > 0 ? line + " " + words[n] : words[0];
  11068. var metrics = context.measureText(testLine);
  11069. var testWidth = metrics.width;
  11070. if (testWidth > width && n > 0) {
  11071. lines.push({ text: line, width: lineWidth });
  11072. line = words[n];
  11073. lineWidth = context.measureText(line).width;
  11074. }
  11075. else {
  11076. lineWidth = testWidth;
  11077. line = testLine;
  11078. }
  11079. }
  11080. lines.push({ text: line, width: lineWidth });
  11081. return lines;
  11082. };
  11083. TextBlock.prototype._renderLines = function (context) {
  11084. var height = this._currentMeasure.height;
  11085. var rootY = 0;
  11086. switch (this._textVerticalAlignment) {
  11087. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  11088. rootY = this._fontOffset.ascent;
  11089. break;
  11090. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  11091. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  11092. break;
  11093. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  11094. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  11095. break;
  11096. }
  11097. rootY += this._currentMeasure.top;
  11098. for (var i = 0; i < this._lines.length; i++) {
  11099. var line = this._lines[i];
  11100. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  11101. if (this._lineSpacing.isPixel) {
  11102. rootY += this._lineSpacing.getValue(this._host);
  11103. }
  11104. else {
  11105. rootY = rootY + (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11106. }
  11107. }
  11108. this._drawText(line.text, line.width, rootY, context);
  11109. rootY += this._fontOffset.height;
  11110. }
  11111. };
  11112. /**
  11113. * Given a width constraint applied on the text block, find the expected height
  11114. * @returns expected height
  11115. */
  11116. TextBlock.prototype.computeExpectedHeight = function () {
  11117. if (this.text && this.widthInPixels) {
  11118. var context_1 = document.createElement('canvas').getContext('2d');
  11119. if (context_1) {
  11120. this._applyStates(context_1);
  11121. if (!this._fontOffset) {
  11122. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  11123. }
  11124. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  11125. return this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  11126. }
  11127. }
  11128. return 0;
  11129. };
  11130. TextBlock.prototype.dispose = function () {
  11131. _super.prototype.dispose.call(this);
  11132. this.onTextChangedObservable.clear();
  11133. };
  11134. return TextBlock;
  11135. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  11136. /***/ }),
  11137. /***/ "./2D/controls/virtualKeyboard.ts":
  11138. /*!****************************************!*\
  11139. !*** ./2D/controls/virtualKeyboard.ts ***!
  11140. \****************************************/
  11141. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  11142. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11143. "use strict";
  11144. __webpack_require__.r(__webpack_exports__);
  11145. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  11146. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  11147. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11148. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  11149. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  11150. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  11151. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  11152. /**
  11153. * Class used to store key control properties
  11154. */
  11155. var KeyPropertySet = /** @class */ (function () {
  11156. function KeyPropertySet() {
  11157. }
  11158. return KeyPropertySet;
  11159. }());
  11160. /**
  11161. * Class used to create virtual keyboard
  11162. */
  11163. var VirtualKeyboard = /** @class */ (function (_super) {
  11164. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VirtualKeyboard, _super);
  11165. function VirtualKeyboard() {
  11166. var _this = _super !== null && _super.apply(this, arguments) || this;
  11167. /** Observable raised when a key is pressed */
  11168. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11169. /** Gets or sets default key button width */
  11170. _this.defaultButtonWidth = "40px";
  11171. /** Gets or sets default key button height */
  11172. _this.defaultButtonHeight = "40px";
  11173. /** Gets or sets default key button left padding */
  11174. _this.defaultButtonPaddingLeft = "2px";
  11175. /** Gets or sets default key button right padding */
  11176. _this.defaultButtonPaddingRight = "2px";
  11177. /** Gets or sets default key button top padding */
  11178. _this.defaultButtonPaddingTop = "2px";
  11179. /** Gets or sets default key button bottom padding */
  11180. _this.defaultButtonPaddingBottom = "2px";
  11181. /** Gets or sets default key button foreground color */
  11182. _this.defaultButtonColor = "#DDD";
  11183. /** Gets or sets default key button background color */
  11184. _this.defaultButtonBackground = "#070707";
  11185. /** Gets or sets shift button foreground color */
  11186. _this.shiftButtonColor = "#7799FF";
  11187. /** Gets or sets shift button thickness*/
  11188. _this.selectedShiftThickness = 1;
  11189. /** Gets shift key state */
  11190. _this.shiftState = 0;
  11191. _this._currentlyConnectedInputText = null;
  11192. _this._connectedInputTexts = [];
  11193. _this._onKeyPressObserver = null;
  11194. return _this;
  11195. }
  11196. VirtualKeyboard.prototype._getTypeName = function () {
  11197. return "VirtualKeyboard";
  11198. };
  11199. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  11200. var _this = this;
  11201. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  11202. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  11203. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  11204. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  11205. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  11206. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  11207. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  11208. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  11209. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  11210. button.thickness = 0;
  11211. button.isFocusInvisible = true;
  11212. button.shadowColor = this.shadowColor;
  11213. button.shadowBlur = this.shadowBlur;
  11214. button.shadowOffsetX = this.shadowOffsetX;
  11215. button.shadowOffsetY = this.shadowOffsetY;
  11216. button.onPointerUpObservable.add(function () {
  11217. _this.onKeyPressObservable.notifyObservers(key);
  11218. });
  11219. return button;
  11220. };
  11221. /**
  11222. * Adds a new row of keys
  11223. * @param keys defines the list of keys to add
  11224. * @param propertySets defines the associated property sets
  11225. */
  11226. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  11227. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  11228. panel.isVertical = false;
  11229. panel.isFocusInvisible = true;
  11230. for (var i = 0; i < keys.length; i++) {
  11231. var properties = null;
  11232. if (propertySets && propertySets.length === keys.length) {
  11233. properties = propertySets[i];
  11234. }
  11235. panel.addControl(this._createKey(keys[i], properties));
  11236. }
  11237. this.addControl(panel);
  11238. };
  11239. /**
  11240. * Set the shift key to a specific state
  11241. * @param shiftState defines the new shift state
  11242. */
  11243. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  11244. if (!this.children) {
  11245. return;
  11246. }
  11247. for (var i = 0; i < this.children.length; i++) {
  11248. var row = this.children[i];
  11249. if (!row || !row.children) {
  11250. continue;
  11251. }
  11252. var rowContainer = row;
  11253. for (var j = 0; j < rowContainer.children.length; j++) {
  11254. var button = rowContainer.children[j];
  11255. if (!button || !button.children[0]) {
  11256. continue;
  11257. }
  11258. var button_tblock = button.children[0];
  11259. if (button_tblock.text === "\u21E7") {
  11260. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  11261. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  11262. }
  11263. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  11264. }
  11265. }
  11266. };
  11267. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  11268. /** Gets the input text control currently attached to the keyboard */
  11269. get: function () {
  11270. return this._currentlyConnectedInputText;
  11271. },
  11272. enumerable: true,
  11273. configurable: true
  11274. });
  11275. /**
  11276. * Connects the keyboard with an input text control
  11277. *
  11278. * @param input defines the target control
  11279. */
  11280. VirtualKeyboard.prototype.connect = function (input) {
  11281. var _this = this;
  11282. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  11283. if (inputTextAlreadyConnected) {
  11284. return;
  11285. }
  11286. if (this._onKeyPressObserver === null) {
  11287. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  11288. if (!_this._currentlyConnectedInputText) {
  11289. return;
  11290. }
  11291. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  11292. switch (key) {
  11293. case "\u21E7":
  11294. _this.shiftState++;
  11295. if (_this.shiftState > 2) {
  11296. _this.shiftState = 0;
  11297. }
  11298. _this.applyShiftState(_this.shiftState);
  11299. return;
  11300. case "\u2190":
  11301. _this._currentlyConnectedInputText.processKey(8);
  11302. return;
  11303. case "\u21B5":
  11304. _this._currentlyConnectedInputText.processKey(13);
  11305. return;
  11306. }
  11307. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  11308. if (_this.shiftState === 1) {
  11309. _this.shiftState = 0;
  11310. _this.applyShiftState(_this.shiftState);
  11311. }
  11312. });
  11313. }
  11314. this.isVisible = false;
  11315. this._currentlyConnectedInputText = input;
  11316. input._connectedVirtualKeyboard = this;
  11317. // Events hooking
  11318. var onFocusObserver = input.onFocusObservable.add(function () {
  11319. _this._currentlyConnectedInputText = input;
  11320. input._connectedVirtualKeyboard = _this;
  11321. _this.isVisible = true;
  11322. });
  11323. var onBlurObserver = input.onBlurObservable.add(function () {
  11324. input._connectedVirtualKeyboard = null;
  11325. _this._currentlyConnectedInputText = null;
  11326. _this.isVisible = false;
  11327. });
  11328. this._connectedInputTexts.push({
  11329. input: input,
  11330. onBlurObserver: onBlurObserver,
  11331. onFocusObserver: onFocusObserver
  11332. });
  11333. };
  11334. /**
  11335. * Disconnects the keyboard from connected InputText controls
  11336. *
  11337. * @param input optionally defines a target control, otherwise all are disconnected
  11338. */
  11339. VirtualKeyboard.prototype.disconnect = function (input) {
  11340. var _this = this;
  11341. if (input) {
  11342. // .find not available on IE
  11343. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  11344. if (filtered.length === 1) {
  11345. this._removeConnectedInputObservables(filtered[0]);
  11346. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  11347. if (this._currentlyConnectedInputText === input) {
  11348. this._currentlyConnectedInputText = null;
  11349. }
  11350. }
  11351. }
  11352. else {
  11353. this._connectedInputTexts.forEach(function (connectedInputText) {
  11354. _this._removeConnectedInputObservables(connectedInputText);
  11355. });
  11356. this._connectedInputTexts = [];
  11357. }
  11358. if (this._connectedInputTexts.length === 0) {
  11359. this._currentlyConnectedInputText = null;
  11360. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  11361. this._onKeyPressObserver = null;
  11362. }
  11363. };
  11364. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  11365. connectedInputText.input._connectedVirtualKeyboard = null;
  11366. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  11367. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  11368. };
  11369. /**
  11370. * Release all resources
  11371. */
  11372. VirtualKeyboard.prototype.dispose = function () {
  11373. _super.prototype.dispose.call(this);
  11374. this.disconnect();
  11375. };
  11376. // Statics
  11377. /**
  11378. * Creates a new keyboard using a default layout
  11379. *
  11380. * @param name defines control name
  11381. * @returns a new VirtualKeyboard
  11382. */
  11383. VirtualKeyboard.CreateDefaultLayout = function (name) {
  11384. var returnValue = new VirtualKeyboard(name);
  11385. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  11386. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  11387. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  11388. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  11389. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  11390. return returnValue;
  11391. };
  11392. return VirtualKeyboard;
  11393. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  11394. /***/ }),
  11395. /***/ "./2D/index.ts":
  11396. /*!*********************!*\
  11397. !*** ./2D/index.ts ***!
  11398. \*********************/
  11399. /*! exports provided: AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, name */
  11400. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11401. "use strict";
  11402. __webpack_require__.r(__webpack_exports__);
  11403. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  11404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  11405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  11406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  11407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  11408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  11409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  11410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  11411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  11412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  11413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  11414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  11415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  11416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  11417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  11418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  11419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  11420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  11421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  11422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  11423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  11424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  11425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  11426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  11427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  11428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  11429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  11430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  11431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  11432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  11433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  11434. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  11435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  11436. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  11437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  11438. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  11439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  11440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  11441. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  11442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  11443. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  11444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  11445. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  11446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  11447. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  11449. /***/ }),
  11450. /***/ "./2D/math2D.ts":
  11451. /*!**********************!*\
  11452. !*** ./2D/math2D.ts ***!
  11453. \**********************/
  11454. /*! exports provided: Vector2WithInfo, Matrix2D */
  11455. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11456. "use strict";
  11457. __webpack_require__.r(__webpack_exports__);
  11458. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  11459. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  11460. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11461. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  11462. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  11463. /**
  11464. * Class used to transport Vector2 information for pointer events
  11465. */
  11466. var Vector2WithInfo = /** @class */ (function (_super) {
  11467. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Vector2WithInfo, _super);
  11468. /**
  11469. * Creates a new Vector2WithInfo
  11470. * @param source defines the vector2 data to transport
  11471. * @param buttonIndex defines the current mouse button index
  11472. */
  11473. function Vector2WithInfo(source,
  11474. /** defines the current mouse button index */
  11475. buttonIndex) {
  11476. if (buttonIndex === void 0) { buttonIndex = 0; }
  11477. var _this = _super.call(this, source.x, source.y) || this;
  11478. _this.buttonIndex = buttonIndex;
  11479. return _this;
  11480. }
  11481. return Vector2WithInfo;
  11482. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  11483. /** Class used to provide 2D matrix features */
  11484. var Matrix2D = /** @class */ (function () {
  11485. /**
  11486. * Creates a new matrix
  11487. * @param m00 defines value for (0, 0)
  11488. * @param m01 defines value for (0, 1)
  11489. * @param m10 defines value for (1, 0)
  11490. * @param m11 defines value for (1, 1)
  11491. * @param m20 defines value for (2, 0)
  11492. * @param m21 defines value for (2, 1)
  11493. */
  11494. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  11495. /** Gets the internal array of 6 floats used to store matrix data */
  11496. this.m = new Float32Array(6);
  11497. this.fromValues(m00, m01, m10, m11, m20, m21);
  11498. }
  11499. /**
  11500. * Fills the matrix from direct values
  11501. * @param m00 defines value for (0, 0)
  11502. * @param m01 defines value for (0, 1)
  11503. * @param m10 defines value for (1, 0)
  11504. * @param m11 defines value for (1, 1)
  11505. * @param m20 defines value for (2, 0)
  11506. * @param m21 defines value for (2, 1)
  11507. * @returns the current modified matrix
  11508. */
  11509. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  11510. this.m[0] = m00;
  11511. this.m[1] = m01;
  11512. this.m[2] = m10;
  11513. this.m[3] = m11;
  11514. this.m[4] = m20;
  11515. this.m[5] = m21;
  11516. return this;
  11517. };
  11518. /**
  11519. * Gets matrix determinant
  11520. * @returns the determinant
  11521. */
  11522. Matrix2D.prototype.determinant = function () {
  11523. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  11524. };
  11525. /**
  11526. * Inverses the matrix and stores it in a target matrix
  11527. * @param result defines the target matrix
  11528. * @returns the current matrix
  11529. */
  11530. Matrix2D.prototype.invertToRef = function (result) {
  11531. var l0 = this.m[0];
  11532. var l1 = this.m[1];
  11533. var l2 = this.m[2];
  11534. var l3 = this.m[3];
  11535. var l4 = this.m[4];
  11536. var l5 = this.m[5];
  11537. var det = this.determinant();
  11538. if (det < (babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  11539. result.m[0] = 0;
  11540. result.m[1] = 0;
  11541. result.m[2] = 0;
  11542. result.m[3] = 0;
  11543. result.m[4] = 0;
  11544. result.m[5] = 0;
  11545. return this;
  11546. }
  11547. var detDiv = 1 / det;
  11548. var det4 = l2 * l5 - l3 * l4;
  11549. var det5 = l1 * l4 - l0 * l5;
  11550. result.m[0] = l3 * detDiv;
  11551. result.m[1] = -l1 * detDiv;
  11552. result.m[2] = -l2 * detDiv;
  11553. result.m[3] = l0 * detDiv;
  11554. result.m[4] = det4 * detDiv;
  11555. result.m[5] = det5 * detDiv;
  11556. return this;
  11557. };
  11558. /**
  11559. * Multiplies the current matrix with another one
  11560. * @param other defines the second operand
  11561. * @param result defines the target matrix
  11562. * @returns the current matrix
  11563. */
  11564. Matrix2D.prototype.multiplyToRef = function (other, result) {
  11565. var l0 = this.m[0];
  11566. var l1 = this.m[1];
  11567. var l2 = this.m[2];
  11568. var l3 = this.m[3];
  11569. var l4 = this.m[4];
  11570. var l5 = this.m[5];
  11571. var r0 = other.m[0];
  11572. var r1 = other.m[1];
  11573. var r2 = other.m[2];
  11574. var r3 = other.m[3];
  11575. var r4 = other.m[4];
  11576. var r5 = other.m[5];
  11577. result.m[0] = l0 * r0 + l1 * r2;
  11578. result.m[1] = l0 * r1 + l1 * r3;
  11579. result.m[2] = l2 * r0 + l3 * r2;
  11580. result.m[3] = l2 * r1 + l3 * r3;
  11581. result.m[4] = l4 * r0 + l5 * r2 + r4;
  11582. result.m[5] = l4 * r1 + l5 * r3 + r5;
  11583. return this;
  11584. };
  11585. /**
  11586. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  11587. * @param x defines the x coordinate to transform
  11588. * @param y defines the x coordinate to transform
  11589. * @param result defines the target vector2
  11590. * @returns the current matrix
  11591. */
  11592. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  11593. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  11594. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  11595. return this;
  11596. };
  11597. // Statics
  11598. /**
  11599. * Creates an identity matrix
  11600. * @returns a new matrix
  11601. */
  11602. Matrix2D.Identity = function () {
  11603. return new Matrix2D(1, 0, 0, 1, 0, 0);
  11604. };
  11605. /**
  11606. * Creates a translation matrix and stores it in a target matrix
  11607. * @param x defines the x coordinate of the translation
  11608. * @param y defines the y coordinate of the translation
  11609. * @param result defines the target matrix
  11610. */
  11611. Matrix2D.TranslationToRef = function (x, y, result) {
  11612. result.fromValues(1, 0, 0, 1, x, y);
  11613. };
  11614. /**
  11615. * Creates a scaling matrix and stores it in a target matrix
  11616. * @param x defines the x coordinate of the scaling
  11617. * @param y defines the y coordinate of the scaling
  11618. * @param result defines the target matrix
  11619. */
  11620. Matrix2D.ScalingToRef = function (x, y, result) {
  11621. result.fromValues(x, 0, 0, y, 0, 0);
  11622. };
  11623. /**
  11624. * Creates a rotation matrix and stores it in a target matrix
  11625. * @param angle defines the rotation angle
  11626. * @param result defines the target matrix
  11627. */
  11628. Matrix2D.RotationToRef = function (angle, result) {
  11629. var s = Math.sin(angle);
  11630. var c = Math.cos(angle);
  11631. result.fromValues(c, s, -s, c, 0, 0);
  11632. };
  11633. /**
  11634. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  11635. * @param tx defines the x coordinate of the translation
  11636. * @param ty defines the y coordinate of the translation
  11637. * @param angle defines the rotation angle
  11638. * @param scaleX defines the x coordinate of the scaling
  11639. * @param scaleY defines the y coordinate of the scaling
  11640. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  11641. * @param result defines the target matrix
  11642. */
  11643. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  11644. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  11645. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  11646. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  11647. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  11648. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  11649. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  11650. if (parentMatrix) {
  11651. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  11652. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  11653. }
  11654. else {
  11655. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  11656. }
  11657. };
  11658. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  11659. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  11660. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  11661. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  11662. Matrix2D._TempCompose0 = Matrix2D.Identity();
  11663. Matrix2D._TempCompose1 = Matrix2D.Identity();
  11664. Matrix2D._TempCompose2 = Matrix2D.Identity();
  11665. return Matrix2D;
  11666. }());
  11667. /***/ }),
  11668. /***/ "./2D/measure.ts":
  11669. /*!***********************!*\
  11670. !*** ./2D/measure.ts ***!
  11671. \***********************/
  11672. /*! exports provided: Measure */
  11673. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11674. "use strict";
  11675. __webpack_require__.r(__webpack_exports__);
  11676. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  11677. /* harmony import */ var babylonjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs */ "babylonjs/Misc/observable");
  11678. /* harmony import */ var babylonjs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs__WEBPACK_IMPORTED_MODULE_0__);
  11679. /**
  11680. * Class used to store 2D control sizes
  11681. */
  11682. var Measure = /** @class */ (function () {
  11683. /**
  11684. * Creates a new measure
  11685. * @param left defines left coordinate
  11686. * @param top defines top coordinate
  11687. * @param width defines width dimension
  11688. * @param height defines height dimension
  11689. */
  11690. function Measure(
  11691. /** defines left coordinate */
  11692. left,
  11693. /** defines top coordinate */
  11694. top,
  11695. /** defines width dimension */
  11696. width,
  11697. /** defines height dimension */
  11698. height) {
  11699. this.left = left;
  11700. this.top = top;
  11701. this.width = width;
  11702. this.height = height;
  11703. }
  11704. /**
  11705. * Copy from another measure
  11706. * @param other defines the other measure to copy from
  11707. */
  11708. Measure.prototype.copyFrom = function (other) {
  11709. this.left = other.left;
  11710. this.top = other.top;
  11711. this.width = other.width;
  11712. this.height = other.height;
  11713. };
  11714. /**
  11715. * Copy from a group of 4 floats
  11716. * @param left defines left coordinate
  11717. * @param top defines top coordinate
  11718. * @param width defines width dimension
  11719. * @param height defines height dimension
  11720. */
  11721. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  11722. this.left = left;
  11723. this.top = top;
  11724. this.width = width;
  11725. this.height = height;
  11726. };
  11727. /**
  11728. * Computes the axis aligned bounding box measure for two given measures
  11729. * @param a Input measure
  11730. * @param b Input measure
  11731. * @param result the resulting bounding measure
  11732. */
  11733. Measure.CombineToRef = function (a, b, result) {
  11734. var left = Math.min(a.left, b.left);
  11735. var top = Math.min(a.top, b.top);
  11736. var right = Math.max(a.left + a.width, b.left + b.width);
  11737. var bottom = Math.max(a.top + a.height, b.top + b.height);
  11738. result.left = left;
  11739. result.top = top;
  11740. result.width = right - left;
  11741. result.height = bottom - top;
  11742. };
  11743. /**
  11744. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  11745. * @param transform the matrix to transform the measure before computing the AABB
  11746. * @param result the resulting AABB
  11747. */
  11748. Measure.prototype.transformToRef = function (transform, result) {
  11749. var rectanglePoints = babylonjs__WEBPACK_IMPORTED_MODULE_0__["Polygon"].Rectangle(this.left, this.top, this.left + this.width, this.top + this.height);
  11750. var min = new babylonjs__WEBPACK_IMPORTED_MODULE_0__["Vector2"](Number.MAX_VALUE, Number.MAX_VALUE);
  11751. var max = new babylonjs__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  11752. for (var i = 0; i < 4; i++) {
  11753. transform.transformCoordinates(rectanglePoints[i].x, rectanglePoints[i].y, rectanglePoints[i]);
  11754. min.x = Math.floor(Math.min(min.x, rectanglePoints[i].x));
  11755. min.y = Math.floor(Math.min(min.y, rectanglePoints[i].y));
  11756. max.x = Math.ceil(Math.max(max.x, rectanglePoints[i].x));
  11757. max.y = Math.ceil(Math.max(max.y, rectanglePoints[i].y));
  11758. }
  11759. result.left = min.x;
  11760. result.top = min.y;
  11761. result.width = max.x - min.x;
  11762. result.height = max.y - min.y;
  11763. };
  11764. /**
  11765. * Check equality between this measure and another one
  11766. * @param other defines the other measures
  11767. * @returns true if both measures are equals
  11768. */
  11769. Measure.prototype.isEqualsTo = function (other) {
  11770. if (this.left !== other.left) {
  11771. return false;
  11772. }
  11773. if (this.top !== other.top) {
  11774. return false;
  11775. }
  11776. if (this.width !== other.width) {
  11777. return false;
  11778. }
  11779. if (this.height !== other.height) {
  11780. return false;
  11781. }
  11782. return true;
  11783. };
  11784. /**
  11785. * Creates an empty measure
  11786. * @returns a new measure
  11787. */
  11788. Measure.Empty = function () {
  11789. return new Measure(0, 0, 0, 0);
  11790. };
  11791. return Measure;
  11792. }());
  11793. /***/ }),
  11794. /***/ "./2D/multiLinePoint.ts":
  11795. /*!******************************!*\
  11796. !*** ./2D/multiLinePoint.ts ***!
  11797. \******************************/
  11798. /*! exports provided: MultiLinePoint */
  11799. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11800. "use strict";
  11801. __webpack_require__.r(__webpack_exports__);
  11802. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  11803. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  11804. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  11805. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11806. /**
  11807. * Class used to store a point for a MultiLine object.
  11808. * The point can be pure 2D coordinates, a mesh or a control
  11809. */
  11810. var MultiLinePoint = /** @class */ (function () {
  11811. /**
  11812. * Creates a new MultiLinePoint
  11813. * @param multiLine defines the source MultiLine object
  11814. */
  11815. function MultiLinePoint(multiLine) {
  11816. this._multiLine = multiLine;
  11817. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  11818. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  11819. this._point = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  11820. }
  11821. Object.defineProperty(MultiLinePoint.prototype, "x", {
  11822. /** Gets or sets x coordinate */
  11823. get: function () {
  11824. return this._x.toString(this._multiLine._host);
  11825. },
  11826. set: function (value) {
  11827. if (this._x.toString(this._multiLine._host) === value) {
  11828. return;
  11829. }
  11830. if (this._x.fromString(value)) {
  11831. this._multiLine._markAsDirty();
  11832. }
  11833. },
  11834. enumerable: true,
  11835. configurable: true
  11836. });
  11837. Object.defineProperty(MultiLinePoint.prototype, "y", {
  11838. /** Gets or sets y coordinate */
  11839. get: function () {
  11840. return this._y.toString(this._multiLine._host);
  11841. },
  11842. set: function (value) {
  11843. if (this._y.toString(this._multiLine._host) === value) {
  11844. return;
  11845. }
  11846. if (this._y.fromString(value)) {
  11847. this._multiLine._markAsDirty();
  11848. }
  11849. },
  11850. enumerable: true,
  11851. configurable: true
  11852. });
  11853. Object.defineProperty(MultiLinePoint.prototype, "control", {
  11854. /** Gets or sets the control associated with this point */
  11855. get: function () {
  11856. return this._control;
  11857. },
  11858. set: function (value) {
  11859. if (this._control === value) {
  11860. return;
  11861. }
  11862. if (this._control && this._controlObserver) {
  11863. this._control.onDirtyObservable.remove(this._controlObserver);
  11864. this._controlObserver = null;
  11865. }
  11866. this._control = value;
  11867. if (this._control) {
  11868. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  11869. }
  11870. this._multiLine._markAsDirty();
  11871. },
  11872. enumerable: true,
  11873. configurable: true
  11874. });
  11875. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  11876. /** Gets or sets the mesh associated with this point */
  11877. get: function () {
  11878. return this._mesh;
  11879. },
  11880. set: function (value) {
  11881. if (this._mesh === value) {
  11882. return;
  11883. }
  11884. if (this._mesh && this._meshObserver) {
  11885. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  11886. }
  11887. this._mesh = value;
  11888. if (this._mesh) {
  11889. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  11890. }
  11891. this._multiLine._markAsDirty();
  11892. },
  11893. enumerable: true,
  11894. configurable: true
  11895. });
  11896. /** Resets links */
  11897. MultiLinePoint.prototype.resetLinks = function () {
  11898. this.control = null;
  11899. this.mesh = null;
  11900. };
  11901. /**
  11902. * Gets a translation vector
  11903. * @returns the translation vector
  11904. */
  11905. MultiLinePoint.prototype.translate = function () {
  11906. this._point = this._translatePoint();
  11907. return this._point;
  11908. };
  11909. MultiLinePoint.prototype._translatePoint = function () {
  11910. if (this._mesh != null) {
  11911. return this._multiLine._host.getProjectedPosition(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  11912. }
  11913. else if (this._control != null) {
  11914. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](this._control.centerX, this._control.centerY);
  11915. }
  11916. else {
  11917. var host = this._multiLine._host;
  11918. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  11919. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  11920. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](xValue, yValue);
  11921. }
  11922. };
  11923. /** Release associated resources */
  11924. MultiLinePoint.prototype.dispose = function () {
  11925. this.resetLinks();
  11926. };
  11927. return MultiLinePoint;
  11928. }());
  11929. /***/ }),
  11930. /***/ "./2D/style.ts":
  11931. /*!*********************!*\
  11932. !*** ./2D/style.ts ***!
  11933. \*********************/
  11934. /*! exports provided: Style */
  11935. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11936. "use strict";
  11937. __webpack_require__.r(__webpack_exports__);
  11938. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  11939. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  11940. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  11941. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11942. /**
  11943. * Define a style used by control to automatically setup properties based on a template.
  11944. * Only support font related properties so far
  11945. */
  11946. var Style = /** @class */ (function () {
  11947. /**
  11948. * Creates a new style object
  11949. * @param host defines the AdvancedDynamicTexture which hosts this style
  11950. */
  11951. function Style(host) {
  11952. this._fontFamily = "Arial";
  11953. this._fontStyle = "";
  11954. this._fontWeight = "";
  11955. /** @hidden */
  11956. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  11957. /**
  11958. * Observable raised when the style values are changed
  11959. */
  11960. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  11961. this._host = host;
  11962. }
  11963. Object.defineProperty(Style.prototype, "fontSize", {
  11964. /**
  11965. * Gets or sets the font size
  11966. */
  11967. get: function () {
  11968. return this._fontSize.toString(this._host);
  11969. },
  11970. set: function (value) {
  11971. if (this._fontSize.toString(this._host) === value) {
  11972. return;
  11973. }
  11974. if (this._fontSize.fromString(value)) {
  11975. this.onChangedObservable.notifyObservers(this);
  11976. }
  11977. },
  11978. enumerable: true,
  11979. configurable: true
  11980. });
  11981. Object.defineProperty(Style.prototype, "fontFamily", {
  11982. /**
  11983. * Gets or sets the font family
  11984. */
  11985. get: function () {
  11986. return this._fontFamily;
  11987. },
  11988. set: function (value) {
  11989. if (this._fontFamily === value) {
  11990. return;
  11991. }
  11992. this._fontFamily = value;
  11993. this.onChangedObservable.notifyObservers(this);
  11994. },
  11995. enumerable: true,
  11996. configurable: true
  11997. });
  11998. Object.defineProperty(Style.prototype, "fontStyle", {
  11999. /**
  12000. * Gets or sets the font style
  12001. */
  12002. get: function () {
  12003. return this._fontStyle;
  12004. },
  12005. set: function (value) {
  12006. if (this._fontStyle === value) {
  12007. return;
  12008. }
  12009. this._fontStyle = value;
  12010. this.onChangedObservable.notifyObservers(this);
  12011. },
  12012. enumerable: true,
  12013. configurable: true
  12014. });
  12015. Object.defineProperty(Style.prototype, "fontWeight", {
  12016. /** Gets or sets font weight */
  12017. get: function () {
  12018. return this._fontWeight;
  12019. },
  12020. set: function (value) {
  12021. if (this._fontWeight === value) {
  12022. return;
  12023. }
  12024. this._fontWeight = value;
  12025. this.onChangedObservable.notifyObservers(this);
  12026. },
  12027. enumerable: true,
  12028. configurable: true
  12029. });
  12030. /** Dispose all associated resources */
  12031. Style.prototype.dispose = function () {
  12032. this.onChangedObservable.clear();
  12033. };
  12034. return Style;
  12035. }());
  12036. /***/ }),
  12037. /***/ "./2D/valueAndUnit.ts":
  12038. /*!****************************!*\
  12039. !*** ./2D/valueAndUnit.ts ***!
  12040. \****************************/
  12041. /*! exports provided: ValueAndUnit */
  12042. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12043. "use strict";
  12044. __webpack_require__.r(__webpack_exports__);
  12045. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  12046. /**
  12047. * Class used to specific a value and its associated unit
  12048. */
  12049. var ValueAndUnit = /** @class */ (function () {
  12050. /**
  12051. * Creates a new ValueAndUnit
  12052. * @param value defines the value to store
  12053. * @param unit defines the unit to store
  12054. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  12055. */
  12056. function ValueAndUnit(value,
  12057. /** defines the unit to store */
  12058. unit,
  12059. /** defines a boolean indicating if the value can be negative */
  12060. negativeValueAllowed) {
  12061. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12062. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  12063. this.unit = unit;
  12064. this.negativeValueAllowed = negativeValueAllowed;
  12065. this._value = 1;
  12066. /**
  12067. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  12068. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  12069. */
  12070. this.ignoreAdaptiveScaling = false;
  12071. this._value = value;
  12072. this._originalUnit = unit;
  12073. }
  12074. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  12075. /** Gets a boolean indicating if the value is a percentage */
  12076. get: function () {
  12077. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  12078. },
  12079. enumerable: true,
  12080. configurable: true
  12081. });
  12082. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  12083. /** Gets a boolean indicating if the value is store as pixel */
  12084. get: function () {
  12085. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  12086. },
  12087. enumerable: true,
  12088. configurable: true
  12089. });
  12090. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  12091. /** Gets direct internal value */
  12092. get: function () {
  12093. return this._value;
  12094. },
  12095. enumerable: true,
  12096. configurable: true
  12097. });
  12098. /**
  12099. * Gets value as pixel
  12100. * @param host defines the root host
  12101. * @param refValue defines the reference value for percentages
  12102. * @returns the value as pixel
  12103. */
  12104. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  12105. if (this.isPixel) {
  12106. return this.getValue(host);
  12107. }
  12108. return this.getValue(host) * refValue;
  12109. };
  12110. /**
  12111. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  12112. * @param value defines the value to store
  12113. * @param unit defines the unit to store
  12114. * @returns the current ValueAndUnit
  12115. */
  12116. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  12117. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12118. this._value = value;
  12119. this.unit = unit;
  12120. return this;
  12121. };
  12122. /**
  12123. * Gets the value accordingly to its unit
  12124. * @param host defines the root host
  12125. * @returns the value
  12126. */
  12127. ValueAndUnit.prototype.getValue = function (host) {
  12128. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  12129. var width = 0;
  12130. var height = 0;
  12131. if (host.idealWidth) {
  12132. width = (this._value * host.getSize().width) / host.idealWidth;
  12133. }
  12134. if (host.idealHeight) {
  12135. height = (this._value * host.getSize().height) / host.idealHeight;
  12136. }
  12137. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  12138. return window.innerWidth < window.innerHeight ? width : height;
  12139. }
  12140. if (host.idealWidth) { // horizontal
  12141. return width;
  12142. }
  12143. if (host.idealHeight) { // vertical
  12144. return height;
  12145. }
  12146. }
  12147. return this._value;
  12148. };
  12149. /**
  12150. * Gets a string representation of the value
  12151. * @param host defines the root host
  12152. * @returns a string
  12153. */
  12154. ValueAndUnit.prototype.toString = function (host) {
  12155. switch (this.unit) {
  12156. case ValueAndUnit.UNITMODE_PERCENTAGE:
  12157. return (this.getValue(host) * 100) + "%";
  12158. case ValueAndUnit.UNITMODE_PIXEL:
  12159. return this.getValue(host) + "px";
  12160. }
  12161. return this.unit.toString();
  12162. };
  12163. /**
  12164. * Store a value parsed from a string
  12165. * @param source defines the source string
  12166. * @returns true if the value was successfully parsed
  12167. */
  12168. ValueAndUnit.prototype.fromString = function (source) {
  12169. var match = ValueAndUnit._Regex.exec(source.toString());
  12170. if (!match || match.length === 0) {
  12171. return false;
  12172. }
  12173. var sourceValue = parseFloat(match[1]);
  12174. var sourceUnit = this._originalUnit;
  12175. if (!this.negativeValueAllowed) {
  12176. if (sourceValue < 0) {
  12177. sourceValue = 0;
  12178. }
  12179. }
  12180. if (match.length === 4) {
  12181. switch (match[3]) {
  12182. case "px":
  12183. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  12184. break;
  12185. case "%":
  12186. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  12187. sourceValue /= 100.0;
  12188. break;
  12189. }
  12190. }
  12191. if (sourceValue === this._value && sourceUnit === this.unit) {
  12192. return false;
  12193. }
  12194. this._value = sourceValue;
  12195. this.unit = sourceUnit;
  12196. return true;
  12197. };
  12198. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  12199. /** UNITMODE_PERCENTAGE */
  12200. get: function () {
  12201. return ValueAndUnit._UNITMODE_PERCENTAGE;
  12202. },
  12203. enumerable: true,
  12204. configurable: true
  12205. });
  12206. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  12207. /** UNITMODE_PIXEL */
  12208. get: function () {
  12209. return ValueAndUnit._UNITMODE_PIXEL;
  12210. },
  12211. enumerable: true,
  12212. configurable: true
  12213. });
  12214. // Static
  12215. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  12216. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  12217. ValueAndUnit._UNITMODE_PIXEL = 1;
  12218. return ValueAndUnit;
  12219. }());
  12220. /***/ }),
  12221. /***/ "./3D/controls/abstractButton3D.ts":
  12222. /*!*****************************************!*\
  12223. !*** ./3D/controls/abstractButton3D.ts ***!
  12224. \*****************************************/
  12225. /*! exports provided: AbstractButton3D */
  12226. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12227. "use strict";
  12228. __webpack_require__.r(__webpack_exports__);
  12229. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  12230. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12231. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/observable");
  12232. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  12233. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  12234. /**
  12235. * Class used as a root to all buttons
  12236. */
  12237. var AbstractButton3D = /** @class */ (function (_super) {
  12238. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AbstractButton3D, _super);
  12239. /**
  12240. * Creates a new button
  12241. * @param name defines the control name
  12242. */
  12243. function AbstractButton3D(name) {
  12244. return _super.call(this, name) || this;
  12245. }
  12246. AbstractButton3D.prototype._getTypeName = function () {
  12247. return "AbstractButton3D";
  12248. };
  12249. // Mesh association
  12250. AbstractButton3D.prototype._createNode = function (scene) {
  12251. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  12252. };
  12253. return AbstractButton3D;
  12254. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  12255. /***/ }),
  12256. /***/ "./3D/controls/button3D.ts":
  12257. /*!*********************************!*\
  12258. !*** ./3D/controls/button3D.ts ***!
  12259. \*********************************/
  12260. /*! exports provided: Button3D */
  12261. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12262. "use strict";
  12263. __webpack_require__.r(__webpack_exports__);
  12264. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  12265. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12266. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  12267. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  12268. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  12269. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  12270. /**
  12271. * Class used to create a button in 3D
  12272. */
  12273. var Button3D = /** @class */ (function (_super) {
  12274. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Button3D, _super);
  12275. /**
  12276. * Creates a new button
  12277. * @param name defines the control name
  12278. */
  12279. function Button3D(name) {
  12280. var _this = _super.call(this, name) || this;
  12281. _this._contentResolution = 512;
  12282. _this._contentScaleRatio = 2;
  12283. // Default animations
  12284. _this.pointerEnterAnimation = function () {
  12285. if (!_this.mesh) {
  12286. return;
  12287. }
  12288. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  12289. };
  12290. _this.pointerOutAnimation = function () {
  12291. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  12292. };
  12293. _this.pointerDownAnimation = function () {
  12294. if (!_this.mesh) {
  12295. return;
  12296. }
  12297. _this.mesh.scaling.scaleInPlace(0.95);
  12298. };
  12299. _this.pointerUpAnimation = function () {
  12300. if (!_this.mesh) {
  12301. return;
  12302. }
  12303. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  12304. };
  12305. return _this;
  12306. }
  12307. Object.defineProperty(Button3D.prototype, "contentResolution", {
  12308. /**
  12309. * Gets or sets the texture resolution used to render content (512 by default)
  12310. */
  12311. get: function () {
  12312. return this._contentResolution;
  12313. },
  12314. set: function (value) {
  12315. if (this._contentResolution === value) {
  12316. return;
  12317. }
  12318. this._contentResolution = value;
  12319. this._resetContent();
  12320. },
  12321. enumerable: true,
  12322. configurable: true
  12323. });
  12324. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  12325. /**
  12326. * Gets or sets the texture scale ratio used to render content (2 by default)
  12327. */
  12328. get: function () {
  12329. return this._contentScaleRatio;
  12330. },
  12331. set: function (value) {
  12332. if (this._contentScaleRatio === value) {
  12333. return;
  12334. }
  12335. this._contentScaleRatio = value;
  12336. this._resetContent();
  12337. },
  12338. enumerable: true,
  12339. configurable: true
  12340. });
  12341. Button3D.prototype._disposeFacadeTexture = function () {
  12342. if (this._facadeTexture) {
  12343. this._facadeTexture.dispose();
  12344. this._facadeTexture = null;
  12345. }
  12346. };
  12347. Button3D.prototype._resetContent = function () {
  12348. this._disposeFacadeTexture();
  12349. this.content = this._content;
  12350. };
  12351. Object.defineProperty(Button3D.prototype, "content", {
  12352. /**
  12353. * Gets or sets the GUI 2D content used to display the button's facade
  12354. */
  12355. get: function () {
  12356. return this._content;
  12357. },
  12358. set: function (value) {
  12359. this._content = value;
  12360. if (!this._host || !this._host.utilityLayer) {
  12361. return;
  12362. }
  12363. if (!this._facadeTexture) {
  12364. this._facadeTexture = new _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__["AdvancedDynamicTexture"]("Facade", this._contentResolution, this._contentResolution, this._host.utilityLayer.utilityLayerScene, true, babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE);
  12365. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  12366. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  12367. this._facadeTexture.premulAlpha = true;
  12368. }
  12369. this._facadeTexture.addControl(value);
  12370. this._applyFacade(this._facadeTexture);
  12371. },
  12372. enumerable: true,
  12373. configurable: true
  12374. });
  12375. /**
  12376. * Apply the facade texture (created from the content property).
  12377. * This function can be overloaded by child classes
  12378. * @param facadeTexture defines the AdvancedDynamicTexture to use
  12379. */
  12380. Button3D.prototype._applyFacade = function (facadeTexture) {
  12381. this._currentMaterial.emissiveTexture = facadeTexture;
  12382. };
  12383. Button3D.prototype._getTypeName = function () {
  12384. return "Button3D";
  12385. };
  12386. // Mesh association
  12387. Button3D.prototype._createNode = function (scene) {
  12388. var faceUV = new Array(6);
  12389. for (var i = 0; i < 6; i++) {
  12390. faceUV[i] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  12391. }
  12392. faceUV[1] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  12393. var mesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["MeshBuilder"].CreateBox(this.name + "_rootMesh", {
  12394. width: 1.0,
  12395. height: 1.0,
  12396. depth: 0.08,
  12397. faceUV: faceUV
  12398. }, scene);
  12399. return mesh;
  12400. };
  12401. Button3D.prototype._affectMaterial = function (mesh) {
  12402. var material = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  12403. material.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  12404. mesh.material = material;
  12405. this._currentMaterial = material;
  12406. this._resetContent();
  12407. };
  12408. /**
  12409. * Releases all associated resources
  12410. */
  12411. Button3D.prototype.dispose = function () {
  12412. _super.prototype.dispose.call(this);
  12413. this._disposeFacadeTexture();
  12414. if (this._currentMaterial) {
  12415. this._currentMaterial.dispose();
  12416. }
  12417. };
  12418. return Button3D;
  12419. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  12420. /***/ }),
  12421. /***/ "./3D/controls/container3D.ts":
  12422. /*!************************************!*\
  12423. !*** ./3D/controls/container3D.ts ***!
  12424. \************************************/
  12425. /*! exports provided: Container3D */
  12426. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12427. "use strict";
  12428. __webpack_require__.r(__webpack_exports__);
  12429. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  12430. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12431. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/observable");
  12432. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  12433. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  12434. /**
  12435. * Class used to create containers for controls
  12436. */
  12437. var Container3D = /** @class */ (function (_super) {
  12438. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Container3D, _super);
  12439. /**
  12440. * Creates a new container
  12441. * @param name defines the container name
  12442. */
  12443. function Container3D(name) {
  12444. var _this = _super.call(this, name) || this;
  12445. _this._blockLayout = false;
  12446. /**
  12447. * Gets the list of child controls
  12448. */
  12449. _this._children = new Array();
  12450. return _this;
  12451. }
  12452. Object.defineProperty(Container3D.prototype, "children", {
  12453. /**
  12454. * Gets the list of child controls
  12455. */
  12456. get: function () {
  12457. return this._children;
  12458. },
  12459. enumerable: true,
  12460. configurable: true
  12461. });
  12462. Object.defineProperty(Container3D.prototype, "blockLayout", {
  12463. /**
  12464. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  12465. * This is helpful to optimize layout operation when adding multiple children in a row
  12466. */
  12467. get: function () {
  12468. return this._blockLayout;
  12469. },
  12470. set: function (value) {
  12471. if (this._blockLayout === value) {
  12472. return;
  12473. }
  12474. this._blockLayout = value;
  12475. if (!this._blockLayout) {
  12476. this._arrangeChildren();
  12477. }
  12478. },
  12479. enumerable: true,
  12480. configurable: true
  12481. });
  12482. /**
  12483. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  12484. * @returns the current container
  12485. */
  12486. Container3D.prototype.updateLayout = function () {
  12487. this._arrangeChildren();
  12488. return this;
  12489. };
  12490. /**
  12491. * Gets a boolean indicating if the given control is in the children of this control
  12492. * @param control defines the control to check
  12493. * @returns true if the control is in the child list
  12494. */
  12495. Container3D.prototype.containsControl = function (control) {
  12496. return this._children.indexOf(control) !== -1;
  12497. };
  12498. /**
  12499. * Adds a control to the children of this control
  12500. * @param control defines the control to add
  12501. * @returns the current container
  12502. */
  12503. Container3D.prototype.addControl = function (control) {
  12504. var index = this._children.indexOf(control);
  12505. if (index !== -1) {
  12506. return this;
  12507. }
  12508. control.parent = this;
  12509. control._host = this._host;
  12510. this._children.push(control);
  12511. if (this._host.utilityLayer) {
  12512. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  12513. if (control.node) {
  12514. control.node.parent = this.node;
  12515. }
  12516. if (!this.blockLayout) {
  12517. this._arrangeChildren();
  12518. }
  12519. }
  12520. return this;
  12521. };
  12522. /**
  12523. * This function will be called everytime a new control is added
  12524. */
  12525. Container3D.prototype._arrangeChildren = function () {
  12526. };
  12527. Container3D.prototype._createNode = function (scene) {
  12528. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  12529. };
  12530. /**
  12531. * Removes a control from the children of this control
  12532. * @param control defines the control to remove
  12533. * @returns the current container
  12534. */
  12535. Container3D.prototype.removeControl = function (control) {
  12536. var index = this._children.indexOf(control);
  12537. if (index !== -1) {
  12538. this._children.splice(index, 1);
  12539. control.parent = null;
  12540. control._disposeNode();
  12541. }
  12542. return this;
  12543. };
  12544. Container3D.prototype._getTypeName = function () {
  12545. return "Container3D";
  12546. };
  12547. /**
  12548. * Releases all associated resources
  12549. */
  12550. Container3D.prototype.dispose = function () {
  12551. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  12552. var control = _a[_i];
  12553. control.dispose();
  12554. }
  12555. this._children = [];
  12556. _super.prototype.dispose.call(this);
  12557. };
  12558. /** Control rotation will remain unchanged */
  12559. Container3D.UNSET_ORIENTATION = 0;
  12560. /** Control will rotate to make it look at sphere central axis */
  12561. Container3D.FACEORIGIN_ORIENTATION = 1;
  12562. /** Control will rotate to make it look back at sphere central axis */
  12563. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  12564. /** Control will rotate to look at z axis (0, 0, 1) */
  12565. Container3D.FACEFORWARD_ORIENTATION = 3;
  12566. /** Control will rotate to look at negative z axis (0, 0, -1) */
  12567. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  12568. return Container3D;
  12569. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  12570. /***/ }),
  12571. /***/ "./3D/controls/control3D.ts":
  12572. /*!**********************************!*\
  12573. !*** ./3D/controls/control3D.ts ***!
  12574. \**********************************/
  12575. /*! exports provided: Control3D */
  12576. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12577. "use strict";
  12578. __webpack_require__.r(__webpack_exports__);
  12579. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  12580. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  12581. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  12582. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  12583. /**
  12584. * Class used as base class for controls
  12585. */
  12586. var Control3D = /** @class */ (function () {
  12587. /**
  12588. * Creates a new control
  12589. * @param name defines the control name
  12590. */
  12591. function Control3D(
  12592. /** Defines the control name */
  12593. name) {
  12594. this.name = name;
  12595. this._downCount = 0;
  12596. this._enterCount = -1;
  12597. this._downPointerIds = {};
  12598. this._isVisible = true;
  12599. /**
  12600. * An event triggered when the pointer move over the control
  12601. */
  12602. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12603. /**
  12604. * An event triggered when the pointer move out of the control
  12605. */
  12606. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12607. /**
  12608. * An event triggered when the pointer taps the control
  12609. */
  12610. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12611. /**
  12612. * An event triggered when pointer is up
  12613. */
  12614. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12615. /**
  12616. * An event triggered when a control is clicked on (with a mouse)
  12617. */
  12618. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12619. /**
  12620. * An event triggered when pointer enters the control
  12621. */
  12622. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12623. // Behaviors
  12624. this._behaviors = new Array();
  12625. }
  12626. Object.defineProperty(Control3D.prototype, "position", {
  12627. /** Gets or sets the control position in world space */
  12628. get: function () {
  12629. if (!this._node) {
  12630. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  12631. }
  12632. return this._node.position;
  12633. },
  12634. set: function (value) {
  12635. if (!this._node) {
  12636. return;
  12637. }
  12638. this._node.position = value;
  12639. },
  12640. enumerable: true,
  12641. configurable: true
  12642. });
  12643. Object.defineProperty(Control3D.prototype, "scaling", {
  12644. /** Gets or sets the control scaling in world space */
  12645. get: function () {
  12646. if (!this._node) {
  12647. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  12648. }
  12649. return this._node.scaling;
  12650. },
  12651. set: function (value) {
  12652. if (!this._node) {
  12653. return;
  12654. }
  12655. this._node.scaling = value;
  12656. },
  12657. enumerable: true,
  12658. configurable: true
  12659. });
  12660. Object.defineProperty(Control3D.prototype, "behaviors", {
  12661. /**
  12662. * Gets the list of attached behaviors
  12663. * @see http://doc.babylonjs.com/features/behaviour
  12664. */
  12665. get: function () {
  12666. return this._behaviors;
  12667. },
  12668. enumerable: true,
  12669. configurable: true
  12670. });
  12671. /**
  12672. * Attach a behavior to the control
  12673. * @see http://doc.babylonjs.com/features/behaviour
  12674. * @param behavior defines the behavior to attach
  12675. * @returns the current control
  12676. */
  12677. Control3D.prototype.addBehavior = function (behavior) {
  12678. var _this = this;
  12679. var index = this._behaviors.indexOf(behavior);
  12680. if (index !== -1) {
  12681. return this;
  12682. }
  12683. behavior.init();
  12684. var scene = this._host.scene;
  12685. if (scene.isLoading) {
  12686. // We defer the attach when the scene will be loaded
  12687. scene.onDataLoadedObservable.addOnce(function () {
  12688. behavior.attach(_this);
  12689. });
  12690. }
  12691. else {
  12692. behavior.attach(this);
  12693. }
  12694. this._behaviors.push(behavior);
  12695. return this;
  12696. };
  12697. /**
  12698. * Remove an attached behavior
  12699. * @see http://doc.babylonjs.com/features/behaviour
  12700. * @param behavior defines the behavior to attach
  12701. * @returns the current control
  12702. */
  12703. Control3D.prototype.removeBehavior = function (behavior) {
  12704. var index = this._behaviors.indexOf(behavior);
  12705. if (index === -1) {
  12706. return this;
  12707. }
  12708. this._behaviors[index].detach();
  12709. this._behaviors.splice(index, 1);
  12710. return this;
  12711. };
  12712. /**
  12713. * Gets an attached behavior by name
  12714. * @param name defines the name of the behavior to look for
  12715. * @see http://doc.babylonjs.com/features/behaviour
  12716. * @returns null if behavior was not found else the requested behavior
  12717. */
  12718. Control3D.prototype.getBehaviorByName = function (name) {
  12719. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  12720. var behavior = _a[_i];
  12721. if (behavior.name === name) {
  12722. return behavior;
  12723. }
  12724. }
  12725. return null;
  12726. };
  12727. Object.defineProperty(Control3D.prototype, "isVisible", {
  12728. /** Gets or sets a boolean indicating if the control is visible */
  12729. get: function () {
  12730. return this._isVisible;
  12731. },
  12732. set: function (value) {
  12733. if (this._isVisible === value) {
  12734. return;
  12735. }
  12736. this._isVisible = value;
  12737. var mesh = this.mesh;
  12738. if (mesh) {
  12739. mesh.setEnabled(value);
  12740. }
  12741. },
  12742. enumerable: true,
  12743. configurable: true
  12744. });
  12745. Object.defineProperty(Control3D.prototype, "typeName", {
  12746. /**
  12747. * Gets a string representing the class name
  12748. */
  12749. get: function () {
  12750. return this._getTypeName();
  12751. },
  12752. enumerable: true,
  12753. configurable: true
  12754. });
  12755. /**
  12756. * Get the current class name of the control.
  12757. * @returns current class name
  12758. */
  12759. Control3D.prototype.getClassName = function () {
  12760. return this._getTypeName();
  12761. };
  12762. Control3D.prototype._getTypeName = function () {
  12763. return "Control3D";
  12764. };
  12765. Object.defineProperty(Control3D.prototype, "node", {
  12766. /**
  12767. * Gets the transform node used by this control
  12768. */
  12769. get: function () {
  12770. return this._node;
  12771. },
  12772. enumerable: true,
  12773. configurable: true
  12774. });
  12775. Object.defineProperty(Control3D.prototype, "mesh", {
  12776. /**
  12777. * Gets the mesh used to render this control
  12778. */
  12779. get: function () {
  12780. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  12781. return this._node;
  12782. }
  12783. return null;
  12784. },
  12785. enumerable: true,
  12786. configurable: true
  12787. });
  12788. /**
  12789. * Link the control as child of the given node
  12790. * @param node defines the node to link to. Use null to unlink the control
  12791. * @returns the current control
  12792. */
  12793. Control3D.prototype.linkToTransformNode = function (node) {
  12794. if (this._node) {
  12795. this._node.parent = node;
  12796. }
  12797. return this;
  12798. };
  12799. /** @hidden **/
  12800. Control3D.prototype._prepareNode = function (scene) {
  12801. if (!this._node) {
  12802. this._node = this._createNode(scene);
  12803. if (!this.node) {
  12804. return;
  12805. }
  12806. this._node.metadata = this; // Store the control on the metadata field in order to get it when picking
  12807. this._node.position = this.position;
  12808. this._node.scaling = this.scaling;
  12809. var mesh = this.mesh;
  12810. if (mesh) {
  12811. mesh.isPickable = true;
  12812. this._affectMaterial(mesh);
  12813. }
  12814. }
  12815. };
  12816. /**
  12817. * Node creation.
  12818. * Can be overriden by children
  12819. * @param scene defines the scene where the node must be attached
  12820. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  12821. */
  12822. Control3D.prototype._createNode = function (scene) {
  12823. // Do nothing by default
  12824. return null;
  12825. };
  12826. /**
  12827. * Affect a material to the given mesh
  12828. * @param mesh defines the mesh which will represent the control
  12829. */
  12830. Control3D.prototype._affectMaterial = function (mesh) {
  12831. mesh.material = null;
  12832. };
  12833. // Pointers
  12834. /** @hidden */
  12835. Control3D.prototype._onPointerMove = function (target, coordinates) {
  12836. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  12837. };
  12838. /** @hidden */
  12839. Control3D.prototype._onPointerEnter = function (target) {
  12840. if (this._enterCount > 0) {
  12841. return false;
  12842. }
  12843. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  12844. this._enterCount = 0;
  12845. }
  12846. this._enterCount++;
  12847. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  12848. if (this.pointerEnterAnimation) {
  12849. this.pointerEnterAnimation();
  12850. }
  12851. return true;
  12852. };
  12853. /** @hidden */
  12854. Control3D.prototype._onPointerOut = function (target) {
  12855. this._enterCount = 0;
  12856. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  12857. if (this.pointerOutAnimation) {
  12858. this.pointerOutAnimation();
  12859. }
  12860. };
  12861. /** @hidden */
  12862. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  12863. if (this._downCount !== 0) {
  12864. return false;
  12865. }
  12866. this._downCount++;
  12867. this._downPointerIds[pointerId] = true;
  12868. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  12869. if (this.pointerDownAnimation) {
  12870. this.pointerDownAnimation();
  12871. }
  12872. return true;
  12873. };
  12874. /** @hidden */
  12875. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  12876. this._downCount = 0;
  12877. delete this._downPointerIds[pointerId];
  12878. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  12879. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  12880. }
  12881. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  12882. if (this.pointerUpAnimation) {
  12883. this.pointerUpAnimation();
  12884. }
  12885. };
  12886. /** @hidden */
  12887. Control3D.prototype.forcePointerUp = function (pointerId) {
  12888. if (pointerId === void 0) { pointerId = null; }
  12889. if (pointerId !== null) {
  12890. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  12891. }
  12892. else {
  12893. for (var key in this._downPointerIds) {
  12894. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  12895. }
  12896. }
  12897. };
  12898. /** @hidden */
  12899. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  12900. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  12901. this._onPointerMove(this, pickedPoint);
  12902. var previousControlOver = this._host._lastControlOver[pointerId];
  12903. if (previousControlOver && previousControlOver !== this) {
  12904. previousControlOver._onPointerOut(this);
  12905. }
  12906. if (previousControlOver !== this) {
  12907. this._onPointerEnter(this);
  12908. }
  12909. this._host._lastControlOver[pointerId] = this;
  12910. return true;
  12911. }
  12912. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  12913. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  12914. this._host._lastControlDown[pointerId] = this;
  12915. this._host._lastPickedControl = this;
  12916. return true;
  12917. }
  12918. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  12919. if (this._host._lastControlDown[pointerId]) {
  12920. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  12921. }
  12922. delete this._host._lastControlDown[pointerId];
  12923. return true;
  12924. }
  12925. return false;
  12926. };
  12927. /** @hidden */
  12928. Control3D.prototype._disposeNode = function () {
  12929. if (this._node) {
  12930. this._node.dispose();
  12931. this._node = null;
  12932. }
  12933. };
  12934. /**
  12935. * Releases all associated resources
  12936. */
  12937. Control3D.prototype.dispose = function () {
  12938. this.onPointerDownObservable.clear();
  12939. this.onPointerEnterObservable.clear();
  12940. this.onPointerMoveObservable.clear();
  12941. this.onPointerOutObservable.clear();
  12942. this.onPointerUpObservable.clear();
  12943. this.onPointerClickObservable.clear();
  12944. this._disposeNode();
  12945. // Behaviors
  12946. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  12947. var behavior = _a[_i];
  12948. behavior.detach();
  12949. }
  12950. };
  12951. return Control3D;
  12952. }());
  12953. /***/ }),
  12954. /***/ "./3D/controls/cylinderPanel.ts":
  12955. /*!**************************************!*\
  12956. !*** ./3D/controls/cylinderPanel.ts ***!
  12957. \**************************************/
  12958. /*! exports provided: CylinderPanel */
  12959. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12960. "use strict";
  12961. __webpack_require__.r(__webpack_exports__);
  12962. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  12963. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12964. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  12965. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  12966. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  12967. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  12968. /**
  12969. * Class used to create a container panel deployed on the surface of a cylinder
  12970. */
  12971. var CylinderPanel = /** @class */ (function (_super) {
  12972. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CylinderPanel, _super);
  12973. function CylinderPanel() {
  12974. var _this = _super !== null && _super.apply(this, arguments) || this;
  12975. _this._radius = 5.0;
  12976. return _this;
  12977. }
  12978. Object.defineProperty(CylinderPanel.prototype, "radius", {
  12979. /**
  12980. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  12981. */
  12982. get: function () {
  12983. return this._radius;
  12984. },
  12985. set: function (value) {
  12986. var _this = this;
  12987. if (this._radius === value) {
  12988. return;
  12989. }
  12990. this._radius = value;
  12991. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  12992. _this._arrangeChildren();
  12993. });
  12994. },
  12995. enumerable: true,
  12996. configurable: true
  12997. });
  12998. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  12999. var mesh = control.mesh;
  13000. if (!mesh) {
  13001. return;
  13002. }
  13003. var newPos = this._cylindricalMapping(nodePosition);
  13004. control.position = newPos;
  13005. switch (this.orientation) {
  13006. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13007. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  13008. break;
  13009. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13010. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  13011. break;
  13012. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13013. break;
  13014. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13015. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  13016. break;
  13017. }
  13018. };
  13019. CylinderPanel.prototype._cylindricalMapping = function (source) {
  13020. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  13021. var yAngle = (source.x / this._radius);
  13022. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13023. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13024. };
  13025. return CylinderPanel;
  13026. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13027. /***/ }),
  13028. /***/ "./3D/controls/holographicButton.ts":
  13029. /*!******************************************!*\
  13030. !*** ./3D/controls/holographicButton.ts ***!
  13031. \******************************************/
  13032. /*! exports provided: HolographicButton */
  13033. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13034. "use strict";
  13035. __webpack_require__.r(__webpack_exports__);
  13036. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  13037. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13038. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13039. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  13040. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__);
  13041. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  13042. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  13043. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  13044. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  13045. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  13046. /**
  13047. * Class used to create a holographic button in 3D
  13048. */
  13049. var HolographicButton = /** @class */ (function (_super) {
  13050. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HolographicButton, _super);
  13051. /**
  13052. * Creates a new button
  13053. * @param name defines the control name
  13054. */
  13055. function HolographicButton(name, shareMaterials) {
  13056. if (shareMaterials === void 0) { shareMaterials = true; }
  13057. var _this = _super.call(this, name) || this;
  13058. _this._shareMaterials = true;
  13059. _this._shareMaterials = shareMaterials;
  13060. // Default animations
  13061. _this.pointerEnterAnimation = function () {
  13062. if (!_this.mesh) {
  13063. return;
  13064. }
  13065. _this._frontPlate.setEnabled(true);
  13066. };
  13067. _this.pointerOutAnimation = function () {
  13068. if (!_this.mesh) {
  13069. return;
  13070. }
  13071. _this._frontPlate.setEnabled(false);
  13072. };
  13073. return _this;
  13074. }
  13075. HolographicButton.prototype._disposeTooltip = function () {
  13076. this._tooltipFade = null;
  13077. if (this._tooltipTextBlock) {
  13078. this._tooltipTextBlock.dispose();
  13079. }
  13080. if (this._tooltipTexture) {
  13081. this._tooltipTexture.dispose();
  13082. }
  13083. if (this._tooltipMesh) {
  13084. this._tooltipMesh.dispose();
  13085. }
  13086. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  13087. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  13088. };
  13089. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  13090. get: function () {
  13091. if (this._tooltipTextBlock) {
  13092. return this._tooltipTextBlock.text;
  13093. }
  13094. return null;
  13095. },
  13096. /**
  13097. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  13098. */
  13099. set: function (text) {
  13100. var _this = this;
  13101. if (!text) {
  13102. this._disposeTooltip();
  13103. return;
  13104. }
  13105. if (!this._tooltipFade) {
  13106. // Create tooltip with mesh and text
  13107. this._tooltipMesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["MeshBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  13108. var tooltipBackground = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["MeshBuilder"].CreatePlane("", { size: 1, sideOrientation: babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Mesh"].DOUBLESIDE }, this._backPlate._scene);
  13109. var mat = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  13110. mat.diffuseColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  13111. tooltipBackground.material = mat;
  13112. tooltipBackground.isPickable = false;
  13113. this._tooltipMesh.addChild(tooltipBackground);
  13114. tooltipBackground.position.z = 0.05;
  13115. this._tooltipMesh.scaling.y = 1 / 3;
  13116. this._tooltipMesh.position.y = 0.7;
  13117. this._tooltipMesh.position.z = -0.15;
  13118. this._tooltipMesh.isPickable = false;
  13119. this._tooltipMesh.parent = this._backPlate;
  13120. // Create text texture for the tooltip
  13121. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  13122. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  13123. this._tooltipTextBlock.scaleY = 3;
  13124. this._tooltipTextBlock.color = "white";
  13125. this._tooltipTextBlock.fontSize = 130;
  13126. this._tooltipTexture.addControl(this._tooltipTextBlock);
  13127. // Add hover action to tooltip
  13128. this._tooltipFade = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  13129. this._tooltipFade.delay = 500;
  13130. this._tooltipMesh.addBehavior(this._tooltipFade);
  13131. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  13132. if (_this._tooltipFade) {
  13133. _this._tooltipFade.fadeIn(true);
  13134. }
  13135. });
  13136. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  13137. if (_this._tooltipFade) {
  13138. _this._tooltipFade.fadeIn(false);
  13139. }
  13140. });
  13141. }
  13142. if (this._tooltipTextBlock) {
  13143. this._tooltipTextBlock.text = text;
  13144. }
  13145. },
  13146. enumerable: true,
  13147. configurable: true
  13148. });
  13149. Object.defineProperty(HolographicButton.prototype, "text", {
  13150. /**
  13151. * Gets or sets text for the button
  13152. */
  13153. get: function () {
  13154. return this._text;
  13155. },
  13156. set: function (value) {
  13157. if (this._text === value) {
  13158. return;
  13159. }
  13160. this._text = value;
  13161. this._rebuildContent();
  13162. },
  13163. enumerable: true,
  13164. configurable: true
  13165. });
  13166. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  13167. /**
  13168. * Gets or sets the image url for the button
  13169. */
  13170. get: function () {
  13171. return this._imageUrl;
  13172. },
  13173. set: function (value) {
  13174. if (this._imageUrl === value) {
  13175. return;
  13176. }
  13177. this._imageUrl = value;
  13178. this._rebuildContent();
  13179. },
  13180. enumerable: true,
  13181. configurable: true
  13182. });
  13183. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  13184. /**
  13185. * Gets the back material used by this button
  13186. */
  13187. get: function () {
  13188. return this._backMaterial;
  13189. },
  13190. enumerable: true,
  13191. configurable: true
  13192. });
  13193. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  13194. /**
  13195. * Gets the front material used by this button
  13196. */
  13197. get: function () {
  13198. return this._frontMaterial;
  13199. },
  13200. enumerable: true,
  13201. configurable: true
  13202. });
  13203. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  13204. /**
  13205. * Gets the plate material used by this button
  13206. */
  13207. get: function () {
  13208. return this._plateMaterial;
  13209. },
  13210. enumerable: true,
  13211. configurable: true
  13212. });
  13213. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  13214. /**
  13215. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  13216. */
  13217. get: function () {
  13218. return this._shareMaterials;
  13219. },
  13220. enumerable: true,
  13221. configurable: true
  13222. });
  13223. HolographicButton.prototype._getTypeName = function () {
  13224. return "HolographicButton";
  13225. };
  13226. HolographicButton.prototype._rebuildContent = function () {
  13227. this._disposeFacadeTexture();
  13228. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  13229. panel.isVertical = true;
  13230. if (this._imageUrl) {
  13231. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  13232. image.source = this._imageUrl;
  13233. image.paddingTop = "40px";
  13234. image.height = "180px";
  13235. image.width = "100px";
  13236. image.paddingBottom = "40px";
  13237. panel.addControl(image);
  13238. }
  13239. if (this._text) {
  13240. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  13241. text.text = this._text;
  13242. text.color = "white";
  13243. text.height = "30px";
  13244. text.fontSize = 24;
  13245. panel.addControl(text);
  13246. }
  13247. if (this._frontPlate) {
  13248. this.content = panel;
  13249. }
  13250. };
  13251. // Mesh association
  13252. HolographicButton.prototype._createNode = function (scene) {
  13253. this._backPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["MeshBuilder"].CreateBox(this.name + "BackMesh", {
  13254. width: 1.0,
  13255. height: 1.0,
  13256. depth: 0.08
  13257. }, scene);
  13258. this._frontPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["MeshBuilder"].CreateBox(this.name + "FrontMesh", {
  13259. width: 1.0,
  13260. height: 1.0,
  13261. depth: 0.08
  13262. }, scene);
  13263. this._frontPlate.parent = this._backPlate;
  13264. this._frontPlate.position.z = -0.08;
  13265. this._frontPlate.isPickable = false;
  13266. this._frontPlate.setEnabled(false);
  13267. this._textPlate = _super.prototype._createNode.call(this, scene);
  13268. this._textPlate.parent = this._backPlate;
  13269. this._textPlate.position.z = -0.08;
  13270. this._textPlate.isPickable = false;
  13271. return this._backPlate;
  13272. };
  13273. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  13274. this._plateMaterial.emissiveTexture = facadeTexture;
  13275. this._plateMaterial.opacityTexture = facadeTexture;
  13276. };
  13277. HolographicButton.prototype._createBackMaterial = function (mesh) {
  13278. var _this = this;
  13279. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  13280. this._backMaterial.renderHoverLight = true;
  13281. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  13282. if (pickedPoint) {
  13283. _this._backMaterial.hoverPosition = pickedPoint;
  13284. _this._backMaterial.hoverColor.a = 1.0;
  13285. }
  13286. else {
  13287. _this._backMaterial.hoverColor.a = 0;
  13288. }
  13289. });
  13290. };
  13291. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  13292. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  13293. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  13294. this._frontMaterial.alpha = 0.5; // Additive
  13295. this._frontMaterial.renderBorders = true;
  13296. };
  13297. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  13298. this._plateMaterial = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  13299. this._plateMaterial.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  13300. };
  13301. HolographicButton.prototype._affectMaterial = function (mesh) {
  13302. // Back
  13303. if (this._shareMaterials) {
  13304. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  13305. this._createBackMaterial(mesh);
  13306. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  13307. }
  13308. else {
  13309. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  13310. }
  13311. // Front
  13312. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  13313. this._createFrontMaterial(mesh);
  13314. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  13315. }
  13316. else {
  13317. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  13318. }
  13319. }
  13320. else {
  13321. this._createBackMaterial(mesh);
  13322. this._createFrontMaterial(mesh);
  13323. }
  13324. this._createPlateMaterial(mesh);
  13325. this._backPlate.material = this._backMaterial;
  13326. this._frontPlate.material = this._frontMaterial;
  13327. this._textPlate.material = this._plateMaterial;
  13328. this._rebuildContent();
  13329. };
  13330. /**
  13331. * Releases all associated resources
  13332. */
  13333. HolographicButton.prototype.dispose = function () {
  13334. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  13335. this._disposeTooltip();
  13336. if (!this.shareMaterials) {
  13337. this._backMaterial.dispose();
  13338. this._frontMaterial.dispose();
  13339. this._plateMaterial.dispose();
  13340. if (this._pickedPointObserver) {
  13341. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  13342. this._pickedPointObserver = null;
  13343. }
  13344. }
  13345. };
  13346. return HolographicButton;
  13347. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  13348. /***/ }),
  13349. /***/ "./3D/controls/index.ts":
  13350. /*!******************************!*\
  13351. !*** ./3D/controls/index.ts ***!
  13352. \******************************/
  13353. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel */
  13354. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13355. "use strict";
  13356. __webpack_require__.r(__webpack_exports__);
  13357. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  13358. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  13359. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13360. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  13361. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  13363. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  13365. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  13366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  13367. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  13368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  13369. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  13370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  13371. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  13372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  13373. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  13374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  13375. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  13376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  13377. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  13378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  13379. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__["VolumeBasedPanel"]; });
  13381. /***/ }),
  13382. /***/ "./3D/controls/meshButton3D.ts":
  13383. /*!*************************************!*\
  13384. !*** ./3D/controls/meshButton3D.ts ***!
  13385. \*************************************/
  13386. /*! exports provided: MeshButton3D */
  13387. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13388. "use strict";
  13389. __webpack_require__.r(__webpack_exports__);
  13390. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  13391. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13392. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13393. /**
  13394. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  13395. */
  13396. var MeshButton3D = /** @class */ (function (_super) {
  13397. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MeshButton3D, _super);
  13398. /**
  13399. * Creates a new 3D button based on a mesh
  13400. * @param mesh mesh to become a 3D button
  13401. * @param name defines the control name
  13402. */
  13403. function MeshButton3D(mesh, name) {
  13404. var _this = _super.call(this, name) || this;
  13405. _this._currentMesh = mesh;
  13406. /**
  13407. * Provides a default behavior on hover/out & up/down
  13408. * Override those function to create your own desired behavior specific to your mesh
  13409. */
  13410. _this.pointerEnterAnimation = function () {
  13411. if (!_this.mesh) {
  13412. return;
  13413. }
  13414. _this.mesh.scaling.scaleInPlace(1.1);
  13415. };
  13416. _this.pointerOutAnimation = function () {
  13417. if (!_this.mesh) {
  13418. return;
  13419. }
  13420. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  13421. };
  13422. _this.pointerDownAnimation = function () {
  13423. if (!_this.mesh) {
  13424. return;
  13425. }
  13426. _this.mesh.scaling.scaleInPlace(0.95);
  13427. };
  13428. _this.pointerUpAnimation = function () {
  13429. if (!_this.mesh) {
  13430. return;
  13431. }
  13432. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  13433. };
  13434. return _this;
  13435. }
  13436. MeshButton3D.prototype._getTypeName = function () {
  13437. return "MeshButton3D";
  13438. };
  13439. // Mesh association
  13440. MeshButton3D.prototype._createNode = function (scene) {
  13441. var _this = this;
  13442. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  13443. mesh.metadata = _this;
  13444. });
  13445. return this._currentMesh;
  13446. };
  13447. MeshButton3D.prototype._affectMaterial = function (mesh) {
  13448. };
  13449. return MeshButton3D;
  13450. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  13451. /***/ }),
  13452. /***/ "./3D/controls/planePanel.ts":
  13453. /*!***********************************!*\
  13454. !*** ./3D/controls/planePanel.ts ***!
  13455. \***********************************/
  13456. /*! exports provided: PlanePanel */
  13457. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13458. "use strict";
  13459. __webpack_require__.r(__webpack_exports__);
  13460. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  13461. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13462. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  13463. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  13464. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13465. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13466. /**
  13467. * Class used to create a container panel deployed on the surface of a plane
  13468. */
  13469. var PlanePanel = /** @class */ (function (_super) {
  13470. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlanePanel, _super);
  13471. function PlanePanel() {
  13472. return _super !== null && _super.apply(this, arguments) || this;
  13473. }
  13474. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  13475. var mesh = control.mesh;
  13476. if (!mesh) {
  13477. return;
  13478. }
  13479. control.position = nodePosition.clone();
  13480. var target = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  13481. target.copyFrom(nodePosition);
  13482. switch (this.orientation) {
  13483. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  13484. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  13485. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  13486. mesh.lookAt(target);
  13487. break;
  13488. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13489. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13490. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  13491. mesh.lookAt(target);
  13492. break;
  13493. }
  13494. };
  13495. return PlanePanel;
  13496. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  13497. /***/ }),
  13498. /***/ "./3D/controls/scatterPanel.ts":
  13499. /*!*************************************!*\
  13500. !*** ./3D/controls/scatterPanel.ts ***!
  13501. \*************************************/
  13502. /*! exports provided: ScatterPanel */
  13503. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13504. "use strict";
  13505. __webpack_require__.r(__webpack_exports__);
  13506. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  13507. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13508. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  13509. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13510. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13511. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13512. /**
  13513. * Class used to create a container panel where items get randomized planar mapping
  13514. */
  13515. var ScatterPanel = /** @class */ (function (_super) {
  13516. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScatterPanel, _super);
  13517. function ScatterPanel() {
  13518. var _this = _super !== null && _super.apply(this, arguments) || this;
  13519. _this._iteration = 100.0;
  13520. return _this;
  13521. }
  13522. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  13523. /**
  13524. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  13525. */
  13526. get: function () {
  13527. return this._iteration;
  13528. },
  13529. set: function (value) {
  13530. var _this = this;
  13531. if (this._iteration === value) {
  13532. return;
  13533. }
  13534. this._iteration = value;
  13535. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13536. _this._arrangeChildren();
  13537. });
  13538. },
  13539. enumerable: true,
  13540. configurable: true
  13541. });
  13542. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  13543. var mesh = control.mesh;
  13544. var newPos = this._scatterMapping(nodePosition);
  13545. if (!mesh) {
  13546. return;
  13547. }
  13548. switch (this.orientation) {
  13549. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13550. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13551. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  13552. break;
  13553. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13554. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13555. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  13556. break;
  13557. }
  13558. control.position = newPos;
  13559. };
  13560. ScatterPanel.prototype._scatterMapping = function (source) {
  13561. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  13562. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  13563. return source;
  13564. };
  13565. ScatterPanel.prototype._finalProcessing = function () {
  13566. var meshes = [];
  13567. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13568. var child = _a[_i];
  13569. if (!child.mesh) {
  13570. continue;
  13571. }
  13572. meshes.push(child.mesh);
  13573. }
  13574. for (var count = 0; count < this._iteration; count++) {
  13575. meshes.sort(function (a, b) {
  13576. var distance1 = a.position.lengthSquared();
  13577. var distance2 = b.position.lengthSquared();
  13578. if (distance1 < distance2) {
  13579. return 1;
  13580. }
  13581. else if (distance1 > distance2) {
  13582. return -1;
  13583. }
  13584. return 0;
  13585. });
  13586. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  13587. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  13588. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector2[0];
  13589. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  13590. for (var i = 0; i < meshes.length - 1; i++) {
  13591. for (var j = i + 1; j < meshes.length; j++) {
  13592. if (i != j) {
  13593. meshes[j].position.subtractToRef(meshes[i].position, difference);
  13594. // Ignore Z axis
  13595. difference2D.x = difference.x;
  13596. difference2D.y = difference.y;
  13597. var combinedRadius = cellSize;
  13598. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  13599. var minSeparation = Math.min(distance, radiusPaddingSquared);
  13600. distance -= minSeparation;
  13601. if (distance < (Math.pow(combinedRadius, 2.0))) {
  13602. difference2D.normalize();
  13603. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  13604. meshes[j].position.addInPlace(difference);
  13605. meshes[i].position.subtractInPlace(difference);
  13606. }
  13607. }
  13608. }
  13609. }
  13610. }
  13611. };
  13612. return ScatterPanel;
  13613. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13614. /***/ }),
  13615. /***/ "./3D/controls/spherePanel.ts":
  13616. /*!************************************!*\
  13617. !*** ./3D/controls/spherePanel.ts ***!
  13618. \************************************/
  13619. /*! exports provided: SpherePanel */
  13620. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13621. "use strict";
  13622. __webpack_require__.r(__webpack_exports__);
  13623. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  13624. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13625. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  13626. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13627. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13628. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13629. /**
  13630. * Class used to create a container panel deployed on the surface of a sphere
  13631. */
  13632. var SpherePanel = /** @class */ (function (_super) {
  13633. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SpherePanel, _super);
  13634. function SpherePanel() {
  13635. var _this = _super !== null && _super.apply(this, arguments) || this;
  13636. _this._radius = 5.0;
  13637. return _this;
  13638. }
  13639. Object.defineProperty(SpherePanel.prototype, "radius", {
  13640. /**
  13641. * Gets or sets the radius of the sphere where to project controls (5 by default)
  13642. */
  13643. get: function () {
  13644. return this._radius;
  13645. },
  13646. set: function (value) {
  13647. var _this = this;
  13648. if (this._radius === value) {
  13649. return;
  13650. }
  13651. this._radius = value;
  13652. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13653. _this._arrangeChildren();
  13654. });
  13655. },
  13656. enumerable: true,
  13657. configurable: true
  13658. });
  13659. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  13660. var mesh = control.mesh;
  13661. if (!mesh) {
  13662. return;
  13663. }
  13664. var newPos = this._sphericalMapping(nodePosition);
  13665. control.position = newPos;
  13666. switch (this.orientation) {
  13667. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13668. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  13669. break;
  13670. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13671. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  13672. break;
  13673. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13674. break;
  13675. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13676. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  13677. break;
  13678. }
  13679. };
  13680. SpherePanel.prototype._sphericalMapping = function (source) {
  13681. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  13682. var xAngle = (source.y / this._radius);
  13683. var yAngle = -(source.x / this._radius);
  13684. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13685. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13686. };
  13687. return SpherePanel;
  13688. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13689. /***/ }),
  13690. /***/ "./3D/controls/stackPanel3D.ts":
  13691. /*!*************************************!*\
  13692. !*** ./3D/controls/stackPanel3D.ts ***!
  13693. \*************************************/
  13694. /*! exports provided: StackPanel3D */
  13695. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13696. "use strict";
  13697. __webpack_require__.r(__webpack_exports__);
  13698. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  13699. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13700. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  13701. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13702. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13703. /**
  13704. * Class used to create a stack panel in 3D on XY plane
  13705. */
  13706. var StackPanel3D = /** @class */ (function (_super) {
  13707. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StackPanel3D, _super);
  13708. /**
  13709. * Creates new StackPanel
  13710. * @param isVertical
  13711. */
  13712. function StackPanel3D(isVertical) {
  13713. if (isVertical === void 0) { isVertical = false; }
  13714. var _this = _super.call(this) || this;
  13715. _this._isVertical = false;
  13716. /**
  13717. * Gets or sets the distance between elements
  13718. */
  13719. _this.margin = 0.1;
  13720. _this._isVertical = isVertical;
  13721. return _this;
  13722. }
  13723. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  13724. /**
  13725. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  13726. */
  13727. get: function () {
  13728. return this._isVertical;
  13729. },
  13730. set: function (value) {
  13731. var _this = this;
  13732. if (this._isVertical === value) {
  13733. return;
  13734. }
  13735. this._isVertical = value;
  13736. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13737. _this._arrangeChildren();
  13738. });
  13739. },
  13740. enumerable: true,
  13741. configurable: true
  13742. });
  13743. StackPanel3D.prototype._arrangeChildren = function () {
  13744. var width = 0;
  13745. var height = 0;
  13746. var controlCount = 0;
  13747. var extendSizes = [];
  13748. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  13749. // Measure
  13750. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13751. var child = _a[_i];
  13752. if (!child.mesh) {
  13753. continue;
  13754. }
  13755. controlCount++;
  13756. child.mesh.computeWorldMatrix(true);
  13757. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13758. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  13759. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13760. extendSizes.push(extendSize);
  13761. if (this._isVertical) {
  13762. height += extendSize.y;
  13763. }
  13764. else {
  13765. width += extendSize.x;
  13766. }
  13767. }
  13768. if (this._isVertical) {
  13769. height += (controlCount - 1) * this.margin / 2;
  13770. }
  13771. else {
  13772. width += (controlCount - 1) * this.margin / 2;
  13773. }
  13774. // Arrange
  13775. var offset;
  13776. if (this._isVertical) {
  13777. offset = -height;
  13778. }
  13779. else {
  13780. offset = -width;
  13781. }
  13782. var index = 0;
  13783. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  13784. var child = _c[_b];
  13785. if (!child.mesh) {
  13786. continue;
  13787. }
  13788. controlCount--;
  13789. var extendSize = extendSizes[index++];
  13790. if (this._isVertical) {
  13791. child.position.y = offset + extendSize.y;
  13792. child.position.x = 0;
  13793. offset += extendSize.y * 2;
  13794. }
  13795. else {
  13796. child.position.x = offset + extendSize.x;
  13797. child.position.y = 0;
  13798. offset += extendSize.x * 2;
  13799. }
  13800. offset += (controlCount > 0 ? this.margin : 0);
  13801. }
  13802. };
  13803. return StackPanel3D;
  13804. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  13805. /***/ }),
  13806. /***/ "./3D/controls/volumeBasedPanel.ts":
  13807. /*!*****************************************!*\
  13808. !*** ./3D/controls/volumeBasedPanel.ts ***!
  13809. \*****************************************/
  13810. /*! exports provided: VolumeBasedPanel */
  13811. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13812. "use strict";
  13813. __webpack_require__.r(__webpack_exports__);
  13814. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  13815. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13816. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  13817. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13818. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13819. /**
  13820. * Abstract class used to create a container panel deployed on the surface of a volume
  13821. */
  13822. var VolumeBasedPanel = /** @class */ (function (_super) {
  13823. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VolumeBasedPanel, _super);
  13824. /**
  13825. * Creates new VolumeBasedPanel
  13826. */
  13827. function VolumeBasedPanel() {
  13828. var _this = _super.call(this) || this;
  13829. _this._columns = 10;
  13830. _this._rows = 0;
  13831. _this._rowThenColum = true;
  13832. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  13833. /**
  13834. * Gets or sets the distance between elements
  13835. */
  13836. _this.margin = 0;
  13837. return _this;
  13838. }
  13839. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  13840. /**
  13841. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  13842. * | Value | Type | Description |
  13843. * | ----- | ----------------------------------- | ----------- |
  13844. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  13845. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  13846. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  13847. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  13848. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  13849. */
  13850. get: function () {
  13851. return this._orientation;
  13852. },
  13853. set: function (value) {
  13854. var _this = this;
  13855. if (this._orientation === value) {
  13856. return;
  13857. }
  13858. this._orientation = value;
  13859. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13860. _this._arrangeChildren();
  13861. });
  13862. },
  13863. enumerable: true,
  13864. configurable: true
  13865. });
  13866. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  13867. /**
  13868. * Gets or sets the number of columns requested (10 by default).
  13869. * The panel will automatically compute the number of rows based on number of child controls.
  13870. */
  13871. get: function () {
  13872. return this._columns;
  13873. },
  13874. set: function (value) {
  13875. var _this = this;
  13876. if (this._columns === value) {
  13877. return;
  13878. }
  13879. this._columns = value;
  13880. this._rowThenColum = true;
  13881. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13882. _this._arrangeChildren();
  13883. });
  13884. },
  13885. enumerable: true,
  13886. configurable: true
  13887. });
  13888. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  13889. /**
  13890. * Gets or sets a the number of rows requested.
  13891. * The panel will automatically compute the number of columns based on number of child controls.
  13892. */
  13893. get: function () {
  13894. return this._rows;
  13895. },
  13896. set: function (value) {
  13897. var _this = this;
  13898. if (this._rows === value) {
  13899. return;
  13900. }
  13901. this._rows = value;
  13902. this._rowThenColum = false;
  13903. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13904. _this._arrangeChildren();
  13905. });
  13906. },
  13907. enumerable: true,
  13908. configurable: true
  13909. });
  13910. VolumeBasedPanel.prototype._arrangeChildren = function () {
  13911. this._cellWidth = 0;
  13912. this._cellHeight = 0;
  13913. var rows = 0;
  13914. var columns = 0;
  13915. var controlCount = 0;
  13916. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  13917. // Measure
  13918. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13919. var child = _a[_i];
  13920. if (!child.mesh) {
  13921. continue;
  13922. }
  13923. controlCount++;
  13924. child.mesh.computeWorldMatrix(true);
  13925. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  13926. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  13927. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  13928. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  13929. boundingBox.max.subtractToRef(boundingBox.min, diff);
  13930. diff.scaleInPlace(0.5);
  13931. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  13932. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  13933. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  13934. }
  13935. this._cellWidth += this.margin * 2;
  13936. this._cellHeight += this.margin * 2;
  13937. // Arrange
  13938. if (this._rowThenColum) {
  13939. columns = this._columns;
  13940. rows = Math.ceil(controlCount / this._columns);
  13941. }
  13942. else {
  13943. rows = this._rows;
  13944. columns = Math.ceil(controlCount / this._rows);
  13945. }
  13946. var startOffsetX = (columns * 0.5) * this._cellWidth;
  13947. var startOffsetY = (rows * 0.5) * this._cellHeight;
  13948. var nodeGrid = [];
  13949. var cellCounter = 0;
  13950. if (this._rowThenColum) {
  13951. for (var r = 0; r < rows; r++) {
  13952. for (var c = 0; c < columns; c++) {
  13953. nodeGrid.push(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"]((c * this._cellWidth) - startOffsetX + this._cellWidth / 2, (r * this._cellHeight) - startOffsetY + this._cellHeight / 2, 0));
  13954. cellCounter++;
  13955. if (cellCounter > controlCount) {
  13956. break;
  13957. }
  13958. }
  13959. }
  13960. }
  13961. else {
  13962. for (var c = 0; c < columns; c++) {
  13963. for (var r = 0; r < rows; r++) {
  13964. nodeGrid.push(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"]((c * this._cellWidth) - startOffsetX + this._cellWidth / 2, (r * this._cellHeight) - startOffsetY + this._cellHeight / 2, 0));
  13965. cellCounter++;
  13966. if (cellCounter > controlCount) {
  13967. break;
  13968. }
  13969. }
  13970. }
  13971. }
  13972. cellCounter = 0;
  13973. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  13974. var child = _c[_b];
  13975. if (!child.mesh) {
  13976. continue;
  13977. }
  13978. this._mapGridNode(child, nodeGrid[cellCounter]);
  13979. cellCounter++;
  13980. }
  13981. this._finalProcessing();
  13982. };
  13983. /** Child classes can implement this function to provide additional processing */
  13984. VolumeBasedPanel.prototype._finalProcessing = function () {
  13985. };
  13986. return VolumeBasedPanel;
  13987. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  13988. /***/ }),
  13989. /***/ "./3D/gui3DManager.ts":
  13990. /*!****************************!*\
  13991. !*** ./3D/gui3DManager.ts ***!
  13992. \****************************/
  13993. /*! exports provided: GUI3DManager */
  13994. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13995. "use strict";
  13996. __webpack_require__.r(__webpack_exports__);
  13997. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  13998. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  13999. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  14000. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  14001. /**
  14002. * Class used to manage 3D user interface
  14003. * @see http://doc.babylonjs.com/how_to/gui3d
  14004. */
  14005. var GUI3DManager = /** @class */ (function () {
  14006. /**
  14007. * Creates a new GUI3DManager
  14008. * @param scene
  14009. */
  14010. function GUI3DManager(scene) {
  14011. var _this = this;
  14012. /** @hidden */
  14013. this._lastControlOver = {};
  14014. /** @hidden */
  14015. this._lastControlDown = {};
  14016. /**
  14017. * Observable raised when the point picked by the pointer events changed
  14018. */
  14019. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14020. // Shared resources
  14021. /** @hidden */
  14022. this._sharedMaterials = {};
  14023. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  14024. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  14025. _this._sceneDisposeObserver = null;
  14026. _this._utilityLayer = null;
  14027. _this.dispose();
  14028. });
  14029. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  14030. this._utilityLayer.onlyCheckPointerDownEvents = false;
  14031. this._utilityLayer.pickUtilitySceneFirst = false;
  14032. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  14033. return mesh && mesh.metadata && mesh.metadata._node;
  14034. };
  14035. // Root
  14036. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  14037. this._rootContainer._host = this;
  14038. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  14039. // Events
  14040. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  14041. _this._handlePointerOut(pointerId, true);
  14042. });
  14043. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  14044. _this._doPicking(pi);
  14045. });
  14046. // Scene
  14047. this._utilityLayer.utilityLayerScene.autoClear = false;
  14048. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  14049. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  14050. }
  14051. Object.defineProperty(GUI3DManager.prototype, "scene", {
  14052. /** Gets the hosting scene */
  14053. get: function () {
  14054. return this._scene;
  14055. },
  14056. enumerable: true,
  14057. configurable: true
  14058. });
  14059. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  14060. /** Gets associated utility layer */
  14061. get: function () {
  14062. return this._utilityLayer;
  14063. },
  14064. enumerable: true,
  14065. configurable: true
  14066. });
  14067. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  14068. var previousControlOver = this._lastControlOver[pointerId];
  14069. if (previousControlOver) {
  14070. previousControlOver._onPointerOut(previousControlOver);
  14071. delete this._lastControlOver[pointerId];
  14072. }
  14073. if (isPointerUp) {
  14074. if (this._lastControlDown[pointerId]) {
  14075. this._lastControlDown[pointerId].forcePointerUp();
  14076. delete this._lastControlDown[pointerId];
  14077. }
  14078. }
  14079. this.onPickedPointChangedObservable.notifyObservers(null);
  14080. };
  14081. GUI3DManager.prototype._doPicking = function (pi) {
  14082. if (!this._utilityLayer || !this._utilityLayer.utilityLayerScene.activeCamera) {
  14083. return false;
  14084. }
  14085. var pointerEvent = (pi.event);
  14086. var pointerId = pointerEvent.pointerId || 0;
  14087. var buttonIndex = pointerEvent.button;
  14088. var pickingInfo = pi.pickInfo;
  14089. if (!pickingInfo || !pickingInfo.hit) {
  14090. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  14091. return false;
  14092. }
  14093. var control = (pickingInfo.pickedMesh.metadata);
  14094. if (pickingInfo.pickedPoint) {
  14095. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  14096. }
  14097. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  14098. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  14099. if (this._lastControlOver[pointerId]) {
  14100. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  14101. }
  14102. delete this._lastControlOver[pointerId];
  14103. }
  14104. }
  14105. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  14106. if (this._lastControlDown[pointerEvent.pointerId]) {
  14107. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  14108. delete this._lastControlDown[pointerEvent.pointerId];
  14109. }
  14110. if (pointerEvent.pointerType === "touch") {
  14111. this._handlePointerOut(pointerId, false);
  14112. }
  14113. }
  14114. return true;
  14115. };
  14116. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  14117. /**
  14118. * Gets the root container
  14119. */
  14120. get: function () {
  14121. return this._rootContainer;
  14122. },
  14123. enumerable: true,
  14124. configurable: true
  14125. });
  14126. /**
  14127. * Gets a boolean indicating if the given control is in the root child list
  14128. * @param control defines the control to check
  14129. * @returns true if the control is in the root child list
  14130. */
  14131. GUI3DManager.prototype.containsControl = function (control) {
  14132. return this._rootContainer.containsControl(control);
  14133. };
  14134. /**
  14135. * Adds a control to the root child list
  14136. * @param control defines the control to add
  14137. * @returns the current manager
  14138. */
  14139. GUI3DManager.prototype.addControl = function (control) {
  14140. this._rootContainer.addControl(control);
  14141. return this;
  14142. };
  14143. /**
  14144. * Removes a control from the root child list
  14145. * @param control defines the control to remove
  14146. * @returns the current container
  14147. */
  14148. GUI3DManager.prototype.removeControl = function (control) {
  14149. this._rootContainer.removeControl(control);
  14150. return this;
  14151. };
  14152. /**
  14153. * Releases all associated resources
  14154. */
  14155. GUI3DManager.prototype.dispose = function () {
  14156. this._rootContainer.dispose();
  14157. for (var materialName in this._sharedMaterials) {
  14158. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  14159. continue;
  14160. }
  14161. this._sharedMaterials[materialName].dispose();
  14162. }
  14163. this._sharedMaterials = {};
  14164. if (this._pointerOutObserver && this._utilityLayer) {
  14165. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  14166. this._pointerOutObserver = null;
  14167. }
  14168. this.onPickedPointChangedObservable.clear();
  14169. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  14170. if (utilityLayerScene) {
  14171. if (this._pointerObserver) {
  14172. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  14173. this._pointerObserver = null;
  14174. }
  14175. }
  14176. if (this._scene) {
  14177. if (this._sceneDisposeObserver) {
  14178. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  14179. this._sceneDisposeObserver = null;
  14180. }
  14181. }
  14182. if (this._utilityLayer) {
  14183. this._utilityLayer.dispose();
  14184. }
  14185. };
  14186. return GUI3DManager;
  14187. }());
  14188. /***/ }),
  14189. /***/ "./3D/index.ts":
  14190. /*!*********************!*\
  14191. !*** ./3D/index.ts ***!
  14192. \*********************/
  14193. /*! exports provided: GUI3DManager, Vector3WithInfo, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  14194. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14195. "use strict";
  14196. __webpack_require__.r(__webpack_exports__);
  14197. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  14198. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14199. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  14200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  14201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  14202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  14203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  14204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  14205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  14206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  14207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  14208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  14209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  14210. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  14211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  14212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  14213. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  14214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  14215. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  14216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  14217. /***/ }),
  14218. /***/ "./3D/materials/fluentMaterial.ts":
  14219. /*!****************************************!*\
  14220. !*** ./3D/materials/fluentMaterial.ts ***!
  14221. \****************************************/
  14222. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  14223. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14224. "use strict";
  14225. __webpack_require__.r(__webpack_exports__);
  14226. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  14227. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  14228. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14229. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/observable");
  14230. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  14231. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  14232. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  14233. /** @hidden */
  14234. var FluentMaterialDefines = /** @class */ (function (_super) {
  14235. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FluentMaterialDefines, _super);
  14236. function FluentMaterialDefines() {
  14237. var _this = _super.call(this) || this;
  14238. _this.INNERGLOW = false;
  14239. _this.BORDER = false;
  14240. _this.HOVERLIGHT = false;
  14241. _this.TEXTURE = false;
  14242. _this.rebuild();
  14243. return _this;
  14244. }
  14245. return FluentMaterialDefines;
  14246. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  14247. /**
  14248. * Class used to render controls with fluent desgin
  14249. */
  14250. var FluentMaterial = /** @class */ (function (_super) {
  14251. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FluentMaterial, _super);
  14252. /**
  14253. * Creates a new Fluent material
  14254. * @param name defines the name of the material
  14255. * @param scene defines the hosting scene
  14256. */
  14257. function FluentMaterial(name, scene) {
  14258. var _this = _super.call(this, name, scene) || this;
  14259. /**
  14260. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  14261. */
  14262. _this.innerGlowColorIntensity = 0.5;
  14263. /**
  14264. * Gets or sets the inner glow color (white by default)
  14265. */
  14266. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  14267. /**
  14268. * Gets or sets alpha value (default is 1.0)
  14269. */
  14270. _this.alpha = 1.0;
  14271. /**
  14272. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  14273. */
  14274. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  14275. /**
  14276. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  14277. */
  14278. _this.renderBorders = false;
  14279. /**
  14280. * Gets or sets border width (default is 0.5)
  14281. */
  14282. _this.borderWidth = 0.5;
  14283. /**
  14284. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  14285. */
  14286. _this.edgeSmoothingValue = 0.02;
  14287. /**
  14288. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  14289. */
  14290. _this.borderMinValue = 0.1;
  14291. /**
  14292. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  14293. */
  14294. _this.renderHoverLight = false;
  14295. /**
  14296. * Gets or sets the radius used to render the hover light (default is 1.0)
  14297. */
  14298. _this.hoverRadius = 1.0;
  14299. /**
  14300. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  14301. */
  14302. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  14303. /**
  14304. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  14305. */
  14306. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  14307. return _this;
  14308. }
  14309. FluentMaterial.prototype.needAlphaBlending = function () {
  14310. return this.alpha !== 1.0;
  14311. };
  14312. FluentMaterial.prototype.needAlphaTesting = function () {
  14313. return false;
  14314. };
  14315. FluentMaterial.prototype.getAlphaTestTexture = function () {
  14316. return null;
  14317. };
  14318. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  14319. if (this.isFrozen) {
  14320. if (this._wasPreviouslyReady && subMesh.effect) {
  14321. return true;
  14322. }
  14323. }
  14324. if (!subMesh._materialDefines) {
  14325. subMesh._materialDefines = new FluentMaterialDefines();
  14326. }
  14327. var scene = this.getScene();
  14328. var defines = subMesh._materialDefines;
  14329. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  14330. if (defines._renderId === scene.getRenderId()) {
  14331. return true;
  14332. }
  14333. }
  14334. if (defines._areTexturesDirty) {
  14335. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  14336. defines.BORDER = this.renderBorders;
  14337. defines.HOVERLIGHT = this.renderHoverLight;
  14338. if (this._albedoTexture) {
  14339. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  14340. return false;
  14341. }
  14342. else {
  14343. defines.TEXTURE = true;
  14344. }
  14345. }
  14346. else {
  14347. defines.TEXTURE = false;
  14348. }
  14349. }
  14350. var engine = scene.getEngine();
  14351. // Get correct effect
  14352. if (defines.isDirty) {
  14353. defines.markAsProcessed();
  14354. scene.resetCachedMaterial();
  14355. //Attributes
  14356. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  14357. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  14358. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  14359. var shaderName = "fluent";
  14360. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  14361. "hoverColor", "hoverPosition", "hoverRadius"
  14362. ];
  14363. var samplers = ["albedoSampler"];
  14364. var uniformBuffers = new Array();
  14365. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  14366. uniformsNames: uniforms,
  14367. uniformBuffersNames: uniformBuffers,
  14368. samplers: samplers,
  14369. defines: defines,
  14370. maxSimultaneousLights: 4
  14371. });
  14372. var join = defines.toString();
  14373. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  14374. attributes: attribs,
  14375. uniformsNames: uniforms,
  14376. uniformBuffersNames: uniformBuffers,
  14377. samplers: samplers,
  14378. defines: join,
  14379. fallbacks: null,
  14380. onCompiled: this.onCompiled,
  14381. onError: this.onError,
  14382. indexParameters: { maxSimultaneousLights: 4 }
  14383. }, engine));
  14384. }
  14385. if (!subMesh.effect || !subMesh.effect.isReady()) {
  14386. return false;
  14387. }
  14388. defines._renderId = scene.getRenderId();
  14389. this._wasPreviouslyReady = true;
  14390. return true;
  14391. };
  14392. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  14393. var scene = this.getScene();
  14394. var defines = subMesh._materialDefines;
  14395. if (!defines) {
  14396. return;
  14397. }
  14398. var effect = subMesh.effect;
  14399. if (!effect) {
  14400. return;
  14401. }
  14402. this._activeEffect = effect;
  14403. // Matrices
  14404. this.bindOnlyWorldMatrix(world);
  14405. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  14406. if (this._mustRebind(scene, effect)) {
  14407. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  14408. if (defines.INNERGLOW) {
  14409. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  14410. }
  14411. if (defines.BORDER) {
  14412. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  14413. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  14414. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  14415. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0]);
  14416. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0]);
  14417. }
  14418. if (defines.HOVERLIGHT) {
  14419. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  14420. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  14421. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  14422. }
  14423. if (defines.TEXTURE) {
  14424. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  14425. }
  14426. }
  14427. this._afterBind(mesh, this._activeEffect);
  14428. };
  14429. FluentMaterial.prototype.getActiveTextures = function () {
  14430. var activeTextures = _super.prototype.getActiveTextures.call(this);
  14431. return activeTextures;
  14432. };
  14433. FluentMaterial.prototype.hasTexture = function (texture) {
  14434. if (_super.prototype.hasTexture.call(this, texture)) {
  14435. return true;
  14436. }
  14437. return false;
  14438. };
  14439. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  14440. _super.prototype.dispose.call(this, forceDisposeEffect);
  14441. };
  14442. FluentMaterial.prototype.clone = function (name) {
  14443. var _this = this;
  14444. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  14445. };
  14446. FluentMaterial.prototype.serialize = function () {
  14447. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  14448. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  14449. return serializationObject;
  14450. };
  14451. FluentMaterial.prototype.getClassName = function () {
  14452. return "FluentMaterial";
  14453. };
  14454. // Statics
  14455. FluentMaterial.Parse = function (source, scene, rootUrl) {
  14456. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  14457. };
  14458. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14459. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14460. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14461. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  14462. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14463. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  14464. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  14465. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14466. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14467. ], FluentMaterial.prototype, "alpha", void 0);
  14468. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14469. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  14470. ], FluentMaterial.prototype, "albedoColor", void 0);
  14471. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14472. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14473. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14474. ], FluentMaterial.prototype, "renderBorders", void 0);
  14475. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14476. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14477. ], FluentMaterial.prototype, "borderWidth", void 0);
  14478. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14479. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14480. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  14481. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14482. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14483. ], FluentMaterial.prototype, "borderMinValue", void 0);
  14484. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14485. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14486. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14487. ], FluentMaterial.prototype, "renderHoverLight", void 0);
  14488. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14489. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14490. ], FluentMaterial.prototype, "hoverRadius", void 0);
  14491. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14492. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  14493. ], FluentMaterial.prototype, "hoverColor", void 0);
  14494. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14495. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  14496. ], FluentMaterial.prototype, "hoverPosition", void 0);
  14497. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14498. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  14499. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  14500. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14501. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  14502. ], FluentMaterial.prototype, "albedoTexture", void 0);
  14503. return FluentMaterial;
  14504. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  14505. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  14506. /***/ }),
  14507. /***/ "./3D/materials/index.ts":
  14508. /*!*******************************!*\
  14509. !*** ./3D/materials/index.ts ***!
  14510. \*******************************/
  14511. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  14512. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14513. "use strict";
  14514. __webpack_require__.r(__webpack_exports__);
  14515. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  14516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  14517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  14518. /***/ }),
  14519. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  14520. /*!*************************************************!*\
  14521. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  14522. \*************************************************/
  14523. /*! exports provided: fluentPixelShader */
  14524. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14525. "use strict";
  14526. __webpack_require__.r(__webpack_exports__);
  14527. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  14528. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/observable");
  14529. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  14530. var name = 'fluentPixelShader';
  14531. var shader = "precision highp float;\nvarying vec2 vUV;\nuniform vec4 albedoColor;\n#ifdef INNERGLOW\nuniform vec4 innerGlowColor;\n#endif\n#ifdef BORDER\nvarying vec2 scaleInfo;\nuniform float edgeSmoothingValue;\nuniform float borderMinValue;\n#endif\n#ifdef HOVERLIGHT\nvarying vec3 worldPosition;\nuniform vec3 hoverPosition;\nuniform vec4 hoverColor;\nuniform float hoverRadius;\n#endif\n#ifdef TEXTURE\nuniform sampler2D albedoSampler;\n#endif\nvoid main(void) {\nvec3 albedo=albedoColor.rgb;\nfloat alpha=albedoColor.a;\n#ifdef TEXTURE\nalbedo=texture2D(albedoSampler,vUV).rgb;\n#endif\n#ifdef HOVERLIGHT\nfloat pointToHover=(1.0-clamp(length(hoverPosition-worldPosition)/hoverRadius,0.,1.))*hoverColor.a;\nalbedo=clamp(albedo+hoverColor.rgb*pointToHover,0.,1.);\n#else\nfloat pointToHover=1.0;\n#endif\n#ifdef BORDER\nfloat borderPower=10.0;\nfloat inverseBorderPower=1.0/borderPower;\nvec3 borderColor=albedo*borderPower;\nvec2 distanceToEdge;\ndistanceToEdge.x=abs(vUV.x-0.5)*2.0;\ndistanceToEdge.y=abs(vUV.y-0.5)*2.0;\nfloat borderValue=max(smoothstep(scaleInfo.x-edgeSmoothingValue,scaleInfo.x+edgeSmoothingValue,distanceToEdge.x),\nsmoothstep(scaleInfo.y-edgeSmoothingValue,scaleInfo.y+edgeSmoothingValue,distanceToEdge.y));\nborderColor=borderColor*borderValue*max(borderMinValue*inverseBorderPower,pointToHover);\nalbedo+=borderColor;\nalpha=max(alpha,borderValue);\n#endif\n#ifdef INNERGLOW\n\nvec2 uvGlow=(vUV-vec2(0.5,0.5))*(innerGlowColor.a*2.0);\nuvGlow=uvGlow*uvGlow;\nuvGlow=uvGlow*uvGlow;\nalbedo+=mix(vec3(0.0,0.0,0.0),innerGlowColor.rgb,uvGlow.x+uvGlow.y);\n#endif\ngl_FragColor=vec4(albedo,alpha);\n}";
  14532. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  14533. /** @hidden */
  14534. var fluentPixelShader = { name: name, shader: shader };
  14535. /***/ }),
  14536. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  14537. /*!***********************************************!*\
  14538. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  14539. \***********************************************/
  14540. /*! exports provided: fluentVertexShader */
  14541. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14542. "use strict";
  14543. __webpack_require__.r(__webpack_exports__);
  14544. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  14545. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/observable");
  14546. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  14547. var name = 'fluentVertexShader';
  14548. var shader = "precision highp float;\n\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n\nuniform mat4 world;\nuniform mat4 viewProjection;\nvarying vec2 vUV;\n#ifdef BORDER\nvarying vec2 scaleInfo;\nuniform float borderWidth;\nuniform vec3 scaleFactor;\n#endif\n#ifdef HOVERLIGHT\nvarying vec3 worldPosition;\n#endif\nvoid main(void) {\nvUV=uv;\n#ifdef BORDER\nvec3 scale=scaleFactor;\nfloat minScale=min(min(scale.x,scale.y),scale.z);\nfloat maxScale=max(max(scale.x,scale.y),scale.z);\nfloat minOverMiddleScale=minScale/(scale.x+scale.y+scale.z-minScale-maxScale);\nfloat areaYZ=scale.y*scale.z;\nfloat areaXZ=scale.x*scale.z;\nfloat areaXY=scale.x*scale.y;\nfloat scaledBorderWidth=borderWidth;\nif (abs(normal.x) == 1.0)\n{\nscale.x=scale.y;\nscale.y=scale.z;\nif (areaYZ>areaXZ && areaYZ>areaXY)\n{\nscaledBorderWidth*=minOverMiddleScale;\n}\n}\nelse if (abs(normal.y) == 1.0)\n{\nscale.x=scale.z;\nif (areaXZ>areaXY && areaXZ>areaYZ)\n{\nscaledBorderWidth*=minOverMiddleScale;\n}\n}\nelse\n{\nif (areaXY>areaYZ && areaXY>areaXZ)\n{\nscaledBorderWidth*=minOverMiddleScale;\n}\n}\nfloat scaleRatio=min(scale.x,scale.y)/max(scale.x,scale.y);\nif (scale.x>scale.y)\n{\nscaleInfo.x=1.0-(scaledBorderWidth*scaleRatio);\nscaleInfo.y=1.0-scaledBorderWidth;\n}\nelse\n{\nscaleInfo.x=1.0-scaledBorderWidth;\nscaleInfo.y=1.0-(scaledBorderWidth*scaleRatio);\n}\n#endif\nvec4 worldPos=world*vec4(position,1.0);\n#ifdef HOVERLIGHT\nworldPosition=worldPos.xyz;\n#endif\ngl_Position=viewProjection*worldPos;\n}\n";
  14549. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  14550. /** @hidden */
  14551. var fluentVertexShader = { name: name, shader: shader };
  14552. /***/ }),
  14553. /***/ "./3D/vector3WithInfo.ts":
  14554. /*!*******************************!*\
  14555. !*** ./3D/vector3WithInfo.ts ***!
  14556. \*******************************/
  14557. /*! exports provided: Vector3WithInfo */
  14558. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14559. "use strict";
  14560. __webpack_require__.r(__webpack_exports__);
  14561. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  14562. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14563. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  14564. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  14565. /**
  14566. * Class used to transport Vector3 information for pointer events
  14567. */
  14568. var Vector3WithInfo = /** @class */ (function (_super) {
  14569. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Vector3WithInfo, _super);
  14570. /**
  14571. * Creates a new Vector3WithInfo
  14572. * @param source defines the vector3 data to transport
  14573. * @param buttonIndex defines the current mouse button index
  14574. */
  14575. function Vector3WithInfo(source,
  14576. /** defines the current mouse button index */
  14577. buttonIndex) {
  14578. if (buttonIndex === void 0) { buttonIndex = 0; }
  14579. var _this = _super.call(this, source.x, source.y, source.z) || this;
  14580. _this.buttonIndex = buttonIndex;
  14581. return _this;
  14582. }
  14583. return Vector3WithInfo;
  14584. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  14585. /***/ }),
  14586. /***/ "./index.ts":
  14587. /*!******************!*\
  14588. !*** ./index.ts ***!
  14589. \******************/
  14590. /*! exports provided: AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, GUI3DManager, Vector3WithInfo, Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, name, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  14591. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14592. "use strict";
  14593. __webpack_require__.r(__webpack_exports__);
  14594. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  14595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  14596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  14597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  14598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  14599. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  14600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  14601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  14602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  14603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  14604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  14605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  14606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  14607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  14608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  14609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  14610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  14611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  14612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  14613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  14614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  14615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  14616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  14617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  14618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  14619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  14620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  14621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  14622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  14623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  14624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  14625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  14626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  14627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  14628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  14629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  14630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  14631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  14632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  14633. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  14634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  14635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  14636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  14637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  14638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  14639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  14640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  14641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  14642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  14643. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  14644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  14645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  14646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  14647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  14648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  14649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  14650. /***/ }),
  14651. /***/ "./legacy/legacy.ts":
  14652. /*!**************************!*\
  14653. !*** ./legacy/legacy.ts ***!
  14654. \**************************/
  14655. /*! exports provided: AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, GUI3DManager, Vector3WithInfo, Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, name, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  14656. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14657. "use strict";
  14658. __webpack_require__.r(__webpack_exports__);
  14659. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  14660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  14661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  14662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  14663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  14664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  14665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  14666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  14667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  14668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  14669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  14670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  14671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  14672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  14673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  14674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  14675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  14676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  14677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  14678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  14679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  14680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  14681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  14682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  14683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  14684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  14685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  14686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  14687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  14688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  14689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  14690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  14691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  14692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  14693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  14694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  14695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  14696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  14697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  14698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  14699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  14700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  14702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  14703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  14704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  14705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  14706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  14707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  14708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  14709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  14710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  14711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  14712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  14713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  14714. /**
  14715. * Legacy support, defining window.BABYLON.GUI (global variable).
  14716. *
  14717. * This is the entry point for the UMD module.
  14718. * The entry point for a future ESM package should be index.ts
  14719. */
  14720. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  14721. if (typeof globalObject !== "undefined") {
  14722. globalObject.BABYLON = globalObject.BABYLON || {};
  14723. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  14724. }
  14725. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  14726. /***/ }),
  14727. /***/ "babylonjs/Misc/observable":
  14728. /*!****************************************************************************************************!*\
  14729. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  14730. \****************************************************************************************************/
  14731. /*! no static exports found */
  14732. /***/ (function(module, exports) {
  14733. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_observable__;
  14734. /***/ })
  14735. /******/ });
  14736. });
  14737. //# sourceMappingURL=babylon.gui.js.map