babylon.gui.js 671 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508
  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. _this._clearRectangle = null;
  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 clearMinX left most position of the rectangle to clear in the texture
  832. * @param clearMinY top most position of the rectangle to clear in the texture
  833. * @param clearMaxX right most position of the rectangle to clear in the texture
  834. * @param clearMaxY bottom most position of the rectangle to clear in the texture
  835. * @param minX left most position of the rectangle to invalidate in absolute coordinates (not taking in account local transformation)
  836. * @param minY top most position of the rectangle to invalidate in absolute coordinates (not taking in account local transformation)
  837. * @param maxX right most position of the rectangle to invalidate in absolute coordinates (not taking in account local transformation)
  838. * @param maxY bottom most position of the rectangle to invalidate in absolute coordinates (not taking in account local transformation)
  839. */
  840. AdvancedDynamicTexture.prototype.invalidateRect = function (clearMinX, clearMinY, clearMaxX, clearMaxY, minX, minY, maxX, maxY) {
  841. if (!this._useInvalidateRectOptimization) {
  842. return;
  843. }
  844. if (!this._clearRectangle || !this._invalidatedRectangle) {
  845. this._clearRectangle = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](clearMinX, clearMinY, clearMaxX - clearMinX + 1, clearMaxY - clearMinY + 1);
  846. this._invalidatedRectangle = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](minX, minY, maxX - minX + 1, maxY - minY + 1);
  847. }
  848. else {
  849. // Compute intersection
  850. var maxX = Math.ceil(Math.max(this._clearRectangle.left + this._clearRectangle.width - 1, clearMaxX));
  851. var maxY = Math.ceil(Math.max(this._clearRectangle.top + this._clearRectangle.height - 1, clearMaxY));
  852. this._clearRectangle.left = Math.floor(Math.min(this._clearRectangle.left, clearMinX));
  853. this._clearRectangle.top = Math.floor(Math.min(this._clearRectangle.top, clearMinY));
  854. this._clearRectangle.width = maxX - this._clearRectangle.left + 1;
  855. this._clearRectangle.height = maxY - this._clearRectangle.top + 1;
  856. maxX = Math.max(this._invalidatedRectangle.left + this._invalidatedRectangle.width - 1, maxX);
  857. maxY = Math.max(this._invalidatedRectangle.top + this._invalidatedRectangle.height - 1, maxY);
  858. this._invalidatedRectangle.left = Math.min(this._invalidatedRectangle.left, minX);
  859. this._invalidatedRectangle.top = Math.min(this._invalidatedRectangle.top, minY);
  860. this._invalidatedRectangle.width = maxX - this._invalidatedRectangle.left + 1;
  861. this._invalidatedRectangle.height = maxY - this._invalidatedRectangle.top + 1;
  862. }
  863. };
  864. /**
  865. * Marks the texture as dirty forcing a complete update
  866. */
  867. AdvancedDynamicTexture.prototype.markAsDirty = function () {
  868. this._isDirty = true;
  869. };
  870. /**
  871. * Helper function used to create a new style
  872. * @returns a new style
  873. * @see http://doc.babylonjs.com/how_to/gui#styles
  874. */
  875. AdvancedDynamicTexture.prototype.createStyle = function () {
  876. return new _style__WEBPACK_IMPORTED_MODULE_3__["Style"](this);
  877. };
  878. /**
  879. * Adds a new control to the root container
  880. * @param control defines the control to add
  881. * @returns the current texture
  882. */
  883. AdvancedDynamicTexture.prototype.addControl = function (control) {
  884. this._rootContainer.addControl(control);
  885. return this;
  886. };
  887. /**
  888. * Removes a control from the root container
  889. * @param control defines the control to remove
  890. * @returns the current texture
  891. */
  892. AdvancedDynamicTexture.prototype.removeControl = function (control) {
  893. this._rootContainer.removeControl(control);
  894. return this;
  895. };
  896. /**
  897. * Release all resources
  898. */
  899. AdvancedDynamicTexture.prototype.dispose = function () {
  900. var scene = this.getScene();
  901. if (!scene) {
  902. return;
  903. }
  904. this._rootCanvas = null;
  905. scene.onBeforeCameraRenderObservable.remove(this._renderObserver);
  906. if (this._resizeObserver) {
  907. scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  908. }
  909. if (this._pointerMoveObserver) {
  910. scene.onPrePointerObservable.remove(this._pointerMoveObserver);
  911. }
  912. if (this._pointerObserver) {
  913. scene.onPointerObservable.remove(this._pointerObserver);
  914. }
  915. if (this._preKeyboardObserver) {
  916. scene.onPreKeyboardObservable.remove(this._preKeyboardObserver);
  917. }
  918. if (this._canvasPointerOutObserver) {
  919. scene.getEngine().onCanvasPointerOutObservable.remove(this._canvasPointerOutObserver);
  920. }
  921. if (this._layerToDispose) {
  922. this._layerToDispose.texture = null;
  923. this._layerToDispose.dispose();
  924. this._layerToDispose = null;
  925. }
  926. this._rootContainer.dispose();
  927. this.onClipboardObservable.clear();
  928. this.onControlPickedObservable.clear();
  929. this.onBeginRenderObservable.clear();
  930. this.onEndRenderObservable.clear();
  931. this.onBeginLayoutObservable.clear();
  932. this.onEndLayoutObservable.clear();
  933. _super.prototype.dispose.call(this);
  934. };
  935. AdvancedDynamicTexture.prototype._onResize = function () {
  936. var scene = this.getScene();
  937. if (!scene) {
  938. return;
  939. }
  940. // Check size
  941. var engine = scene.getEngine();
  942. var textureSize = this.getSize();
  943. var renderWidth = engine.getRenderWidth() * this._renderScale;
  944. var renderHeight = engine.getRenderHeight() * this._renderScale;
  945. if (this._renderAtIdealSize) {
  946. if (this._idealWidth) {
  947. renderHeight = (renderHeight * this._idealWidth) / renderWidth;
  948. renderWidth = this._idealWidth;
  949. }
  950. else if (this._idealHeight) {
  951. renderWidth = (renderWidth * this._idealHeight) / renderHeight;
  952. renderHeight = this._idealHeight;
  953. }
  954. }
  955. if (textureSize.width !== renderWidth || textureSize.height !== renderHeight) {
  956. this.scaleTo(renderWidth, renderHeight);
  957. this.markAsDirty();
  958. if (this._idealWidth || this._idealHeight) {
  959. this._rootContainer._markAllAsDirty();
  960. }
  961. }
  962. this.invalidateRect(0, 0, textureSize.width - 1, textureSize.height - 1, 0, 0, textureSize.width - 1, textureSize.height - 1);
  963. };
  964. /** @hidden */
  965. AdvancedDynamicTexture.prototype._getGlobalViewport = function (scene) {
  966. var engine = scene.getEngine();
  967. return this._fullscreenViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  968. };
  969. /**
  970. * Get screen coordinates for a vector3
  971. * @param position defines the position to project
  972. * @param worldMatrix defines the world matrix to use
  973. * @returns the projected position
  974. */
  975. AdvancedDynamicTexture.prototype.getProjectedPosition = function (position, worldMatrix) {
  976. var scene = this.getScene();
  977. if (!scene) {
  978. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  979. }
  980. var globalViewport = this._getGlobalViewport(scene);
  981. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, worldMatrix, scene.getTransformMatrix(), globalViewport);
  982. projectedPosition.scaleInPlace(this.renderScale);
  983. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"](projectedPosition.x, projectedPosition.y);
  984. };
  985. AdvancedDynamicTexture.prototype._checkUpdate = function (camera) {
  986. if (this._layerToDispose) {
  987. if ((camera.layerMask & this._layerToDispose.layerMask) === 0) {
  988. return;
  989. }
  990. }
  991. if (this._isFullscreen && this._linkedControls.length) {
  992. var scene = this.getScene();
  993. if (!scene) {
  994. return;
  995. }
  996. var globalViewport = this._getGlobalViewport(scene);
  997. for (var _i = 0, _a = this._linkedControls; _i < _a.length; _i++) {
  998. var control = _a[_i];
  999. if (!control.isVisible) {
  1000. continue;
  1001. }
  1002. var mesh = control._linkedMesh;
  1003. if (!mesh || mesh.isDisposed()) {
  1004. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  1005. control.linkWithMesh(null);
  1006. });
  1007. continue;
  1008. }
  1009. var position = mesh.getBoundingInfo().boundingSphere.center;
  1010. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, mesh.getWorldMatrix(), scene.getTransformMatrix(), globalViewport);
  1011. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  1012. control.notRenderable = true;
  1013. continue;
  1014. }
  1015. control.notRenderable = false;
  1016. // Account for RenderScale.
  1017. projectedPosition.scaleInPlace(this.renderScale);
  1018. control._moveToProjectedPosition(projectedPosition);
  1019. }
  1020. }
  1021. if (!this._isDirty && !this._rootContainer.isDirty) {
  1022. return;
  1023. }
  1024. this._isDirty = false;
  1025. this._render();
  1026. this.update(true, this.premulAlpha);
  1027. };
  1028. AdvancedDynamicTexture.prototype._render = function () {
  1029. var textureSize = this.getSize();
  1030. var renderWidth = textureSize.width;
  1031. var renderHeight = textureSize.height;
  1032. var context = this.getContext();
  1033. context.font = "18px Arial";
  1034. context.strokeStyle = "white";
  1035. // Layout
  1036. this.onBeginLayoutObservable.notifyObservers(this);
  1037. var measure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, renderWidth, renderHeight);
  1038. this._rootContainer._layout(measure, context);
  1039. this.onEndLayoutObservable.notifyObservers(this);
  1040. this._isDirty = false; // Restoring the dirty state that could have been set by controls during layout processing
  1041. // Clear
  1042. if (this._clearRectangle) {
  1043. this._clearMeasure.copyFrom(this._clearRectangle);
  1044. }
  1045. else {
  1046. this._clearMeasure.copyFromFloats(0, 0, renderWidth, renderHeight);
  1047. }
  1048. context.clearRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1049. if (this._background) {
  1050. context.save();
  1051. context.fillStyle = this._background;
  1052. context.fillRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1053. context.restore();
  1054. }
  1055. // Render
  1056. this.onBeginRenderObservable.notifyObservers(this);
  1057. this._rootContainer._render(context, this._invalidatedRectangle);
  1058. this.onEndRenderObservable.notifyObservers(this);
  1059. this._clearRectangle = null;
  1060. this._invalidatedRectangle = null;
  1061. };
  1062. /** @hidden */
  1063. AdvancedDynamicTexture.prototype._changeCursor = function (cursor) {
  1064. if (this._rootCanvas) {
  1065. this._rootCanvas.style.cursor = cursor;
  1066. }
  1067. };
  1068. /** @hidden */
  1069. AdvancedDynamicTexture.prototype._registerLastControlDown = function (control, pointerId) {
  1070. this._lastControlDown[pointerId] = control;
  1071. this.onControlPickedObservable.notifyObservers(control);
  1072. };
  1073. AdvancedDynamicTexture.prototype._doPicking = function (x, y, type, pointerId, buttonIndex) {
  1074. var scene = this.getScene();
  1075. if (!scene) {
  1076. return;
  1077. }
  1078. var engine = scene.getEngine();
  1079. var textureSize = this.getSize();
  1080. if (this._isFullscreen) {
  1081. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1082. var viewport = camera.viewport;
  1083. x = x * (textureSize.width / (engine.getRenderWidth() * viewport.width));
  1084. y = y * (textureSize.height / (engine.getRenderHeight() * viewport.height));
  1085. }
  1086. if (this._capturingControl[pointerId]) {
  1087. this._capturingControl[pointerId]._processObservables(type, x, y, pointerId, buttonIndex);
  1088. return;
  1089. }
  1090. if (!this._rootContainer._processPicking(x, y, type, pointerId, buttonIndex)) {
  1091. this._changeCursor("");
  1092. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1093. if (this._lastControlOver[pointerId]) {
  1094. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  1095. delete this._lastControlOver[pointerId];
  1096. }
  1097. }
  1098. }
  1099. this._manageFocus();
  1100. };
  1101. /** @hidden */
  1102. AdvancedDynamicTexture.prototype._cleanControlAfterRemovalFromList = function (list, control) {
  1103. for (var pointerId in list) {
  1104. if (!list.hasOwnProperty(pointerId)) {
  1105. continue;
  1106. }
  1107. var lastControlOver = list[pointerId];
  1108. if (lastControlOver === control) {
  1109. delete list[pointerId];
  1110. }
  1111. }
  1112. };
  1113. /** @hidden */
  1114. AdvancedDynamicTexture.prototype._cleanControlAfterRemoval = function (control) {
  1115. this._cleanControlAfterRemovalFromList(this._lastControlDown, control);
  1116. this._cleanControlAfterRemovalFromList(this._lastControlOver, control);
  1117. };
  1118. /** Attach to all scene events required to support pointer events */
  1119. AdvancedDynamicTexture.prototype.attach = function () {
  1120. var _this = this;
  1121. var scene = this.getScene();
  1122. if (!scene) {
  1123. return;
  1124. }
  1125. var tempViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0, 0);
  1126. this._pointerMoveObserver = scene.onPrePointerObservable.add(function (pi, state) {
  1127. if (scene.isPointerCaptured((pi.event).pointerId)) {
  1128. return;
  1129. }
  1130. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1131. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1132. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1133. return;
  1134. }
  1135. if (!scene) {
  1136. return;
  1137. }
  1138. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1139. var engine = scene.getEngine();
  1140. if (!camera) {
  1141. tempViewport.x = 0;
  1142. tempViewport.y = 0;
  1143. tempViewport.width = engine.getRenderWidth();
  1144. tempViewport.height = engine.getRenderHeight();
  1145. }
  1146. else {
  1147. camera.viewport.toGlobalToRef(engine.getRenderWidth(), engine.getRenderHeight(), tempViewport);
  1148. }
  1149. var x = scene.pointerX / engine.getHardwareScalingLevel() - tempViewport.x;
  1150. var y = scene.pointerY / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - tempViewport.y - tempViewport.height);
  1151. _this._shouldBlockPointer = false;
  1152. // Do picking modifies _shouldBlockPointer
  1153. _this._doPicking(x, y, pi.type, pi.event.pointerId || 0, pi.event.button);
  1154. // Avoid overwriting a true skipOnPointerObservable to false
  1155. if (_this._shouldBlockPointer) {
  1156. pi.skipOnPointerObservable = _this._shouldBlockPointer;
  1157. }
  1158. });
  1159. this._attachToOnPointerOut(scene);
  1160. };
  1161. /**
  1162. * Register the clipboard Events onto the canvas
  1163. */
  1164. AdvancedDynamicTexture.prototype.registerClipboardEvents = function () {
  1165. self.addEventListener("copy", this.onClipboardCopy, false);
  1166. self.addEventListener("cut", this.onClipboardCut, false);
  1167. self.addEventListener("paste", this.onClipboardPaste, false);
  1168. };
  1169. /**
  1170. * Unregister the clipboard Events from the canvas
  1171. */
  1172. AdvancedDynamicTexture.prototype.unRegisterClipboardEvents = function () {
  1173. self.removeEventListener("copy", this.onClipboardCopy);
  1174. self.removeEventListener("cut", this.onClipboardCut);
  1175. self.removeEventListener("paste", this.onClipboardPaste);
  1176. };
  1177. /**
  1178. * Connect the texture to a hosting mesh to enable interactions
  1179. * @param mesh defines the mesh to attach to
  1180. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  1181. */
  1182. AdvancedDynamicTexture.prototype.attachToMesh = function (mesh, supportPointerMove) {
  1183. var _this = this;
  1184. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1185. var scene = this.getScene();
  1186. if (!scene) {
  1187. return;
  1188. }
  1189. this._pointerObserver = scene.onPointerObservable.add(function (pi, state) {
  1190. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1191. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1192. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1193. return;
  1194. }
  1195. var pointerId = pi.event.pointerId || 0;
  1196. if (pi.pickInfo && pi.pickInfo.hit && pi.pickInfo.pickedMesh === mesh) {
  1197. var uv = pi.pickInfo.getTextureCoordinates();
  1198. if (uv) {
  1199. var size = _this.getSize();
  1200. _this._doPicking(uv.x * size.width, (1.0 - uv.y) * size.height, pi.type, pointerId, pi.event.button);
  1201. }
  1202. }
  1203. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  1204. if (_this._lastControlDown[pointerId]) {
  1205. _this._lastControlDown[pointerId]._forcePointerUp(pointerId);
  1206. }
  1207. delete _this._lastControlDown[pointerId];
  1208. if (_this.focusedControl) {
  1209. var friendlyControls = _this.focusedControl.keepsFocusWith();
  1210. var canMoveFocus = true;
  1211. if (friendlyControls) {
  1212. for (var _i = 0, friendlyControls_1 = friendlyControls; _i < friendlyControls_1.length; _i++) {
  1213. var control = friendlyControls_1[_i];
  1214. // Same host, no need to keep the focus
  1215. if (_this === control._host) {
  1216. continue;
  1217. }
  1218. // Different hosts
  1219. var otherHost = control._host;
  1220. if (otherHost._lastControlOver[pointerId] && otherHost._lastControlOver[pointerId].isAscendant(control)) {
  1221. canMoveFocus = false;
  1222. break;
  1223. }
  1224. }
  1225. }
  1226. if (canMoveFocus) {
  1227. _this.focusedControl = null;
  1228. }
  1229. }
  1230. }
  1231. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1232. if (_this._lastControlOver[pointerId]) {
  1233. _this._lastControlOver[pointerId]._onPointerOut(_this._lastControlOver[pointerId]);
  1234. }
  1235. delete _this._lastControlOver[pointerId];
  1236. }
  1237. });
  1238. mesh.enablePointerMoveEvents = supportPointerMove;
  1239. this._attachToOnPointerOut(scene);
  1240. };
  1241. /**
  1242. * Move the focus to a specific control
  1243. * @param control defines the control which will receive the focus
  1244. */
  1245. AdvancedDynamicTexture.prototype.moveFocusToControl = function (control) {
  1246. this.focusedControl = control;
  1247. this._lastPickedControl = control;
  1248. this._blockNextFocusCheck = true;
  1249. };
  1250. AdvancedDynamicTexture.prototype._manageFocus = function () {
  1251. if (this._blockNextFocusCheck) {
  1252. this._blockNextFocusCheck = false;
  1253. this._lastPickedControl = this._focusedControl;
  1254. return;
  1255. }
  1256. // Focus management
  1257. if (this._focusedControl) {
  1258. if (this._focusedControl !== this._lastPickedControl) {
  1259. if (this._lastPickedControl.isFocusInvisible) {
  1260. return;
  1261. }
  1262. this.focusedControl = null;
  1263. }
  1264. }
  1265. };
  1266. AdvancedDynamicTexture.prototype._attachToOnPointerOut = function (scene) {
  1267. var _this = this;
  1268. this._canvasPointerOutObserver = scene.getEngine().onCanvasPointerOutObservable.add(function (pointerEvent) {
  1269. if (_this._lastControlOver[pointerEvent.pointerId]) {
  1270. _this._lastControlOver[pointerEvent.pointerId]._onPointerOut(_this._lastControlOver[pointerEvent.pointerId]);
  1271. }
  1272. delete _this._lastControlOver[pointerEvent.pointerId];
  1273. if (_this._lastControlDown[pointerEvent.pointerId] && _this._lastControlDown[pointerEvent.pointerId] !== _this._capturingControl[pointerEvent.pointerId]) {
  1274. _this._lastControlDown[pointerEvent.pointerId]._forcePointerUp();
  1275. delete _this._lastControlDown[pointerEvent.pointerId];
  1276. }
  1277. });
  1278. };
  1279. // Statics
  1280. /**
  1281. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  1282. * @param mesh defines the mesh which will receive the texture
  1283. * @param width defines the texture width (1024 by default)
  1284. * @param height defines the texture height (1024 by default)
  1285. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  1286. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  1287. * @returns a new AdvancedDynamicTexture
  1288. */
  1289. AdvancedDynamicTexture.CreateForMesh = function (mesh, width, height, supportPointerMove, onlyAlphaTesting) {
  1290. if (width === void 0) { width = 1024; }
  1291. if (height === void 0) { height = 1024; }
  1292. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1293. if (onlyAlphaTesting === void 0) { onlyAlphaTesting = false; }
  1294. var result = new AdvancedDynamicTexture(mesh.name + " AdvancedDynamicTexture", width, height, mesh.getScene(), true, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE);
  1295. var material = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("AdvancedDynamicTextureMaterial", mesh.getScene());
  1296. material.backFaceCulling = false;
  1297. material.diffuseColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1298. material.specularColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1299. if (onlyAlphaTesting) {
  1300. material.diffuseTexture = result;
  1301. material.emissiveTexture = result;
  1302. result.hasAlpha = true;
  1303. }
  1304. else {
  1305. material.emissiveTexture = result;
  1306. material.opacityTexture = result;
  1307. }
  1308. mesh.material = material;
  1309. result.attachToMesh(mesh, supportPointerMove);
  1310. return result;
  1311. };
  1312. /**
  1313. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  1314. * In this mode the texture will rely on a layer for its rendering.
  1315. * This allows it to be treated like any other layer.
  1316. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  1317. * LayerMask is set through advancedTexture.layer.layerMask
  1318. * @param name defines name for the texture
  1319. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  1320. * @param scene defines the hsoting scene
  1321. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  1322. * @returns a new AdvancedDynamicTexture
  1323. */
  1324. AdvancedDynamicTexture.CreateFullscreenUI = function (name, foreground, scene, sampling) {
  1325. if (foreground === void 0) { foreground = true; }
  1326. if (scene === void 0) { scene = null; }
  1327. if (sampling === void 0) { sampling = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  1328. var result = new AdvancedDynamicTexture(name, 0, 0, scene, false, sampling);
  1329. // Display
  1330. var layer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Layer"](name + "_layer", null, scene, !foreground);
  1331. layer.texture = result;
  1332. result._layerToDispose = layer;
  1333. result._isFullscreen = true;
  1334. // Attach
  1335. result.attach();
  1336. return result;
  1337. };
  1338. return AdvancedDynamicTexture;
  1339. }(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["DynamicTexture"]));
  1340. /***/ }),
  1341. /***/ "./2D/controls/button.ts":
  1342. /*!*******************************!*\
  1343. !*** ./2D/controls/button.ts ***!
  1344. \*******************************/
  1345. /*! exports provided: Button */
  1346. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1347. "use strict";
  1348. __webpack_require__.r(__webpack_exports__);
  1349. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return Button; });
  1350. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1351. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1352. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1353. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1354. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  1355. /**
  1356. * Class used to create 2D buttons
  1357. */
  1358. var Button = /** @class */ (function (_super) {
  1359. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Button, _super);
  1360. /**
  1361. * Creates a new Button
  1362. * @param name defines the name of the button
  1363. */
  1364. function Button(name) {
  1365. var _this = _super.call(this, name) || this;
  1366. _this.name = name;
  1367. _this.thickness = 1;
  1368. _this.isPointerBlocker = true;
  1369. var alphaStore = null;
  1370. _this.pointerEnterAnimation = function () {
  1371. alphaStore = _this.alpha;
  1372. _this.alpha -= 0.1;
  1373. };
  1374. _this.pointerOutAnimation = function () {
  1375. if (alphaStore !== null) {
  1376. _this.alpha = alphaStore;
  1377. }
  1378. };
  1379. _this.pointerDownAnimation = function () {
  1380. _this.scaleX -= 0.05;
  1381. _this.scaleY -= 0.05;
  1382. };
  1383. _this.pointerUpAnimation = function () {
  1384. _this.scaleX += 0.05;
  1385. _this.scaleY += 0.05;
  1386. };
  1387. return _this;
  1388. }
  1389. Object.defineProperty(Button.prototype, "image", {
  1390. /**
  1391. * Returns the image part of the button (if any)
  1392. */
  1393. get: function () {
  1394. return this._image;
  1395. },
  1396. enumerable: true,
  1397. configurable: true
  1398. });
  1399. Object.defineProperty(Button.prototype, "textBlock", {
  1400. /**
  1401. * Returns the image part of the button (if any)
  1402. */
  1403. get: function () {
  1404. return this._textBlock;
  1405. },
  1406. enumerable: true,
  1407. configurable: true
  1408. });
  1409. Button.prototype._getTypeName = function () {
  1410. return "Button";
  1411. };
  1412. // While being a container, the button behaves like a control.
  1413. /** @hidden */
  1414. Button.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  1415. if (!this.isHitTestVisible || !this.isVisible || this.notRenderable) {
  1416. return false;
  1417. }
  1418. if (!_super.prototype.contains.call(this, x, y)) {
  1419. return false;
  1420. }
  1421. this._processObservables(type, x, y, pointerId, buttonIndex);
  1422. return true;
  1423. };
  1424. /** @hidden */
  1425. Button.prototype._onPointerEnter = function (target) {
  1426. if (!_super.prototype._onPointerEnter.call(this, target)) {
  1427. return false;
  1428. }
  1429. if (this.pointerEnterAnimation) {
  1430. this.pointerEnterAnimation();
  1431. }
  1432. return true;
  1433. };
  1434. /** @hidden */
  1435. Button.prototype._onPointerOut = function (target) {
  1436. if (this.pointerOutAnimation) {
  1437. this.pointerOutAnimation();
  1438. }
  1439. _super.prototype._onPointerOut.call(this, target);
  1440. };
  1441. /** @hidden */
  1442. Button.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1443. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1444. return false;
  1445. }
  1446. if (this.pointerDownAnimation) {
  1447. this.pointerDownAnimation();
  1448. }
  1449. return true;
  1450. };
  1451. /** @hidden */
  1452. Button.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  1453. if (this.pointerUpAnimation) {
  1454. this.pointerUpAnimation();
  1455. }
  1456. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  1457. };
  1458. // Statics
  1459. /**
  1460. * Creates a new button made with an image and a text
  1461. * @param name defines the name of the button
  1462. * @param text defines the text of the button
  1463. * @param imageUrl defines the url of the image
  1464. * @returns a new Button
  1465. */
  1466. Button.CreateImageButton = function (name, text, imageUrl) {
  1467. var result = new Button(name);
  1468. // Adding text
  1469. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1470. textBlock.textWrapping = true;
  1471. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1472. textBlock.paddingLeft = "20%";
  1473. result.addControl(textBlock);
  1474. // Adding image
  1475. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1476. iconImage.width = "20%";
  1477. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_UNIFORM;
  1478. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1479. result.addControl(iconImage);
  1480. // Store
  1481. result._image = iconImage;
  1482. result._textBlock = textBlock;
  1483. return result;
  1484. };
  1485. /**
  1486. * Creates a new button made with an image
  1487. * @param name defines the name of the button
  1488. * @param imageUrl defines the url of the image
  1489. * @returns a new Button
  1490. */
  1491. Button.CreateImageOnlyButton = function (name, imageUrl) {
  1492. var result = new Button(name);
  1493. // Adding image
  1494. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1495. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1496. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1497. result.addControl(iconImage);
  1498. // Store
  1499. result._image = iconImage;
  1500. return result;
  1501. };
  1502. /**
  1503. * Creates a new button made with a text
  1504. * @param name defines the name of the button
  1505. * @param text defines the text of the button
  1506. * @returns a new Button
  1507. */
  1508. Button.CreateSimpleButton = function (name, text) {
  1509. var result = new Button(name);
  1510. // Adding text
  1511. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1512. textBlock.textWrapping = true;
  1513. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1514. result.addControl(textBlock);
  1515. // Store
  1516. result._textBlock = textBlock;
  1517. return result;
  1518. };
  1519. /**
  1520. * Creates a new button made with an image and a centered text
  1521. * @param name defines the name of the button
  1522. * @param text defines the text of the button
  1523. * @param imageUrl defines the url of the image
  1524. * @returns a new Button
  1525. */
  1526. Button.CreateImageWithCenterTextButton = function (name, text, imageUrl) {
  1527. var result = new Button(name);
  1528. // Adding image
  1529. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1530. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1531. result.addControl(iconImage);
  1532. // Adding text
  1533. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1534. textBlock.textWrapping = true;
  1535. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1536. result.addControl(textBlock);
  1537. // Store
  1538. result._image = iconImage;
  1539. result._textBlock = textBlock;
  1540. return result;
  1541. };
  1542. return Button;
  1543. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  1544. /***/ }),
  1545. /***/ "./2D/controls/checkbox.ts":
  1546. /*!*********************************!*\
  1547. !*** ./2D/controls/checkbox.ts ***!
  1548. \*********************************/
  1549. /*! exports provided: Checkbox */
  1550. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1551. "use strict";
  1552. __webpack_require__.r(__webpack_exports__);
  1553. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return Checkbox; });
  1554. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1555. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  1556. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1557. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1558. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  1559. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1560. /**
  1561. * Class used to represent a 2D checkbox
  1562. */
  1563. var Checkbox = /** @class */ (function (_super) {
  1564. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Checkbox, _super);
  1565. /**
  1566. * Creates a new CheckBox
  1567. * @param name defines the control name
  1568. */
  1569. function Checkbox(name) {
  1570. var _this = _super.call(this, name) || this;
  1571. _this.name = name;
  1572. _this._isChecked = false;
  1573. _this._background = "black";
  1574. _this._checkSizeRatio = 0.8;
  1575. _this._thickness = 1;
  1576. /**
  1577. * Observable raised when isChecked property changes
  1578. */
  1579. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1580. _this.isPointerBlocker = true;
  1581. return _this;
  1582. }
  1583. Object.defineProperty(Checkbox.prototype, "thickness", {
  1584. /** Gets or sets border thickness */
  1585. get: function () {
  1586. return this._thickness;
  1587. },
  1588. set: function (value) {
  1589. if (this._thickness === value) {
  1590. return;
  1591. }
  1592. this._thickness = value;
  1593. this._markAsDirty();
  1594. },
  1595. enumerable: true,
  1596. configurable: true
  1597. });
  1598. Object.defineProperty(Checkbox.prototype, "checkSizeRatio", {
  1599. /** Gets or sets a value indicating the ratio between overall size and check size */
  1600. get: function () {
  1601. return this._checkSizeRatio;
  1602. },
  1603. set: function (value) {
  1604. value = Math.max(Math.min(1, value), 0);
  1605. if (this._checkSizeRatio === value) {
  1606. return;
  1607. }
  1608. this._checkSizeRatio = value;
  1609. this._markAsDirty();
  1610. },
  1611. enumerable: true,
  1612. configurable: true
  1613. });
  1614. Object.defineProperty(Checkbox.prototype, "background", {
  1615. /** Gets or sets background color */
  1616. get: function () {
  1617. return this._background;
  1618. },
  1619. set: function (value) {
  1620. if (this._background === value) {
  1621. return;
  1622. }
  1623. this._background = value;
  1624. this._markAsDirty();
  1625. },
  1626. enumerable: true,
  1627. configurable: true
  1628. });
  1629. Object.defineProperty(Checkbox.prototype, "isChecked", {
  1630. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1631. get: function () {
  1632. return this._isChecked;
  1633. },
  1634. set: function (value) {
  1635. if (this._isChecked === value) {
  1636. return;
  1637. }
  1638. this._isChecked = value;
  1639. this._markAsDirty();
  1640. this.onIsCheckedChangedObservable.notifyObservers(value);
  1641. },
  1642. enumerable: true,
  1643. configurable: true
  1644. });
  1645. Checkbox.prototype._getTypeName = function () {
  1646. return "Checkbox";
  1647. };
  1648. /** @hidden */
  1649. Checkbox.prototype._draw = function (context) {
  1650. context.save();
  1651. this._applyStates(context);
  1652. var actualWidth = this._currentMeasure.width - this._thickness;
  1653. var actualHeight = this._currentMeasure.height - this._thickness;
  1654. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1655. context.shadowColor = this.shadowColor;
  1656. context.shadowBlur = this.shadowBlur;
  1657. context.shadowOffsetX = this.shadowOffsetX;
  1658. context.shadowOffsetY = this.shadowOffsetY;
  1659. }
  1660. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  1661. context.fillRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1662. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1663. context.shadowBlur = 0;
  1664. context.shadowOffsetX = 0;
  1665. context.shadowOffsetY = 0;
  1666. }
  1667. if (this._isChecked) {
  1668. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  1669. var offsetWidth = actualWidth * this._checkSizeRatio;
  1670. var offseHeight = actualHeight * this._checkSizeRatio;
  1671. context.fillRect(this._currentMeasure.left + this._thickness / 2 + (actualWidth - offsetWidth) / 2, this._currentMeasure.top + this._thickness / 2 + (actualHeight - offseHeight) / 2, offsetWidth, offseHeight);
  1672. }
  1673. context.strokeStyle = this.color;
  1674. context.lineWidth = this._thickness;
  1675. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1676. context.restore();
  1677. };
  1678. // Events
  1679. /** @hidden */
  1680. Checkbox.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1681. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1682. return false;
  1683. }
  1684. this.isChecked = !this.isChecked;
  1685. return true;
  1686. };
  1687. /**
  1688. * Utility function to easily create a checkbox with a header
  1689. * @param title defines the label to use for the header
  1690. * @param onValueChanged defines the callback to call when value changes
  1691. * @returns a StackPanel containing the checkbox and a textBlock
  1692. */
  1693. Checkbox.AddCheckBoxWithHeader = function (title, onValueChanged) {
  1694. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  1695. panel.isVertical = false;
  1696. panel.height = "30px";
  1697. var checkbox = new Checkbox();
  1698. checkbox.width = "20px";
  1699. checkbox.height = "20px";
  1700. checkbox.isChecked = true;
  1701. checkbox.color = "green";
  1702. checkbox.onIsCheckedChangedObservable.add(onValueChanged);
  1703. panel.addControl(checkbox);
  1704. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  1705. header.text = title;
  1706. header.width = "180px";
  1707. header.paddingLeft = "5px";
  1708. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1709. header.color = "white";
  1710. panel.addControl(header);
  1711. return panel;
  1712. };
  1713. return Checkbox;
  1714. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  1715. /***/ }),
  1716. /***/ "./2D/controls/colorpicker.ts":
  1717. /*!************************************!*\
  1718. !*** ./2D/controls/colorpicker.ts ***!
  1719. \************************************/
  1720. /*! exports provided: ColorPicker */
  1721. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1722. "use strict";
  1723. __webpack_require__.r(__webpack_exports__);
  1724. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return ColorPicker; });
  1725. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1726. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  1727. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1728. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1729. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  1730. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1731. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  1732. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  1733. /* harmony import */ var _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../controls/textBlock */ "./2D/controls/textBlock.ts");
  1734. /** Class used to create color pickers */
  1735. var ColorPicker = /** @class */ (function (_super) {
  1736. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorPicker, _super);
  1737. /**
  1738. * Creates a new ColorPicker
  1739. * @param name defines the control name
  1740. */
  1741. function ColorPicker(name) {
  1742. var _this = _super.call(this, name) || this;
  1743. _this.name = name;
  1744. _this._value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  1745. _this._tmpColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]();
  1746. _this._pointerStartedOnSquare = false;
  1747. _this._pointerStartedOnWheel = false;
  1748. _this._squareLeft = 0;
  1749. _this._squareTop = 0;
  1750. _this._squareSize = 0;
  1751. _this._h = 360;
  1752. _this._s = 1;
  1753. _this._v = 1;
  1754. /**
  1755. * Observable raised when the value changes
  1756. */
  1757. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1758. // Events
  1759. _this._pointerIsDown = false;
  1760. _this.value = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](.88, .1, .1);
  1761. _this.size = "200px";
  1762. _this.isPointerBlocker = true;
  1763. return _this;
  1764. }
  1765. Object.defineProperty(ColorPicker.prototype, "value", {
  1766. /** Gets or sets the color of the color picker */
  1767. get: function () {
  1768. return this._value;
  1769. },
  1770. set: function (value) {
  1771. if (this._value.equals(value)) {
  1772. return;
  1773. }
  1774. this._value.copyFrom(value);
  1775. this._RGBtoHSV(this._value, this._tmpColor);
  1776. this._h = this._tmpColor.r;
  1777. this._s = Math.max(this._tmpColor.g, 0.00001);
  1778. this._v = Math.max(this._tmpColor.b, 0.00001);
  1779. this._markAsDirty();
  1780. if (this._value.r <= ColorPicker._Epsilon) {
  1781. this._value.r = 0;
  1782. }
  1783. if (this._value.g <= ColorPicker._Epsilon) {
  1784. this._value.g = 0;
  1785. }
  1786. if (this._value.b <= ColorPicker._Epsilon) {
  1787. this._value.b = 0;
  1788. }
  1789. if (this._value.r >= 1.0 - ColorPicker._Epsilon) {
  1790. this._value.r = 1.0;
  1791. }
  1792. if (this._value.g >= 1.0 - ColorPicker._Epsilon) {
  1793. this._value.g = 1.0;
  1794. }
  1795. if (this._value.b >= 1.0 - ColorPicker._Epsilon) {
  1796. this._value.b = 1.0;
  1797. }
  1798. this.onValueChangedObservable.notifyObservers(this._value);
  1799. },
  1800. enumerable: true,
  1801. configurable: true
  1802. });
  1803. Object.defineProperty(ColorPicker.prototype, "width", {
  1804. /**
  1805. * Gets or sets control width
  1806. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1807. */
  1808. get: function () {
  1809. return this._width.toString(this._host);
  1810. },
  1811. set: function (value) {
  1812. if (this._width.toString(this._host) === value) {
  1813. return;
  1814. }
  1815. if (this._width.fromString(value)) {
  1816. this._height.fromString(value);
  1817. this._markAsDirty();
  1818. }
  1819. },
  1820. enumerable: true,
  1821. configurable: true
  1822. });
  1823. Object.defineProperty(ColorPicker.prototype, "height", {
  1824. /**
  1825. * Gets or sets control height
  1826. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1827. */
  1828. get: function () {
  1829. return this._height.toString(this._host);
  1830. },
  1831. /** Gets or sets control height */
  1832. set: function (value) {
  1833. if (this._height.toString(this._host) === value) {
  1834. return;
  1835. }
  1836. if (this._height.fromString(value)) {
  1837. this._width.fromString(value);
  1838. this._markAsDirty();
  1839. }
  1840. },
  1841. enumerable: true,
  1842. configurable: true
  1843. });
  1844. Object.defineProperty(ColorPicker.prototype, "size", {
  1845. /** Gets or sets control size */
  1846. get: function () {
  1847. return this.width;
  1848. },
  1849. set: function (value) {
  1850. this.width = value;
  1851. },
  1852. enumerable: true,
  1853. configurable: true
  1854. });
  1855. ColorPicker.prototype._getTypeName = function () {
  1856. return "ColorPicker";
  1857. };
  1858. /** @hidden */
  1859. ColorPicker.prototype._preMeasure = function (parentMeasure, context) {
  1860. if (parentMeasure.width < parentMeasure.height) {
  1861. this._currentMeasure.height = parentMeasure.width;
  1862. }
  1863. else {
  1864. this._currentMeasure.width = parentMeasure.height;
  1865. }
  1866. };
  1867. ColorPicker.prototype._updateSquareProps = function () {
  1868. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1869. var wheelThickness = radius * .2;
  1870. var innerDiameter = (radius - wheelThickness) * 2;
  1871. var squareSize = innerDiameter / (Math.sqrt(2));
  1872. var offset = radius - squareSize * .5;
  1873. this._squareLeft = this._currentMeasure.left + offset;
  1874. this._squareTop = this._currentMeasure.top + offset;
  1875. this._squareSize = squareSize;
  1876. };
  1877. ColorPicker.prototype._drawGradientSquare = function (hueValue, left, top, width, height, context) {
  1878. var lgh = context.createLinearGradient(left, top, width + left, top);
  1879. lgh.addColorStop(0, '#fff');
  1880. lgh.addColorStop(1, 'hsl(' + hueValue + ', 100%, 50%)');
  1881. context.fillStyle = lgh;
  1882. context.fillRect(left, top, width, height);
  1883. var lgv = context.createLinearGradient(left, top, left, height + top);
  1884. lgv.addColorStop(0, 'rgba(0,0,0,0)');
  1885. lgv.addColorStop(1, '#000');
  1886. context.fillStyle = lgv;
  1887. context.fillRect(left, top, width, height);
  1888. };
  1889. ColorPicker.prototype._drawCircle = function (centerX, centerY, radius, context) {
  1890. context.beginPath();
  1891. context.arc(centerX, centerY, radius + 1, 0, 2 * Math.PI, false);
  1892. context.lineWidth = 3;
  1893. context.strokeStyle = '#333333';
  1894. context.stroke();
  1895. context.beginPath();
  1896. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  1897. context.lineWidth = 3;
  1898. context.strokeStyle = '#ffffff';
  1899. context.stroke();
  1900. };
  1901. ColorPicker.prototype._createColorWheelCanvas = function (radius, thickness) {
  1902. var canvas = document.createElement("canvas");
  1903. canvas.width = radius * 2;
  1904. canvas.height = radius * 2;
  1905. var context = canvas.getContext("2d");
  1906. var image = context.getImageData(0, 0, radius * 2, radius * 2);
  1907. var data = image.data;
  1908. var color = this._tmpColor;
  1909. var maxDistSq = radius * radius;
  1910. var innerRadius = radius - thickness;
  1911. var minDistSq = innerRadius * innerRadius;
  1912. for (var x = -radius; x < radius; x++) {
  1913. for (var y = -radius; y < radius; y++) {
  1914. var distSq = x * x + y * y;
  1915. if (distSq > maxDistSq || distSq < minDistSq) {
  1916. continue;
  1917. }
  1918. var dist = Math.sqrt(distSq);
  1919. var ang = Math.atan2(y, x);
  1920. this._HSVtoRGB(ang * 180 / Math.PI + 180, dist / radius, 1, color);
  1921. var index = ((x + radius) + ((y + radius) * 2 * radius)) * 4;
  1922. data[index] = color.r * 255;
  1923. data[index + 1] = color.g * 255;
  1924. data[index + 2] = color.b * 255;
  1925. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  1926. //apply less alpha to bigger color pickers
  1927. var alphaAmount = .2;
  1928. var maxAlpha = .2;
  1929. var minAlpha = .04;
  1930. var lowerRadius = 50;
  1931. var upperRadius = 150;
  1932. if (radius < lowerRadius) {
  1933. alphaAmount = maxAlpha;
  1934. }
  1935. else if (radius > upperRadius) {
  1936. alphaAmount = minAlpha;
  1937. }
  1938. else {
  1939. alphaAmount = (minAlpha - maxAlpha) * (radius - lowerRadius) / (upperRadius - lowerRadius) + maxAlpha;
  1940. }
  1941. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  1942. if (alphaRatio < alphaAmount) {
  1943. data[index + 3] = 255 * (alphaRatio / alphaAmount);
  1944. }
  1945. else if (alphaRatio > 1 - alphaAmount) {
  1946. data[index + 3] = 255 * (1.0 - ((alphaRatio - (1 - alphaAmount)) / alphaAmount));
  1947. }
  1948. else {
  1949. data[index + 3] = 255;
  1950. }
  1951. }
  1952. }
  1953. context.putImageData(image, 0, 0);
  1954. return canvas;
  1955. };
  1956. ColorPicker.prototype._RGBtoHSV = function (color, result) {
  1957. var r = color.r;
  1958. var g = color.g;
  1959. var b = color.b;
  1960. var max = Math.max(r, g, b);
  1961. var min = Math.min(r, g, b);
  1962. var h = 0;
  1963. var s = 0;
  1964. var v = max;
  1965. var dm = max - min;
  1966. if (max !== 0) {
  1967. s = dm / max;
  1968. }
  1969. if (max != min) {
  1970. if (max == r) {
  1971. h = (g - b) / dm;
  1972. if (g < b) {
  1973. h += 6;
  1974. }
  1975. }
  1976. else if (max == g) {
  1977. h = (b - r) / dm + 2;
  1978. }
  1979. else if (max == b) {
  1980. h = (r - g) / dm + 4;
  1981. }
  1982. h *= 60;
  1983. }
  1984. result.r = h;
  1985. result.g = s;
  1986. result.b = v;
  1987. };
  1988. ColorPicker.prototype._HSVtoRGB = function (hue, saturation, value, result) {
  1989. var chroma = value * saturation;
  1990. var h = hue / 60;
  1991. var x = chroma * (1 - Math.abs((h % 2) - 1));
  1992. var r = 0;
  1993. var g = 0;
  1994. var b = 0;
  1995. if (h >= 0 && h <= 1) {
  1996. r = chroma;
  1997. g = x;
  1998. }
  1999. else if (h >= 1 && h <= 2) {
  2000. r = x;
  2001. g = chroma;
  2002. }
  2003. else if (h >= 2 && h <= 3) {
  2004. g = chroma;
  2005. b = x;
  2006. }
  2007. else if (h >= 3 && h <= 4) {
  2008. g = x;
  2009. b = chroma;
  2010. }
  2011. else if (h >= 4 && h <= 5) {
  2012. r = x;
  2013. b = chroma;
  2014. }
  2015. else if (h >= 5 && h <= 6) {
  2016. r = chroma;
  2017. b = x;
  2018. }
  2019. var m = value - chroma;
  2020. result.set((r + m), (g + m), (b + m));
  2021. };
  2022. /** @hidden */
  2023. ColorPicker.prototype._draw = function (context) {
  2024. context.save();
  2025. this._applyStates(context);
  2026. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2027. var wheelThickness = radius * .2;
  2028. var left = this._currentMeasure.left;
  2029. var top = this._currentMeasure.top;
  2030. if (!this._colorWheelCanvas || this._colorWheelCanvas.width != radius * 2) {
  2031. this._colorWheelCanvas = this._createColorWheelCanvas(radius, wheelThickness);
  2032. }
  2033. this._updateSquareProps();
  2034. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2035. context.shadowColor = this.shadowColor;
  2036. context.shadowBlur = this.shadowBlur;
  2037. context.shadowOffsetX = this.shadowOffsetX;
  2038. context.shadowOffsetY = this.shadowOffsetY;
  2039. context.fillRect(this._squareLeft, this._squareTop, this._squareSize, this._squareSize);
  2040. }
  2041. context.drawImage(this._colorWheelCanvas, left, top);
  2042. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2043. context.shadowBlur = 0;
  2044. context.shadowOffsetX = 0;
  2045. context.shadowOffsetY = 0;
  2046. }
  2047. this._drawGradientSquare(this._h, this._squareLeft, this._squareTop, this._squareSize, this._squareSize, context);
  2048. var cx = this._squareLeft + this._squareSize * this._s;
  2049. var cy = this._squareTop + this._squareSize * (1 - this._v);
  2050. this._drawCircle(cx, cy, radius * .04, context);
  2051. var dist = radius - wheelThickness * .5;
  2052. cx = left + radius + Math.cos((this._h - 180) * Math.PI / 180) * dist;
  2053. cy = top + radius + Math.sin((this._h - 180) * Math.PI / 180) * dist;
  2054. this._drawCircle(cx, cy, wheelThickness * .35, context);
  2055. context.restore();
  2056. };
  2057. ColorPicker.prototype._updateValueFromPointer = function (x, y) {
  2058. if (this._pointerStartedOnWheel) {
  2059. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2060. var centerX = radius + this._currentMeasure.left;
  2061. var centerY = radius + this._currentMeasure.top;
  2062. this._h = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI + 180;
  2063. }
  2064. else if (this._pointerStartedOnSquare) {
  2065. this._updateSquareProps();
  2066. this._s = (x - this._squareLeft) / this._squareSize;
  2067. this._v = 1 - (y - this._squareTop) / this._squareSize;
  2068. this._s = Math.min(this._s, 1);
  2069. this._s = Math.max(this._s, ColorPicker._Epsilon);
  2070. this._v = Math.min(this._v, 1);
  2071. this._v = Math.max(this._v, ColorPicker._Epsilon);
  2072. }
  2073. this._HSVtoRGB(this._h, this._s, this._v, this._tmpColor);
  2074. this.value = this._tmpColor;
  2075. };
  2076. ColorPicker.prototype._isPointOnSquare = function (x, y) {
  2077. this._updateSquareProps();
  2078. var left = this._squareLeft;
  2079. var top = this._squareTop;
  2080. var size = this._squareSize;
  2081. if (x >= left && x <= left + size &&
  2082. y >= top && y <= top + size) {
  2083. return true;
  2084. }
  2085. return false;
  2086. };
  2087. ColorPicker.prototype._isPointOnWheel = function (x, y) {
  2088. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2089. var centerX = radius + this._currentMeasure.left;
  2090. var centerY = radius + this._currentMeasure.top;
  2091. var wheelThickness = radius * .2;
  2092. var innerRadius = radius - wheelThickness;
  2093. var radiusSq = radius * radius;
  2094. var innerRadiusSq = innerRadius * innerRadius;
  2095. var dx = x - centerX;
  2096. var dy = y - centerY;
  2097. var distSq = dx * dx + dy * dy;
  2098. if (distSq <= radiusSq && distSq >= innerRadiusSq) {
  2099. return true;
  2100. }
  2101. return false;
  2102. };
  2103. ColorPicker.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  2104. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  2105. return false;
  2106. }
  2107. this._pointerIsDown = true;
  2108. this._pointerStartedOnSquare = false;
  2109. this._pointerStartedOnWheel = false;
  2110. // Invert transform
  2111. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2112. var x = this._transformedPosition.x;
  2113. var y = this._transformedPosition.y;
  2114. if (this._isPointOnSquare(x, y)) {
  2115. this._pointerStartedOnSquare = true;
  2116. }
  2117. else if (this._isPointOnWheel(x, y)) {
  2118. this._pointerStartedOnWheel = true;
  2119. }
  2120. this._updateValueFromPointer(x, y);
  2121. this._host._capturingControl[pointerId] = this;
  2122. return true;
  2123. };
  2124. ColorPicker.prototype._onPointerMove = function (target, coordinates) {
  2125. // Invert transform
  2126. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2127. var x = this._transformedPosition.x;
  2128. var y = this._transformedPosition.y;
  2129. if (this._pointerIsDown) {
  2130. this._updateValueFromPointer(x, y);
  2131. }
  2132. _super.prototype._onPointerMove.call(this, target, coordinates);
  2133. };
  2134. ColorPicker.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  2135. this._pointerIsDown = false;
  2136. delete this._host._capturingControl[pointerId];
  2137. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  2138. };
  2139. /**
  2140. * This function expands the color picker by creating a color picker dialog with manual
  2141. * color value input and the ability to save colors into an array to be used later in
  2142. * subsequent launches of the dialogue.
  2143. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  2144. * @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.
  2145. * @returns picked color as a hex string and the saved colors array as hex strings.
  2146. */
  2147. ColorPicker.ShowPickerDialogAsync = function (advancedTexture, options) {
  2148. return new Promise(function (resolve, reject) {
  2149. // Default options
  2150. options.pickerWidth = options.pickerWidth || "640px";
  2151. options.pickerHeight = options.pickerHeight || "400px";
  2152. options.headerHeight = options.headerHeight || "35px";
  2153. options.lastColor = options.lastColor || "#000000";
  2154. options.swatchLimit = options.swatchLimit || 20;
  2155. options.numSwatchesPerLine = options.numSwatchesPerLine || 10;
  2156. // Window size settings
  2157. var drawerMaxRows = options.swatchLimit / options.numSwatchesPerLine;
  2158. var rawSwatchSize = parseFloat(options.pickerWidth) / options.numSwatchesPerLine;
  2159. var gutterSize = Math.floor(rawSwatchSize * 0.25);
  2160. var colGutters = gutterSize * (options.numSwatchesPerLine + 1);
  2161. var swatchSize = Math.floor((parseFloat(options.pickerWidth) - colGutters) / options.numSwatchesPerLine);
  2162. var drawerMaxSize = (swatchSize * drawerMaxRows) + (gutterSize * (drawerMaxRows + 1));
  2163. var containerSize = (parseInt(options.pickerHeight) + drawerMaxSize + Math.floor(swatchSize * 0.25)).toString() + "px";
  2164. // Button Colors
  2165. var buttonColor = "#c0c0c0";
  2166. var buttonBackgroundColor = "#535353";
  2167. var buttonBackgroundHoverColor = "#414141";
  2168. var buttonBackgroundClickColor = "515151";
  2169. var buttonDisabledColor = "#555555";
  2170. var buttonDisabledBackgroundColor = "#454545";
  2171. var currentSwatchesOutlineColor = "#404040";
  2172. var luminanceLimitColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString("#dddddd");
  2173. var luminanceLimit = luminanceLimitColor.r + luminanceLimitColor.g + luminanceLimitColor.b;
  2174. var iconColorDark = "#aaaaaa";
  2175. var iconColorLight = "#ffffff";
  2176. var closeIconColor;
  2177. // Button settings
  2178. var buttonFontSize;
  2179. var butEdit;
  2180. var buttonWidth;
  2181. var buttonHeight;
  2182. // Input Text Colors
  2183. var inputFieldLabels = ["R", "G", "B"];
  2184. var inputTextBackgroundColor = "#454545";
  2185. var inputTextColor = "#f0f0f0";
  2186. // This is the current color as set by either the picker or by entering a value
  2187. var currentColor;
  2188. // This int is used for naming swatches and serves as the index for calling them from the list
  2189. var swatchNumber;
  2190. // Menu Panel options. We need to know if the swatchDrawer exists so we can create it if needed.
  2191. var swatchDrawer;
  2192. var editSwatchMode = false;
  2193. // Color InputText fields that will be updated upon value change
  2194. var picker;
  2195. var rValInt;
  2196. var gValInt;
  2197. var bValInt;
  2198. var rValDec;
  2199. var gValDec;
  2200. var bValDec;
  2201. var hexVal;
  2202. var newSwatch;
  2203. var lastVal;
  2204. var activeField;
  2205. /**
  2206. * Will update all values for InputText and ColorPicker controls based on the BABYLON.Color3 passed to this function.
  2207. * Each InputText control and the ColorPicker control will be tested to see if they are the activeField and if they
  2208. * are will receive no update. This is to prevent the input from the user being overwritten.
  2209. */
  2210. function updateValues(value, inputField) {
  2211. activeField = inputField;
  2212. var pickedColor = value.toHexString();
  2213. newSwatch.background = pickedColor;
  2214. if (rValInt.name != activeField) {
  2215. rValInt.text = Math.floor(value.r * 255).toString();
  2216. }
  2217. if (gValInt.name != activeField) {
  2218. gValInt.text = Math.floor(value.g * 255).toString();
  2219. }
  2220. if (bValInt.name != activeField) {
  2221. bValInt.text = Math.floor(value.b * 255).toString();
  2222. }
  2223. if (rValDec.name != activeField) {
  2224. rValDec.text = value.r.toString();
  2225. }
  2226. if (gValDec.name != activeField) {
  2227. gValDec.text = value.g.toString();
  2228. }
  2229. if (bValDec.name != activeField) {
  2230. bValDec.text = value.b.toString();
  2231. }
  2232. if (hexVal.name != activeField) {
  2233. var minusPound = pickedColor.split("#");
  2234. hexVal.text = minusPound[1];
  2235. }
  2236. if (picker.name != activeField) {
  2237. picker.value = value;
  2238. }
  2239. }
  2240. // 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.
  2241. function updateInt(field, channel) {
  2242. var newValue = field.text;
  2243. var checkVal = /[^0-9]/g.test(newValue);
  2244. if (checkVal) {
  2245. field.text = lastVal;
  2246. return;
  2247. }
  2248. else {
  2249. if (newValue != "") {
  2250. if (Math.floor(parseInt(newValue)) < 0) {
  2251. newValue = "0";
  2252. }
  2253. else if (Math.floor(parseInt(newValue)) > 255) {
  2254. newValue = "255";
  2255. }
  2256. else if (isNaN(parseInt(newValue))) {
  2257. newValue = "0";
  2258. }
  2259. }
  2260. if (activeField == field.name) {
  2261. lastVal = newValue;
  2262. }
  2263. }
  2264. if (newValue != "") {
  2265. newValue = parseInt(newValue).toString();
  2266. field.text = newValue;
  2267. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2268. if (activeField == field.name) {
  2269. if (channel == "r") {
  2270. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]((parseInt(newValue)) / 255, newSwatchRGB.g, newSwatchRGB.b), field.name);
  2271. }
  2272. else if (channel == "g") {
  2273. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, (parseInt(newValue)) / 255, newSwatchRGB.b), field.name);
  2274. }
  2275. else {
  2276. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, (parseInt(newValue)) / 255), field.name);
  2277. }
  2278. }
  2279. }
  2280. }
  2281. // 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.
  2282. function updateFloat(field, channel) {
  2283. var newValue = field.text;
  2284. var checkVal = /[^0-9\.]/g.test(newValue);
  2285. if (checkVal) {
  2286. field.text = lastVal;
  2287. return;
  2288. }
  2289. else {
  2290. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2291. if (parseFloat(newValue) < 0.0) {
  2292. newValue = "0.0";
  2293. }
  2294. else if (parseFloat(newValue) > 1.0) {
  2295. newValue = "1.0";
  2296. }
  2297. else if (isNaN(parseFloat(newValue))) {
  2298. newValue = "0.0";
  2299. }
  2300. }
  2301. if (activeField == field.name) {
  2302. lastVal = newValue;
  2303. }
  2304. }
  2305. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2306. newValue = parseFloat(newValue).toString();
  2307. field.text = newValue;
  2308. }
  2309. else {
  2310. newValue = "0.0";
  2311. }
  2312. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2313. if (activeField == field.name) {
  2314. if (channel == "r") {
  2315. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](parseFloat(newValue), newSwatchRGB.g, newSwatchRGB.b), field.name);
  2316. }
  2317. else if (channel == "g") {
  2318. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, parseFloat(newValue), newSwatchRGB.b), field.name);
  2319. }
  2320. else {
  2321. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, parseFloat(newValue)), field.name);
  2322. }
  2323. }
  2324. }
  2325. // Removes the current index from the savedColors array. Drawer can then be regenerated.
  2326. function deleteSwatch(index) {
  2327. if (options.savedColors) {
  2328. options.savedColors.splice(index, 1);
  2329. }
  2330. if (options.savedColors && options.savedColors.length == 0) {
  2331. setEditButtonVisibility(false);
  2332. editSwatchMode = false;
  2333. }
  2334. }
  2335. // Creates and styles an individual swatch when updateSwatches is called.
  2336. function createSwatch() {
  2337. if (options.savedColors && options.savedColors[swatchNumber]) {
  2338. if (editSwatchMode) {
  2339. var icon = "b";
  2340. }
  2341. else {
  2342. var icon = "";
  2343. }
  2344. var swatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("Swatch_" + swatchNumber, icon);
  2345. swatch.fontFamily = "BabylonJSglyphs";
  2346. var swatchColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[swatchNumber]);
  2347. var swatchLuminence = swatchColor.r + swatchColor.g + swatchColor.b;
  2348. // Set color of outline and textBlock based on luminance of the color swatch so feedback always visible
  2349. if (swatchLuminence > luminanceLimit) {
  2350. swatch.color = iconColorDark;
  2351. }
  2352. else {
  2353. swatch.color = iconColorLight;
  2354. }
  2355. swatch.fontSize = Math.floor(swatchSize * 0.7);
  2356. swatch.textBlock.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2357. swatch.height = swatch.width = (swatchSize).toString() + "px";
  2358. swatch.background = options.savedColors[swatchNumber];
  2359. swatch.thickness = 2;
  2360. var metadata_1 = swatchNumber;
  2361. swatch.pointerDownAnimation = function () {
  2362. swatch.thickness = 4;
  2363. };
  2364. swatch.pointerUpAnimation = function () {
  2365. swatch.thickness = 3;
  2366. };
  2367. swatch.pointerEnterAnimation = function () {
  2368. swatch.thickness = 3;
  2369. };
  2370. swatch.pointerOutAnimation = function () {
  2371. swatch.thickness = 2;
  2372. };
  2373. swatch.onPointerClickObservable.add(function () {
  2374. if (!editSwatchMode) {
  2375. if (options.savedColors) {
  2376. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[metadata_1]), swatch.name);
  2377. }
  2378. }
  2379. else {
  2380. deleteSwatch(metadata_1);
  2381. updateSwatches("", butSave);
  2382. }
  2383. });
  2384. return swatch;
  2385. }
  2386. else {
  2387. return null;
  2388. }
  2389. }
  2390. // Mode switch to render button text and close symbols on swatch controls
  2391. function editSwatches(mode) {
  2392. if (mode !== undefined) {
  2393. editSwatchMode = mode;
  2394. }
  2395. if (editSwatchMode) {
  2396. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2397. var thisButton = swatchDrawer.children[i];
  2398. thisButton.textBlock.text = "b";
  2399. }
  2400. if (butEdit !== undefined) {
  2401. butEdit.textBlock.text = "Done";
  2402. }
  2403. }
  2404. else {
  2405. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2406. var thisButton = swatchDrawer.children[i];
  2407. thisButton.textBlock.text = "";
  2408. }
  2409. if (butEdit !== undefined) {
  2410. butEdit.textBlock.text = "Edit";
  2411. }
  2412. }
  2413. }
  2414. /**
  2415. * When Save Color button is pressed this function will first create a swatch drawer if one is not already
  2416. * made. Then all controls are removed from the drawer and we step through the savedColors array and
  2417. * creates one swatch per color. It will also set the height of the drawer control based on how many
  2418. * saved colors there are and how many can be stored per row.
  2419. */
  2420. function updateSwatches(color, button) {
  2421. if (options.savedColors) {
  2422. if (color != "") {
  2423. options.savedColors.push(color);
  2424. }
  2425. swatchNumber = 0;
  2426. swatchDrawer.clearControls();
  2427. var rowCount = Math.ceil(options.savedColors.length / options.numSwatchesPerLine);
  2428. if (rowCount == 0) {
  2429. var gutterCount = 0;
  2430. }
  2431. else {
  2432. var gutterCount = rowCount + 1;
  2433. }
  2434. if (swatchDrawer.rowCount != rowCount + gutterCount) {
  2435. var currentRows = swatchDrawer.rowCount;
  2436. for (var i = 0; i < currentRows; i++) {
  2437. swatchDrawer.removeRowDefinition(0);
  2438. }
  2439. for (var i = 0; i < rowCount + gutterCount; i++) {
  2440. if (i % 2) {
  2441. swatchDrawer.addRowDefinition(swatchSize, true);
  2442. }
  2443. else {
  2444. swatchDrawer.addRowDefinition(gutterSize, true);
  2445. }
  2446. }
  2447. }
  2448. swatchDrawer.height = ((swatchSize * rowCount) + (gutterCount * gutterSize)).toString() + "px";
  2449. for (var y = 1, thisRow = 1; y < rowCount + gutterCount; y += 2, thisRow++) {
  2450. // Determine number of buttons to create per row based on the button limit per row and number of saved colors
  2451. if (options.savedColors.length > thisRow * options.numSwatchesPerLine) {
  2452. var totalButtonsThisRow = options.numSwatchesPerLine;
  2453. }
  2454. else {
  2455. var totalButtonsThisRow = options.savedColors.length - ((thisRow - 1) * options.numSwatchesPerLine);
  2456. }
  2457. var buttonIterations = (Math.min(Math.max(totalButtonsThisRow, 0), options.numSwatchesPerLine));
  2458. for (var x = 0, w = 1; x < buttonIterations; x++) {
  2459. if (x > options.numSwatchesPerLine) {
  2460. continue;
  2461. }
  2462. var swatch = createSwatch();
  2463. if (swatch != null) {
  2464. swatchDrawer.addControl(swatch, y, w);
  2465. w += 2;
  2466. swatchNumber++;
  2467. }
  2468. else {
  2469. continue;
  2470. }
  2471. }
  2472. }
  2473. if (options.savedColors.length >= options.swatchLimit) {
  2474. disableButton(button, true);
  2475. }
  2476. else {
  2477. disableButton(button, false);
  2478. }
  2479. }
  2480. }
  2481. // Shows or hides edit swatches button depending on if there are saved swatches
  2482. function setEditButtonVisibility(enableButton) {
  2483. if (enableButton) {
  2484. butEdit = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butEdit", "Edit");
  2485. butEdit.width = buttonWidth;
  2486. butEdit.height = buttonHeight;
  2487. butEdit.left = (Math.floor(parseInt(buttonWidth) * 0.1)).toString() + "px";
  2488. butEdit.top = (parseFloat(butEdit.left) * -1).toString() + "px";
  2489. butEdit.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_BOTTOM;
  2490. butEdit.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2491. butEdit.thickness = 2;
  2492. butEdit.color = buttonColor;
  2493. butEdit.fontSize = buttonFontSize;
  2494. butEdit.background = buttonBackgroundColor;
  2495. butEdit.onPointerEnterObservable.add(function () {
  2496. butEdit.background = buttonBackgroundHoverColor;
  2497. });
  2498. butEdit.onPointerOutObservable.add(function () {
  2499. butEdit.background = buttonBackgroundColor;
  2500. });
  2501. butEdit.pointerDownAnimation = function () {
  2502. butEdit.background = buttonBackgroundClickColor;
  2503. };
  2504. butEdit.pointerUpAnimation = function () {
  2505. butEdit.background = buttonBackgroundHoverColor;
  2506. };
  2507. butEdit.onPointerClickObservable.add(function () {
  2508. if (editSwatchMode) {
  2509. editSwatchMode = false;
  2510. }
  2511. else {
  2512. editSwatchMode = true;
  2513. }
  2514. editSwatches();
  2515. });
  2516. pickerGrid.addControl(butEdit, 1, 0);
  2517. }
  2518. else {
  2519. pickerGrid.removeControl(butEdit);
  2520. }
  2521. }
  2522. // Called when the user hits the limit of saved colors in the drawer.
  2523. function disableButton(button, disabled) {
  2524. if (disabled) {
  2525. button.color = buttonDisabledColor;
  2526. button.background = buttonDisabledBackgroundColor;
  2527. }
  2528. else {
  2529. button.color = buttonColor;
  2530. button.background = buttonBackgroundColor;
  2531. }
  2532. }
  2533. // Passes last chosen color back to scene and kills dialog by removing from AdvancedDynamicTexture
  2534. function closePicker(color) {
  2535. if (options.savedColors && options.savedColors.length > 0) {
  2536. resolve({
  2537. savedColors: options.savedColors,
  2538. pickedColor: color
  2539. });
  2540. }
  2541. else {
  2542. resolve({
  2543. pickedColor: color
  2544. });
  2545. }
  2546. advancedTexture.removeControl(dialogContainer);
  2547. }
  2548. // Dialogue menu container which will contain both the main dialogue window and the swatch drawer which opens once a color is saved.
  2549. var dialogContainer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2550. dialogContainer.name = "Dialog Container";
  2551. dialogContainer.width = options.pickerWidth;
  2552. if (options.savedColors) {
  2553. dialogContainer.height = containerSize;
  2554. var topRow = parseInt(options.pickerHeight) / parseInt(containerSize);
  2555. dialogContainer.addRowDefinition(topRow, false);
  2556. dialogContainer.addRowDefinition(1.0 - topRow, false);
  2557. }
  2558. else {
  2559. dialogContainer.height = options.pickerHeight;
  2560. dialogContainer.addRowDefinition(1.0, false);
  2561. }
  2562. advancedTexture.addControl(dialogContainer);
  2563. // Swatch drawer which contains all saved color buttons
  2564. if (options.savedColors) {
  2565. swatchDrawer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2566. swatchDrawer.name = "Swatch Drawer";
  2567. swatchDrawer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  2568. swatchDrawer.background = buttonBackgroundColor;
  2569. swatchDrawer.width = options.pickerWidth;
  2570. var initialRows = options.savedColors.length / options.numSwatchesPerLine;
  2571. if (initialRows == 0) {
  2572. var gutterCount = 0;
  2573. }
  2574. else {
  2575. var gutterCount = initialRows + 1;
  2576. }
  2577. swatchDrawer.height = ((swatchSize * initialRows) + (gutterCount * gutterSize)).toString() + "px";
  2578. swatchDrawer.top = Math.floor(swatchSize * 0.25).toString() + "px";
  2579. for (var i = 0; i < (Math.ceil(options.savedColors.length / options.numSwatchesPerLine) * 2) + 1; i++) {
  2580. if (i % 2 != 0) {
  2581. swatchDrawer.addRowDefinition(swatchSize, true);
  2582. }
  2583. else {
  2584. swatchDrawer.addRowDefinition(gutterSize, true);
  2585. }
  2586. }
  2587. for (var i = 0; i < options.numSwatchesPerLine * 2 + 1; i++) {
  2588. if (i % 2 != 0) {
  2589. swatchDrawer.addColumnDefinition(swatchSize, true);
  2590. }
  2591. else {
  2592. swatchDrawer.addColumnDefinition(gutterSize, true);
  2593. }
  2594. }
  2595. dialogContainer.addControl(swatchDrawer, 1, 0);
  2596. }
  2597. // Picker container
  2598. var pickerPanel = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2599. pickerPanel.name = "Picker Panel";
  2600. pickerPanel.height = options.pickerHeight;
  2601. var panelHead = parseInt(options.headerHeight) / parseInt(options.pickerHeight);
  2602. var pickerPanelRows = [panelHead, 1.0 - panelHead];
  2603. pickerPanel.addRowDefinition(pickerPanelRows[0], false);
  2604. pickerPanel.addRowDefinition(pickerPanelRows[1], false);
  2605. dialogContainer.addControl(pickerPanel, 0, 0);
  2606. // Picker container header
  2607. var header = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2608. header.name = "Dialogue Header Bar";
  2609. header.background = "#cccccc";
  2610. header.thickness = 0;
  2611. pickerPanel.addControl(header, 0, 0);
  2612. // Header close button
  2613. var closeButton = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("closeButton", "a");
  2614. closeButton.fontFamily = "BabylonJSglyphs";
  2615. var headerColor3 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(header.background);
  2616. closeIconColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0 - headerColor3.r, 1.0 - headerColor3.g, 1.0 - headerColor3.b);
  2617. closeButton.color = closeIconColor.toHexString();
  2618. closeButton.fontSize = Math.floor(parseInt(options.headerHeight) * 0.6);
  2619. closeButton.textBlock.textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2620. closeButton.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_RIGHT;
  2621. closeButton.height = closeButton.width = options.headerHeight;
  2622. closeButton.background = header.background;
  2623. closeButton.thickness = 0;
  2624. closeButton.pointerDownAnimation = function () {
  2625. };
  2626. closeButton.pointerUpAnimation = function () {
  2627. closeButton.background = header.background;
  2628. };
  2629. closeButton.pointerEnterAnimation = function () {
  2630. closeButton.color = header.background;
  2631. closeButton.background = "red";
  2632. };
  2633. closeButton.pointerOutAnimation = function () {
  2634. closeButton.color = closeIconColor.toHexString();
  2635. closeButton.background = header.background;
  2636. };
  2637. closeButton.onPointerClickObservable.add(function () {
  2638. closePicker(currentSwatch.background);
  2639. });
  2640. pickerPanel.addControl(closeButton, 0, 0);
  2641. // Dialog container body
  2642. var dialogBody = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2643. dialogBody.name = "Dialogue Body";
  2644. dialogBody.background = buttonBackgroundColor;
  2645. var dialogBodyCols = [0.4375, 0.5625];
  2646. dialogBody.addRowDefinition(1.0, false);
  2647. dialogBody.addColumnDefinition(dialogBodyCols[0], false);
  2648. dialogBody.addColumnDefinition(dialogBodyCols[1], false);
  2649. pickerPanel.addControl(dialogBody, 1, 0);
  2650. // Picker grid
  2651. var pickerGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2652. pickerGrid.name = "Picker Grid";
  2653. pickerGrid.addRowDefinition(0.85, false);
  2654. pickerGrid.addRowDefinition(0.15, false);
  2655. dialogBody.addControl(pickerGrid, 0, 0);
  2656. // Picker control
  2657. picker = new ColorPicker();
  2658. picker.name = "GUI Color Picker";
  2659. if (options.pickerHeight < options.pickerWidth) {
  2660. picker.width = 0.89;
  2661. }
  2662. else {
  2663. picker.height = 0.89;
  2664. }
  2665. picker.value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2666. picker.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  2667. picker.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2668. picker.onPointerDownObservable.add(function () {
  2669. activeField = picker.name;
  2670. lastVal = "";
  2671. editSwatches(false);
  2672. });
  2673. picker.onValueChangedObservable.add(function (value) {
  2674. if (activeField == picker.name) {
  2675. updateValues(value, picker.name);
  2676. }
  2677. });
  2678. pickerGrid.addControl(picker, 0, 0);
  2679. // Picker body right quarant
  2680. var pickerBodyRight = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2681. pickerBodyRight.name = "Dialogue Right Half";
  2682. pickerBodyRight.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2683. var pickerBodyRightRows = [0.514, 0.486];
  2684. pickerBodyRight.addRowDefinition(pickerBodyRightRows[0], false);
  2685. pickerBodyRight.addRowDefinition(pickerBodyRightRows[1], false);
  2686. dialogBody.addControl(pickerBodyRight, 1, 1);
  2687. // Picker container swatches and buttons
  2688. var pickerSwatchesButtons = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2689. pickerSwatchesButtons.name = "Swatches and Buttons";
  2690. var pickerButtonsCol = [0.417, 0.583];
  2691. pickerSwatchesButtons.addRowDefinition(1.0, false);
  2692. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[0], false);
  2693. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[1], false);
  2694. pickerBodyRight.addControl(pickerSwatchesButtons, 0, 0);
  2695. // Picker Swatches quadrant
  2696. var pickerSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2697. pickerSwatches.name = "New and Current Swatches";
  2698. var pickeSwatchesRows = [0.04, 0.16, 0.64, 0.16];
  2699. pickerSwatches.addRowDefinition(pickeSwatchesRows[0], false);
  2700. pickerSwatches.addRowDefinition(pickeSwatchesRows[1], false);
  2701. pickerSwatches.addRowDefinition(pickeSwatchesRows[2], false);
  2702. pickerSwatches.addRowDefinition(pickeSwatchesRows[3], false);
  2703. pickerSwatchesButtons.addControl(pickerSwatches, 0, 0);
  2704. // Active swatches
  2705. var activeSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2706. activeSwatches.name = "Active Swatches";
  2707. activeSwatches.width = 0.67;
  2708. activeSwatches.addRowDefinition(0.5, false);
  2709. activeSwatches.addRowDefinition(0.5, false);
  2710. pickerSwatches.addControl(activeSwatches, 2, 0);
  2711. var labelWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[0] * 0.11));
  2712. var labelHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * pickeSwatchesRows[1] * 0.5));
  2713. if (options.pickerWidth > options.pickerHeight) {
  2714. var labelTextSize = labelHeight;
  2715. }
  2716. else {
  2717. var labelTextSize = labelWidth;
  2718. }
  2719. // New color swatch and previous color button
  2720. var newText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2721. newText.text = "new";
  2722. newText.name = "New Color Label";
  2723. newText.color = buttonColor;
  2724. newText.fontSize = labelTextSize;
  2725. pickerSwatches.addControl(newText, 1, 0);
  2726. newSwatch = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2727. newSwatch.name = "New Color Swatch";
  2728. newSwatch.background = options.lastColor;
  2729. newSwatch.thickness = 0;
  2730. activeSwatches.addControl(newSwatch, 0, 0);
  2731. var currentSwatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("currentSwatch", "");
  2732. currentSwatch.background = options.lastColor;
  2733. currentSwatch.thickness = 0;
  2734. currentSwatch.onPointerClickObservable.add(function () {
  2735. var revertColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(currentSwatch.background);
  2736. updateValues(revertColor, currentSwatch.name);
  2737. editSwatches(false);
  2738. });
  2739. currentSwatch.pointerDownAnimation = function () { };
  2740. currentSwatch.pointerUpAnimation = function () { };
  2741. currentSwatch.pointerEnterAnimation = function () { };
  2742. currentSwatch.pointerOutAnimation = function () { };
  2743. activeSwatches.addControl(currentSwatch, 1, 0);
  2744. var swatchOutline = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2745. swatchOutline.name = "Swatch Outline";
  2746. swatchOutline.width = 0.67;
  2747. swatchOutline.thickness = 2;
  2748. swatchOutline.color = currentSwatchesOutlineColor;
  2749. swatchOutline.isHitTestVisible = false;
  2750. pickerSwatches.addControl(swatchOutline, 2, 0);
  2751. var currentText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2752. currentText.name = "Current Color Label";
  2753. currentText.text = "current";
  2754. currentText.color = buttonColor;
  2755. currentText.fontSize = labelTextSize;
  2756. pickerSwatches.addControl(currentText, 3, 0);
  2757. // Buttons grid
  2758. var buttonGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2759. buttonGrid.name = "Button Grid";
  2760. buttonGrid.height = 0.8;
  2761. var buttonGridRows = 1 / 3;
  2762. buttonGrid.addRowDefinition(buttonGridRows, false);
  2763. buttonGrid.addRowDefinition(buttonGridRows, false);
  2764. buttonGrid.addRowDefinition(buttonGridRows, false);
  2765. pickerSwatchesButtons.addControl(buttonGrid, 0, 1);
  2766. // Determine pixel width and height for all buttons from overall panel dimensions
  2767. buttonWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[1] * 0.67)).toString() + "px";
  2768. buttonHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * (parseFloat(buttonGrid.height.toString()) / 100) * buttonGridRows * 0.7)).toString() + "px";
  2769. // Determine button type size
  2770. if (parseFloat(buttonWidth) > parseFloat(buttonHeight)) {
  2771. buttonFontSize = Math.floor(parseFloat(buttonHeight) * 0.45);
  2772. }
  2773. else {
  2774. buttonFontSize = Math.floor(parseFloat(buttonWidth) * 0.11);
  2775. }
  2776. // Panel Buttons
  2777. var butOK = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butOK", "OK");
  2778. butOK.width = buttonWidth;
  2779. butOK.height = buttonHeight;
  2780. butOK.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2781. butOK.thickness = 2;
  2782. butOK.color = buttonColor;
  2783. butOK.fontSize = buttonFontSize;
  2784. butOK.background = buttonBackgroundColor;
  2785. butOK.onPointerEnterObservable.add(function () { butOK.background = buttonBackgroundHoverColor; });
  2786. butOK.onPointerOutObservable.add(function () { butOK.background = buttonBackgroundColor; });
  2787. butOK.pointerDownAnimation = function () {
  2788. butOK.background = buttonBackgroundClickColor;
  2789. };
  2790. butOK.pointerUpAnimation = function () {
  2791. butOK.background = buttonBackgroundHoverColor;
  2792. };
  2793. butOK.onPointerClickObservable.add(function () {
  2794. editSwatches(false);
  2795. closePicker(newSwatch.background);
  2796. });
  2797. buttonGrid.addControl(butOK, 0, 0);
  2798. var butCancel = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butCancel", "Cancel");
  2799. butCancel.width = buttonWidth;
  2800. butCancel.height = buttonHeight;
  2801. butCancel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2802. butCancel.thickness = 2;
  2803. butCancel.color = buttonColor;
  2804. butCancel.fontSize = buttonFontSize;
  2805. butCancel.background = buttonBackgroundColor;
  2806. butCancel.onPointerEnterObservable.add(function () { butCancel.background = buttonBackgroundHoverColor; });
  2807. butCancel.onPointerOutObservable.add(function () { butCancel.background = buttonBackgroundColor; });
  2808. butCancel.pointerDownAnimation = function () {
  2809. butCancel.background = buttonBackgroundClickColor;
  2810. };
  2811. butCancel.pointerUpAnimation = function () {
  2812. butCancel.background = buttonBackgroundHoverColor;
  2813. };
  2814. butCancel.onPointerClickObservable.add(function () {
  2815. editSwatches(false);
  2816. closePicker(currentSwatch.background);
  2817. });
  2818. buttonGrid.addControl(butCancel, 1, 0);
  2819. if (options.savedColors) {
  2820. var butSave = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butSave", "Save");
  2821. butSave.width = buttonWidth;
  2822. butSave.height = buttonHeight;
  2823. butSave.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2824. butSave.thickness = 2;
  2825. butSave.fontSize = buttonFontSize;
  2826. if (options.savedColors.length < options.swatchLimit) {
  2827. butSave.color = buttonColor;
  2828. butSave.background = buttonBackgroundColor;
  2829. }
  2830. else {
  2831. disableButton(butSave, true);
  2832. }
  2833. butSave.onPointerEnterObservable.add(function () {
  2834. if (options.savedColors) {
  2835. if (options.savedColors.length < options.swatchLimit) {
  2836. butSave.background = buttonBackgroundHoverColor;
  2837. }
  2838. }
  2839. });
  2840. butSave.onPointerOutObservable.add(function () {
  2841. if (options.savedColors) {
  2842. if (options.savedColors.length < options.swatchLimit) {
  2843. butSave.background = buttonBackgroundColor;
  2844. }
  2845. }
  2846. });
  2847. butSave.pointerDownAnimation = function () {
  2848. if (options.savedColors) {
  2849. if (options.savedColors.length < options.swatchLimit) {
  2850. butSave.background = buttonBackgroundClickColor;
  2851. }
  2852. }
  2853. };
  2854. butSave.pointerUpAnimation = function () {
  2855. if (options.savedColors) {
  2856. if (options.savedColors.length < options.swatchLimit) {
  2857. butSave.background = buttonBackgroundHoverColor;
  2858. }
  2859. }
  2860. };
  2861. butSave.onPointerClickObservable.add(function () {
  2862. if (options.savedColors) {
  2863. if (options.savedColors.length == 0) {
  2864. setEditButtonVisibility(true);
  2865. }
  2866. if (options.savedColors.length < options.swatchLimit) {
  2867. updateSwatches(newSwatch.background, butSave);
  2868. }
  2869. editSwatches(false);
  2870. }
  2871. });
  2872. if (options.savedColors.length > 0) {
  2873. setEditButtonVisibility(true);
  2874. }
  2875. buttonGrid.addControl(butSave, 2, 0);
  2876. }
  2877. // Picker color values input
  2878. var pickerColorValues = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2879. pickerColorValues.name = "Dialog Lower Right";
  2880. pickerColorValues.addRowDefinition(0.02, false);
  2881. pickerColorValues.addRowDefinition(0.63, false);
  2882. pickerColorValues.addRowDefinition(0.21, false);
  2883. pickerColorValues.addRowDefinition(0.14, false);
  2884. pickerBodyRight.addControl(pickerColorValues, 1, 0);
  2885. // RGB values text boxes
  2886. currentColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2887. var rgbValuesQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2888. rgbValuesQuadrant.name = "RGB Values";
  2889. rgbValuesQuadrant.width = 0.82;
  2890. rgbValuesQuadrant.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2891. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2892. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2893. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2894. rgbValuesQuadrant.addColumnDefinition(0.1, false);
  2895. rgbValuesQuadrant.addColumnDefinition(0.2, false);
  2896. rgbValuesQuadrant.addColumnDefinition(0.7, false);
  2897. pickerColorValues.addControl(rgbValuesQuadrant, 1, 0);
  2898. for (var i = 0; i < inputFieldLabels.length; i++) {
  2899. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2900. labelText.text = inputFieldLabels[i];
  2901. labelText.color = buttonColor;
  2902. labelText.fontSize = buttonFontSize;
  2903. rgbValuesQuadrant.addControl(labelText, i, 0);
  2904. }
  2905. // Input fields for RGB values
  2906. rValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2907. rValInt.width = 0.83;
  2908. rValInt.height = 0.72;
  2909. rValInt.name = "rIntField";
  2910. rValInt.fontSize = buttonFontSize;
  2911. rValInt.text = (currentColor.r * 255).toString();
  2912. rValInt.color = inputTextColor;
  2913. rValInt.background = inputTextBackgroundColor;
  2914. rValInt.onFocusObservable.add(function () {
  2915. activeField = rValInt.name;
  2916. lastVal = rValInt.text;
  2917. editSwatches(false);
  2918. });
  2919. rValInt.onBlurObservable.add(function () {
  2920. if (rValInt.text == "") {
  2921. rValInt.text = "0";
  2922. }
  2923. updateInt(rValInt, "r");
  2924. if (activeField == rValInt.name) {
  2925. activeField = "";
  2926. }
  2927. });
  2928. rValInt.onTextChangedObservable.add(function () {
  2929. if (activeField == rValInt.name) {
  2930. updateInt(rValInt, "r");
  2931. }
  2932. });
  2933. rgbValuesQuadrant.addControl(rValInt, 0, 1);
  2934. gValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2935. gValInt.width = 0.83;
  2936. gValInt.height = 0.72;
  2937. gValInt.name = "gIntField";
  2938. gValInt.fontSize = buttonFontSize;
  2939. gValInt.text = (currentColor.g * 255).toString();
  2940. gValInt.color = inputTextColor;
  2941. gValInt.background = inputTextBackgroundColor;
  2942. gValInt.onFocusObservable.add(function () {
  2943. activeField = gValInt.name;
  2944. lastVal = gValInt.text;
  2945. editSwatches(false);
  2946. });
  2947. gValInt.onBlurObservable.add(function () {
  2948. if (gValInt.text == "") {
  2949. gValInt.text = "0";
  2950. }
  2951. updateInt(gValInt, "g");
  2952. if (activeField == gValInt.name) {
  2953. activeField = "";
  2954. }
  2955. });
  2956. gValInt.onTextChangedObservable.add(function () {
  2957. if (activeField == gValInt.name) {
  2958. updateInt(gValInt, "g");
  2959. }
  2960. });
  2961. rgbValuesQuadrant.addControl(gValInt, 1, 1);
  2962. bValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2963. bValInt.width = 0.83;
  2964. bValInt.height = 0.72;
  2965. bValInt.name = "bIntField";
  2966. bValInt.fontSize = buttonFontSize;
  2967. bValInt.text = (currentColor.b * 255).toString();
  2968. bValInt.color = inputTextColor;
  2969. bValInt.background = inputTextBackgroundColor;
  2970. bValInt.onFocusObservable.add(function () {
  2971. activeField = bValInt.name;
  2972. lastVal = bValInt.text;
  2973. editSwatches(false);
  2974. });
  2975. bValInt.onBlurObservable.add(function () {
  2976. if (bValInt.text == "") {
  2977. bValInt.text = "0";
  2978. }
  2979. updateInt(bValInt, "b");
  2980. if (activeField == bValInt.name) {
  2981. activeField = "";
  2982. }
  2983. });
  2984. bValInt.onTextChangedObservable.add(function () {
  2985. if (activeField == bValInt.name) {
  2986. updateInt(bValInt, "b");
  2987. }
  2988. });
  2989. rgbValuesQuadrant.addControl(bValInt, 2, 1);
  2990. rValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2991. rValDec.width = 0.95;
  2992. rValDec.height = 0.72;
  2993. rValDec.name = "rDecField";
  2994. rValDec.fontSize = buttonFontSize;
  2995. rValDec.text = currentColor.r.toString();
  2996. rValDec.color = inputTextColor;
  2997. rValDec.background = inputTextBackgroundColor;
  2998. rValDec.onFocusObservable.add(function () {
  2999. activeField = rValDec.name;
  3000. lastVal = rValDec.text;
  3001. editSwatches(false);
  3002. });
  3003. rValDec.onBlurObservable.add(function () {
  3004. if (parseFloat(rValDec.text) == 0 || rValDec.text == "") {
  3005. rValDec.text = "0";
  3006. updateFloat(rValDec, "r");
  3007. }
  3008. if (activeField == rValDec.name) {
  3009. activeField = "";
  3010. }
  3011. });
  3012. rValDec.onTextChangedObservable.add(function () {
  3013. if (activeField == rValDec.name) {
  3014. updateFloat(rValDec, "r");
  3015. }
  3016. });
  3017. rgbValuesQuadrant.addControl(rValDec, 0, 2);
  3018. gValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3019. gValDec.width = 0.95;
  3020. gValDec.height = 0.72;
  3021. gValDec.name = "gDecField";
  3022. gValDec.fontSize = buttonFontSize;
  3023. gValDec.text = currentColor.g.toString();
  3024. gValDec.color = inputTextColor;
  3025. gValDec.background = inputTextBackgroundColor;
  3026. gValDec.onFocusObservable.add(function () {
  3027. activeField = gValDec.name;
  3028. lastVal = gValDec.text;
  3029. editSwatches(false);
  3030. });
  3031. gValDec.onBlurObservable.add(function () {
  3032. if (parseFloat(gValDec.text) == 0 || gValDec.text == "") {
  3033. gValDec.text = "0";
  3034. updateFloat(gValDec, "g");
  3035. }
  3036. if (activeField == gValDec.name) {
  3037. activeField = "";
  3038. }
  3039. });
  3040. gValDec.onTextChangedObservable.add(function () {
  3041. if (activeField == gValDec.name) {
  3042. updateFloat(gValDec, "g");
  3043. }
  3044. });
  3045. rgbValuesQuadrant.addControl(gValDec, 1, 2);
  3046. bValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3047. bValDec.width = 0.95;
  3048. bValDec.height = 0.72;
  3049. bValDec.name = "bDecField";
  3050. bValDec.fontSize = buttonFontSize;
  3051. bValDec.text = currentColor.b.toString();
  3052. bValDec.color = inputTextColor;
  3053. bValDec.background = inputTextBackgroundColor;
  3054. bValDec.onFocusObservable.add(function () {
  3055. activeField = bValDec.name;
  3056. lastVal = bValDec.text;
  3057. editSwatches(false);
  3058. });
  3059. bValDec.onBlurObservable.add(function () {
  3060. if (parseFloat(bValDec.text) == 0 || bValDec.text == "") {
  3061. bValDec.text = "0";
  3062. updateFloat(bValDec, "b");
  3063. }
  3064. if (activeField == bValDec.name) {
  3065. activeField = "";
  3066. }
  3067. });
  3068. bValDec.onTextChangedObservable.add(function () {
  3069. if (activeField == bValDec.name) {
  3070. updateFloat(bValDec, "b");
  3071. }
  3072. });
  3073. rgbValuesQuadrant.addControl(bValDec, 2, 2);
  3074. // Hex value input
  3075. var hexValueQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3076. hexValueQuadrant.name = "Hex Value";
  3077. hexValueQuadrant.width = 0.82;
  3078. hexValueQuadrant.addRowDefinition(1.0, false);
  3079. hexValueQuadrant.addColumnDefinition(0.1, false);
  3080. hexValueQuadrant.addColumnDefinition(0.9, false);
  3081. pickerColorValues.addControl(hexValueQuadrant, 2, 0);
  3082. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  3083. labelText.text = "#";
  3084. labelText.color = buttonColor;
  3085. labelText.fontSize = buttonFontSize;
  3086. hexValueQuadrant.addControl(labelText, 0, 0);
  3087. hexVal = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3088. hexVal.width = 0.96;
  3089. hexVal.height = 0.72;
  3090. hexVal.name = "hexField";
  3091. hexVal.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  3092. hexVal.fontSize = buttonFontSize;
  3093. var minusPound = options.lastColor.split("#");
  3094. hexVal.text = minusPound[1];
  3095. hexVal.color = inputTextColor;
  3096. hexVal.background = inputTextBackgroundColor;
  3097. hexVal.onFocusObservable.add(function () {
  3098. activeField = hexVal.name;
  3099. lastVal = hexVal.text;
  3100. editSwatches(false);
  3101. });
  3102. hexVal.onBlurObservable.add(function () {
  3103. if (hexVal.text.length == 3) {
  3104. var val = hexVal.text.split("");
  3105. hexVal.text = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3106. }
  3107. if (hexVal.text == "") {
  3108. hexVal.text = "000000";
  3109. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(hexVal.text), "b");
  3110. }
  3111. if (activeField == hexVal.name) {
  3112. activeField = "";
  3113. }
  3114. });
  3115. hexVal.onTextChangedObservable.add(function () {
  3116. var newHexValue = hexVal.text;
  3117. var checkHex = /[^0-9A-F]/i.test(newHexValue);
  3118. if ((hexVal.text.length > 6 || checkHex) && activeField == hexVal.name) {
  3119. hexVal.text = lastVal;
  3120. }
  3121. else {
  3122. if (hexVal.text.length < 6) {
  3123. var leadingZero = 6 - hexVal.text.length;
  3124. for (var i = 0; i < leadingZero; i++) {
  3125. newHexValue = "0" + newHexValue;
  3126. }
  3127. }
  3128. if (hexVal.text.length == 3) {
  3129. var val = hexVal.text.split("");
  3130. newHexValue = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3131. }
  3132. newHexValue = "#" + newHexValue;
  3133. if (activeField == hexVal.name) {
  3134. lastVal = hexVal.text;
  3135. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newHexValue), hexVal.name);
  3136. }
  3137. }
  3138. });
  3139. hexValueQuadrant.addControl(hexVal, 0, 1);
  3140. if (options.savedColors && options.savedColors.length > 0) {
  3141. updateSwatches("", butSave);
  3142. }
  3143. });
  3144. };
  3145. ColorPicker._Epsilon = 0.000001;
  3146. return ColorPicker;
  3147. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3148. /***/ }),
  3149. /***/ "./2D/controls/container.ts":
  3150. /*!**********************************!*\
  3151. !*** ./2D/controls/container.ts ***!
  3152. \**********************************/
  3153. /*! exports provided: Container */
  3154. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3155. "use strict";
  3156. __webpack_require__.r(__webpack_exports__);
  3157. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return Container; });
  3158. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  3159. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Misc/observable");
  3160. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__);
  3161. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  3162. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3163. /**
  3164. * Root class for 2D containers
  3165. * @see http://doc.babylonjs.com/how_to/gui#containers
  3166. */
  3167. var Container = /** @class */ (function (_super) {
  3168. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Container, _super);
  3169. /**
  3170. * Creates a new Container
  3171. * @param name defines the name of the container
  3172. */
  3173. function Container(name) {
  3174. var _this = _super.call(this, name) || this;
  3175. _this.name = name;
  3176. /** @hidden */
  3177. _this._children = new Array();
  3178. /** @hidden */
  3179. _this._measureForChildren = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3180. /** @hidden */
  3181. _this._background = "";
  3182. /** @hidden */
  3183. _this._adaptWidthToChildren = false;
  3184. /** @hidden */
  3185. _this._adaptHeightToChildren = false;
  3186. return _this;
  3187. }
  3188. Object.defineProperty(Container.prototype, "adaptHeightToChildren", {
  3189. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  3190. get: function () {
  3191. return this._adaptHeightToChildren;
  3192. },
  3193. set: function (value) {
  3194. if (this._adaptHeightToChildren === value) {
  3195. return;
  3196. }
  3197. this._adaptHeightToChildren = value;
  3198. if (value) {
  3199. this.height = "100%";
  3200. }
  3201. this._markAsDirty();
  3202. },
  3203. enumerable: true,
  3204. configurable: true
  3205. });
  3206. Object.defineProperty(Container.prototype, "adaptWidthToChildren", {
  3207. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  3208. get: function () {
  3209. return this._adaptWidthToChildren;
  3210. },
  3211. set: function (value) {
  3212. if (this._adaptWidthToChildren === value) {
  3213. return;
  3214. }
  3215. this._adaptWidthToChildren = value;
  3216. if (value) {
  3217. this.width = "100%";
  3218. }
  3219. this._markAsDirty();
  3220. },
  3221. enumerable: true,
  3222. configurable: true
  3223. });
  3224. Object.defineProperty(Container.prototype, "background", {
  3225. /** Gets or sets background color */
  3226. get: function () {
  3227. return this._background;
  3228. },
  3229. set: function (value) {
  3230. if (this._background === value) {
  3231. return;
  3232. }
  3233. this._background = value;
  3234. this._markAsDirty();
  3235. },
  3236. enumerable: true,
  3237. configurable: true
  3238. });
  3239. Object.defineProperty(Container.prototype, "children", {
  3240. /** Gets the list of children */
  3241. get: function () {
  3242. return this._children;
  3243. },
  3244. enumerable: true,
  3245. configurable: true
  3246. });
  3247. Container.prototype._getTypeName = function () {
  3248. return "Container";
  3249. };
  3250. Container.prototype._flagDescendantsAsMatrixDirty = function () {
  3251. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3252. var child = _a[_i];
  3253. child._markMatrixAsDirty();
  3254. }
  3255. };
  3256. /**
  3257. * Gets a child using its name
  3258. * @param name defines the child name to look for
  3259. * @returns the child control if found
  3260. */
  3261. Container.prototype.getChildByName = function (name) {
  3262. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3263. var child = _a[_i];
  3264. if (child.name === name) {
  3265. return child;
  3266. }
  3267. }
  3268. return null;
  3269. };
  3270. /**
  3271. * Gets a child using its type and its name
  3272. * @param name defines the child name to look for
  3273. * @param type defines the child type to look for
  3274. * @returns the child control if found
  3275. */
  3276. Container.prototype.getChildByType = function (name, type) {
  3277. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3278. var child = _a[_i];
  3279. if (child.typeName === type) {
  3280. return child;
  3281. }
  3282. }
  3283. return null;
  3284. };
  3285. /**
  3286. * Search for a specific control in children
  3287. * @param control defines the control to look for
  3288. * @returns true if the control is in child list
  3289. */
  3290. Container.prototype.containsControl = function (control) {
  3291. return this.children.indexOf(control) !== -1;
  3292. };
  3293. /**
  3294. * Adds a new control to the current container
  3295. * @param control defines the control to add
  3296. * @returns the current container
  3297. */
  3298. Container.prototype.addControl = function (control) {
  3299. if (!control) {
  3300. return this;
  3301. }
  3302. var index = this._children.indexOf(control);
  3303. if (index !== -1) {
  3304. return this;
  3305. }
  3306. control._link(this._host);
  3307. control._markAllAsDirty();
  3308. this._reOrderControl(control);
  3309. this._markAsDirty();
  3310. return this;
  3311. };
  3312. /**
  3313. * Removes all controls from the current container
  3314. * @returns the current container
  3315. */
  3316. Container.prototype.clearControls = function () {
  3317. var children = this.children.slice();
  3318. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  3319. var child = children_1[_i];
  3320. this.removeControl(child);
  3321. }
  3322. return this;
  3323. };
  3324. /**
  3325. * Removes a control from the current container
  3326. * @param control defines the control to remove
  3327. * @returns the current container
  3328. */
  3329. Container.prototype.removeControl = function (control) {
  3330. var index = this._children.indexOf(control);
  3331. if (index !== -1) {
  3332. this._children.splice(index, 1);
  3333. control.parent = null;
  3334. }
  3335. control.linkWithMesh(null);
  3336. if (this._host) {
  3337. this._host._cleanControlAfterRemoval(control);
  3338. }
  3339. this._markAsDirty();
  3340. return this;
  3341. };
  3342. /** @hidden */
  3343. Container.prototype._reOrderControl = function (control) {
  3344. this.removeControl(control);
  3345. for (var index = 0; index < this._children.length; index++) {
  3346. if (this._children[index].zIndex > control.zIndex) {
  3347. this._children.splice(index, 0, control);
  3348. return;
  3349. }
  3350. }
  3351. this._children.push(control);
  3352. control.parent = this;
  3353. this._markAsDirty();
  3354. };
  3355. /** @hidden */
  3356. Container.prototype._offsetLeft = function (offset) {
  3357. _super.prototype._offsetLeft.call(this, offset);
  3358. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3359. var child = _a[_i];
  3360. child._offsetLeft(offset);
  3361. }
  3362. };
  3363. /** @hidden */
  3364. Container.prototype._offsetTop = function (offset) {
  3365. _super.prototype._offsetTop.call(this, offset);
  3366. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3367. var child = _a[_i];
  3368. child._offsetTop(offset);
  3369. }
  3370. };
  3371. /** @hidden */
  3372. Container.prototype._markAllAsDirty = function () {
  3373. _super.prototype._markAllAsDirty.call(this);
  3374. for (var index = 0; index < this._children.length; index++) {
  3375. this._children[index]._markAllAsDirty();
  3376. }
  3377. };
  3378. /** @hidden */
  3379. Container.prototype._localDraw = function (context) {
  3380. if (this._background) {
  3381. context.save();
  3382. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  3383. context.shadowColor = this.shadowColor;
  3384. context.shadowBlur = this.shadowBlur;
  3385. context.shadowOffsetX = this.shadowOffsetX;
  3386. context.shadowOffsetY = this.shadowOffsetY;
  3387. }
  3388. context.fillStyle = this._background;
  3389. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  3390. context.restore();
  3391. }
  3392. };
  3393. /** @hidden */
  3394. Container.prototype._link = function (host) {
  3395. _super.prototype._link.call(this, host);
  3396. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3397. var child = _a[_i];
  3398. child._link(host);
  3399. }
  3400. };
  3401. /** @hidden */
  3402. Container.prototype._beforeLayout = function () {
  3403. // Do nothing
  3404. };
  3405. /** @hidden */
  3406. Container.prototype._processMeasures = function (parentMeasure, context) {
  3407. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  3408. _super.prototype._processMeasures.call(this, parentMeasure, context);
  3409. this._evaluateClippingState(parentMeasure);
  3410. }
  3411. };
  3412. /** @hidden */
  3413. Container.prototype._layout = function (parentMeasure, context) {
  3414. if (!this.isVisible || this.notRenderable) {
  3415. return false;
  3416. }
  3417. if (this._isDirty) {
  3418. this._tempCurrentMeasure.copyFrom(this._currentMeasure);
  3419. }
  3420. var rebuildCount = 0;
  3421. context.save();
  3422. this._applyStates(context);
  3423. this._beforeLayout();
  3424. do {
  3425. var computedWidth = -1;
  3426. var computedHeight = -1;
  3427. this._rebuildLayout = false;
  3428. this._processMeasures(parentMeasure, context);
  3429. if (!this._isClipped) {
  3430. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3431. var child = _a[_i];
  3432. child._tempParentMeasure.copyFrom(this._measureForChildren);
  3433. if (child._layout(this._measureForChildren, context)) {
  3434. if (this.adaptWidthToChildren && child._width.isPixel) {
  3435. computedWidth = Math.max(computedWidth, child._currentMeasure.width);
  3436. }
  3437. if (this.adaptHeightToChildren && child._height.isPixel) {
  3438. computedHeight = Math.max(computedHeight, child._currentMeasure.height);
  3439. }
  3440. }
  3441. }
  3442. if (this.adaptWidthToChildren && computedWidth >= 0) {
  3443. if (this.width !== computedWidth + "px") {
  3444. this.width = computedWidth + "px";
  3445. this._rebuildLayout = true;
  3446. }
  3447. }
  3448. if (this.adaptHeightToChildren && computedHeight >= 0) {
  3449. if (this.height !== computedHeight + "px") {
  3450. this.height = computedHeight + "px";
  3451. this._rebuildLayout = true;
  3452. }
  3453. }
  3454. this._postMeasure();
  3455. }
  3456. rebuildCount++;
  3457. } while (this._rebuildLayout && rebuildCount < 3);
  3458. if (rebuildCount >= 3) {
  3459. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Layout cycle detected in GUI (Container name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  3460. }
  3461. context.restore();
  3462. if (this._isDirty) {
  3463. this.invalidateRect(Math.min(this._currentMeasure.left, this._tempCurrentMeasure.left), Math.min(this._currentMeasure.top, this._tempCurrentMeasure.top), Math.max(this._currentMeasure.left + this._currentMeasure.width, this._tempCurrentMeasure.left + this._tempCurrentMeasure.width) - 1, Math.max(this._currentMeasure.top + this._currentMeasure.height, this._tempCurrentMeasure.top + this._tempCurrentMeasure.height) - 1);
  3464. this._isDirty = false;
  3465. }
  3466. return true;
  3467. };
  3468. Container.prototype._postMeasure = function () {
  3469. // Do nothing by default
  3470. };
  3471. /** @hidden */
  3472. Container.prototype._draw = function (context, invalidatedRectangle) {
  3473. this._localDraw(context);
  3474. if (this.clipChildren) {
  3475. this._clipForChildren(context);
  3476. }
  3477. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3478. var child = _a[_i];
  3479. // Only redraw parts of the screen that are invalidated
  3480. if (invalidatedRectangle) {
  3481. if (!child._intersectsRect(invalidatedRectangle)) {
  3482. // continue;
  3483. }
  3484. }
  3485. child._render(context, invalidatedRectangle);
  3486. }
  3487. };
  3488. /** @hidden */
  3489. Container.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  3490. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  3491. if (!this.children) {
  3492. return;
  3493. }
  3494. for (var index = 0; index < this.children.length; index++) {
  3495. var item = this.children[index];
  3496. if (!predicate || predicate(item)) {
  3497. results.push(item);
  3498. }
  3499. if (!directDescendantsOnly) {
  3500. item._getDescendants(results, false, predicate);
  3501. }
  3502. }
  3503. };
  3504. /** @hidden */
  3505. Container.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  3506. if (!this.isVisible || this.notRenderable) {
  3507. return false;
  3508. }
  3509. if (!_super.prototype.contains.call(this, x, y)) {
  3510. return false;
  3511. }
  3512. // Checking backwards to pick closest first
  3513. for (var index = this._children.length - 1; index >= 0; index--) {
  3514. var child = this._children[index];
  3515. if (child._processPicking(x, y, type, pointerId, buttonIndex)) {
  3516. if (child.hoverCursor) {
  3517. this._host._changeCursor(child.hoverCursor);
  3518. }
  3519. return true;
  3520. }
  3521. }
  3522. if (!this.isHitTestVisible) {
  3523. return false;
  3524. }
  3525. return this._processObservables(type, x, y, pointerId, buttonIndex);
  3526. };
  3527. /** @hidden */
  3528. Container.prototype._additionalProcessing = function (parentMeasure, context) {
  3529. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  3530. this._measureForChildren.copyFrom(this._currentMeasure);
  3531. };
  3532. /** Releases associated resources */
  3533. Container.prototype.dispose = function () {
  3534. _super.prototype.dispose.call(this);
  3535. for (var index = this.children.length - 1; index >= 0; index--) {
  3536. this.children[index].dispose();
  3537. }
  3538. };
  3539. return Container;
  3540. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3541. /***/ }),
  3542. /***/ "./2D/controls/control.ts":
  3543. /*!********************************!*\
  3544. !*** ./2D/controls/control.ts ***!
  3545. \********************************/
  3546. /*! exports provided: Control */
  3547. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3548. "use strict";
  3549. __webpack_require__.r(__webpack_exports__);
  3550. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return Control; });
  3551. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  3552. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  3553. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  3554. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3555. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../math2D */ "./2D/math2D.ts");
  3556. /**
  3557. * Root class used for all 2D controls
  3558. * @see http://doc.babylonjs.com/how_to/gui#controls
  3559. */
  3560. var Control = /** @class */ (function () {
  3561. // Functions
  3562. /**
  3563. * Creates a new control
  3564. * @param name defines the name of the control
  3565. */
  3566. function Control(
  3567. /** defines the name of the control */
  3568. name) {
  3569. this.name = name;
  3570. this._alpha = 1;
  3571. this._alphaSet = false;
  3572. this._zIndex = 0;
  3573. /** @hidden */
  3574. this._currentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3575. this._fontFamily = "Arial";
  3576. this._fontStyle = "";
  3577. this._fontWeight = "";
  3578. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  3579. /** @hidden */
  3580. this._width = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3581. /** @hidden */
  3582. this._height = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3583. this._color = "";
  3584. this._style = null;
  3585. /** @hidden */
  3586. this._horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
  3587. /** @hidden */
  3588. this._verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
  3589. /** @hidden */
  3590. this._isDirty = true;
  3591. /** @hidden */
  3592. this._wasDirty = false;
  3593. /** @hidden */
  3594. this._tempParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3595. /** @hidden */
  3596. this._tempCurrentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3597. /** @hidden */
  3598. this._cachedParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3599. this._paddingLeft = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3600. this._paddingRight = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3601. this._paddingTop = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3602. this._paddingBottom = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3603. /** @hidden */
  3604. this._left = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3605. /** @hidden */
  3606. this._top = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3607. this._scaleX = 1.0;
  3608. this._scaleY = 1.0;
  3609. this._rotation = 0;
  3610. this._transformCenterX = 0.5;
  3611. this._transformCenterY = 0.5;
  3612. this._transformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3613. /** @hidden */
  3614. this._invertTransformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3615. /** @hidden */
  3616. this._transformedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3617. this._isMatrixDirty = true;
  3618. this._isVisible = true;
  3619. this._isHighlighted = false;
  3620. this._fontSet = false;
  3621. this._dummyVector2 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3622. this._downCount = 0;
  3623. this._enterCount = -1;
  3624. this._doNotRender = false;
  3625. this._downPointerIds = {};
  3626. this._isEnabled = true;
  3627. this._disabledColor = "#9a9a9a";
  3628. /** @hidden */
  3629. this._rebuildLayout = false;
  3630. /** @hidden */
  3631. this._isClipped = false;
  3632. /**
  3633. * Gets or sets an object used to store user defined information for the node
  3634. */
  3635. this.metadata = null;
  3636. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  3637. this.isHitTestVisible = true;
  3638. /** Gets or sets a boolean indicating if the control can block pointer events */
  3639. this.isPointerBlocker = false;
  3640. /** Gets or sets a boolean indicating if the control can be focusable */
  3641. this.isFocusInvisible = false;
  3642. /** Gets or sets a boolean indicating if the children are clipped to the current control bounds */
  3643. this.clipChildren = true;
  3644. /**
  3645. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  3646. */
  3647. this.useBitmapCache = false;
  3648. this._shadowOffsetX = 0;
  3649. this._shadowOffsetY = 0;
  3650. this._shadowBlur = 0;
  3651. this._shadowColor = 'black';
  3652. /** Gets or sets the cursor to use when the control is hovered */
  3653. this.hoverCursor = "";
  3654. /** @hidden */
  3655. this._linkOffsetX = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3656. /** @hidden */
  3657. this._linkOffsetY = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3658. /**
  3659. * An event triggered when the pointer move over the control.
  3660. */
  3661. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3662. /**
  3663. * An event triggered when the pointer move out of the control.
  3664. */
  3665. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3666. /**
  3667. * An event triggered when the pointer taps the control
  3668. */
  3669. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3670. /**
  3671. * An event triggered when pointer up
  3672. */
  3673. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3674. /**
  3675. * An event triggered when a control is clicked on
  3676. */
  3677. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3678. /**
  3679. * An event triggered when pointer enters the control
  3680. */
  3681. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3682. /**
  3683. * An event triggered when the control is marked as dirty
  3684. */
  3685. this.onDirtyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3686. /**
  3687. * An event triggered before drawing the control
  3688. */
  3689. this.onBeforeDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3690. /**
  3691. * An event triggered after the control was drawn
  3692. */
  3693. this.onAfterDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3694. }
  3695. Object.defineProperty(Control.prototype, "shadowOffsetX", {
  3696. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  3697. get: function () {
  3698. return this._shadowOffsetX;
  3699. },
  3700. set: function (value) {
  3701. if (this._shadowOffsetX === value) {
  3702. return;
  3703. }
  3704. this._shadowOffsetX = value;
  3705. this._markAsDirty();
  3706. },
  3707. enumerable: true,
  3708. configurable: true
  3709. });
  3710. Object.defineProperty(Control.prototype, "shadowOffsetY", {
  3711. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  3712. get: function () {
  3713. return this._shadowOffsetY;
  3714. },
  3715. set: function (value) {
  3716. if (this._shadowOffsetY === value) {
  3717. return;
  3718. }
  3719. this._shadowOffsetY = value;
  3720. this._markAsDirty();
  3721. },
  3722. enumerable: true,
  3723. configurable: true
  3724. });
  3725. Object.defineProperty(Control.prototype, "shadowBlur", {
  3726. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  3727. get: function () {
  3728. return this._shadowBlur;
  3729. },
  3730. set: function (value) {
  3731. if (this._shadowBlur === value) {
  3732. return;
  3733. }
  3734. this._shadowBlur = value;
  3735. this._markAsDirty();
  3736. },
  3737. enumerable: true,
  3738. configurable: true
  3739. });
  3740. Object.defineProperty(Control.prototype, "shadowColor", {
  3741. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  3742. get: function () {
  3743. return this._shadowColor;
  3744. },
  3745. set: function (value) {
  3746. if (this._shadowColor === value) {
  3747. return;
  3748. }
  3749. this._shadowColor = value;
  3750. this._markAsDirty();
  3751. },
  3752. enumerable: true,
  3753. configurable: true
  3754. });
  3755. Object.defineProperty(Control.prototype, "typeName", {
  3756. // Properties
  3757. /** Gets the control type name */
  3758. get: function () {
  3759. return this._getTypeName();
  3760. },
  3761. enumerable: true,
  3762. configurable: true
  3763. });
  3764. /**
  3765. * Get the current class name of the control.
  3766. * @returns current class name
  3767. */
  3768. Control.prototype.getClassName = function () {
  3769. return this._getTypeName();
  3770. };
  3771. Object.defineProperty(Control.prototype, "host", {
  3772. /**
  3773. * Get the hosting AdvancedDynamicTexture
  3774. */
  3775. get: function () {
  3776. return this._host;
  3777. },
  3778. enumerable: true,
  3779. configurable: true
  3780. });
  3781. Object.defineProperty(Control.prototype, "fontOffset", {
  3782. /** Gets or set information about font offsets (used to render and align text) */
  3783. get: function () {
  3784. return this._fontOffset;
  3785. },
  3786. set: function (offset) {
  3787. this._fontOffset = offset;
  3788. },
  3789. enumerable: true,
  3790. configurable: true
  3791. });
  3792. Object.defineProperty(Control.prototype, "alpha", {
  3793. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  3794. get: function () {
  3795. return this._alpha;
  3796. },
  3797. set: function (value) {
  3798. if (this._alpha === value) {
  3799. return;
  3800. }
  3801. this._alphaSet = true;
  3802. this._alpha = value;
  3803. this._markAsDirty();
  3804. },
  3805. enumerable: true,
  3806. configurable: true
  3807. });
  3808. Object.defineProperty(Control.prototype, "isHighlighted", {
  3809. /**
  3810. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  3811. */
  3812. get: function () {
  3813. return this._isHighlighted;
  3814. },
  3815. set: function (value) {
  3816. if (this._isHighlighted === value) {
  3817. return;
  3818. }
  3819. this._isHighlighted = value;
  3820. this._markAsDirty();
  3821. },
  3822. enumerable: true,
  3823. configurable: true
  3824. });
  3825. Object.defineProperty(Control.prototype, "scaleX", {
  3826. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  3827. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3828. */
  3829. get: function () {
  3830. return this._scaleX;
  3831. },
  3832. set: function (value) {
  3833. if (this._scaleX === value) {
  3834. return;
  3835. }
  3836. this._scaleX = value;
  3837. this._transform();
  3838. this._markAsDirty();
  3839. this._markMatrixAsDirty();
  3840. },
  3841. enumerable: true,
  3842. configurable: true
  3843. });
  3844. Object.defineProperty(Control.prototype, "scaleY", {
  3845. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  3846. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3847. */
  3848. get: function () {
  3849. return this._scaleY;
  3850. },
  3851. set: function (value) {
  3852. if (this._scaleY === value) {
  3853. return;
  3854. }
  3855. this._scaleY = value;
  3856. this._transform();
  3857. this._markAsDirty();
  3858. this._markMatrixAsDirty();
  3859. },
  3860. enumerable: true,
  3861. configurable: true
  3862. });
  3863. Object.defineProperty(Control.prototype, "rotation", {
  3864. /** Gets or sets the rotation angle (0 by default)
  3865. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3866. */
  3867. get: function () {
  3868. return this._rotation;
  3869. },
  3870. set: function (value) {
  3871. if (this._rotation === value) {
  3872. return;
  3873. }
  3874. this._rotation = value;
  3875. this._markAsDirty();
  3876. this._markMatrixAsDirty();
  3877. },
  3878. enumerable: true,
  3879. configurable: true
  3880. });
  3881. Object.defineProperty(Control.prototype, "transformCenterY", {
  3882. /** Gets or sets the transformation center on Y axis (0 by default)
  3883. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3884. */
  3885. get: function () {
  3886. return this._transformCenterY;
  3887. },
  3888. set: function (value) {
  3889. if (this._transformCenterY === value) {
  3890. return;
  3891. }
  3892. this._transformCenterY = value;
  3893. this._markAsDirty();
  3894. this._markMatrixAsDirty();
  3895. },
  3896. enumerable: true,
  3897. configurable: true
  3898. });
  3899. Object.defineProperty(Control.prototype, "transformCenterX", {
  3900. /** Gets or sets the transformation center on X axis (0 by default)
  3901. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3902. */
  3903. get: function () {
  3904. return this._transformCenterX;
  3905. },
  3906. set: function (value) {
  3907. if (this._transformCenterX === value) {
  3908. return;
  3909. }
  3910. this._transformCenterX = value;
  3911. this._markAsDirty();
  3912. this._markMatrixAsDirty();
  3913. },
  3914. enumerable: true,
  3915. configurable: true
  3916. });
  3917. Object.defineProperty(Control.prototype, "horizontalAlignment", {
  3918. /**
  3919. * Gets or sets the horizontal alignment
  3920. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3921. */
  3922. get: function () {
  3923. return this._horizontalAlignment;
  3924. },
  3925. set: function (value) {
  3926. if (this._horizontalAlignment === value) {
  3927. return;
  3928. }
  3929. this._horizontalAlignment = value;
  3930. this._markAsDirty();
  3931. },
  3932. enumerable: true,
  3933. configurable: true
  3934. });
  3935. Object.defineProperty(Control.prototype, "verticalAlignment", {
  3936. /**
  3937. * Gets or sets the vertical alignment
  3938. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3939. */
  3940. get: function () {
  3941. return this._verticalAlignment;
  3942. },
  3943. set: function (value) {
  3944. if (this._verticalAlignment === value) {
  3945. return;
  3946. }
  3947. this._verticalAlignment = value;
  3948. this._markAsDirty();
  3949. },
  3950. enumerable: true,
  3951. configurable: true
  3952. });
  3953. Object.defineProperty(Control.prototype, "width", {
  3954. /**
  3955. * Gets or sets control width
  3956. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3957. */
  3958. get: function () {
  3959. return this._width.toString(this._host);
  3960. },
  3961. set: function (value) {
  3962. if (this._width.toString(this._host) === value) {
  3963. return;
  3964. }
  3965. if (this._width.fromString(value)) {
  3966. this._markAsDirty();
  3967. }
  3968. },
  3969. enumerable: true,
  3970. configurable: true
  3971. });
  3972. Object.defineProperty(Control.prototype, "widthInPixels", {
  3973. /**
  3974. * Gets control width in pixel
  3975. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3976. */
  3977. get: function () {
  3978. return this._width.getValueInPixel(this._host, this._cachedParentMeasure.width);
  3979. },
  3980. enumerable: true,
  3981. configurable: true
  3982. });
  3983. Object.defineProperty(Control.prototype, "height", {
  3984. /**
  3985. * Gets or sets control height
  3986. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3987. */
  3988. get: function () {
  3989. return this._height.toString(this._host);
  3990. },
  3991. set: function (value) {
  3992. if (this._height.toString(this._host) === value) {
  3993. return;
  3994. }
  3995. if (this._height.fromString(value)) {
  3996. this._markAsDirty();
  3997. }
  3998. },
  3999. enumerable: true,
  4000. configurable: true
  4001. });
  4002. Object.defineProperty(Control.prototype, "heightInPixels", {
  4003. /**
  4004. * Gets control height in pixel
  4005. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4006. */
  4007. get: function () {
  4008. return this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4009. },
  4010. enumerable: true,
  4011. configurable: true
  4012. });
  4013. Object.defineProperty(Control.prototype, "fontFamily", {
  4014. /** Gets or set font family */
  4015. get: function () {
  4016. if (!this._fontSet) {
  4017. return "";
  4018. }
  4019. return this._fontFamily;
  4020. },
  4021. set: function (value) {
  4022. if (this._fontFamily === value) {
  4023. return;
  4024. }
  4025. this._fontFamily = value;
  4026. this._resetFontCache();
  4027. },
  4028. enumerable: true,
  4029. configurable: true
  4030. });
  4031. Object.defineProperty(Control.prototype, "fontStyle", {
  4032. /** Gets or sets font style */
  4033. get: function () {
  4034. return this._fontStyle;
  4035. },
  4036. set: function (value) {
  4037. if (this._fontStyle === value) {
  4038. return;
  4039. }
  4040. this._fontStyle = value;
  4041. this._resetFontCache();
  4042. },
  4043. enumerable: true,
  4044. configurable: true
  4045. });
  4046. Object.defineProperty(Control.prototype, "fontWeight", {
  4047. /** Gets or sets font weight */
  4048. get: function () {
  4049. return this._fontWeight;
  4050. },
  4051. set: function (value) {
  4052. if (this._fontWeight === value) {
  4053. return;
  4054. }
  4055. this._fontWeight = value;
  4056. this._resetFontCache();
  4057. },
  4058. enumerable: true,
  4059. configurable: true
  4060. });
  4061. Object.defineProperty(Control.prototype, "style", {
  4062. /**
  4063. * Gets or sets style
  4064. * @see http://doc.babylonjs.com/how_to/gui#styles
  4065. */
  4066. get: function () {
  4067. return this._style;
  4068. },
  4069. set: function (value) {
  4070. var _this = this;
  4071. if (this._style) {
  4072. this._style.onChangedObservable.remove(this._styleObserver);
  4073. this._styleObserver = null;
  4074. }
  4075. this._style = value;
  4076. if (this._style) {
  4077. this._styleObserver = this._style.onChangedObservable.add(function () {
  4078. _this._markAsDirty();
  4079. _this._resetFontCache();
  4080. });
  4081. }
  4082. this._markAsDirty();
  4083. this._resetFontCache();
  4084. },
  4085. enumerable: true,
  4086. configurable: true
  4087. });
  4088. Object.defineProperty(Control.prototype, "_isFontSizeInPercentage", {
  4089. /** @hidden */
  4090. get: function () {
  4091. return this._fontSize.isPercentage;
  4092. },
  4093. enumerable: true,
  4094. configurable: true
  4095. });
  4096. Object.defineProperty(Control.prototype, "fontSizeInPixels", {
  4097. /** Gets font size in pixels */
  4098. get: function () {
  4099. var fontSizeToUse = this._style ? this._style._fontSize : this._fontSize;
  4100. if (fontSizeToUse.isPixel) {
  4101. return fontSizeToUse.getValue(this._host);
  4102. }
  4103. return fontSizeToUse.getValueInPixel(this._host, this._tempParentMeasure.height || this._cachedParentMeasure.height);
  4104. },
  4105. enumerable: true,
  4106. configurable: true
  4107. });
  4108. Object.defineProperty(Control.prototype, "fontSize", {
  4109. /** Gets or sets font size */
  4110. get: function () {
  4111. return this._fontSize.toString(this._host);
  4112. },
  4113. set: function (value) {
  4114. if (this._fontSize.toString(this._host) === value) {
  4115. return;
  4116. }
  4117. if (this._fontSize.fromString(value)) {
  4118. this._markAsDirty();
  4119. this._resetFontCache();
  4120. }
  4121. },
  4122. enumerable: true,
  4123. configurable: true
  4124. });
  4125. Object.defineProperty(Control.prototype, "color", {
  4126. /** Gets or sets foreground color */
  4127. get: function () {
  4128. return this._color;
  4129. },
  4130. set: function (value) {
  4131. if (this._color === value) {
  4132. return;
  4133. }
  4134. this._color = value;
  4135. this._markAsDirty();
  4136. },
  4137. enumerable: true,
  4138. configurable: true
  4139. });
  4140. Object.defineProperty(Control.prototype, "zIndex", {
  4141. /** Gets or sets z index which is used to reorder controls on the z axis */
  4142. get: function () {
  4143. return this._zIndex;
  4144. },
  4145. set: function (value) {
  4146. if (this.zIndex === value) {
  4147. return;
  4148. }
  4149. this._zIndex = value;
  4150. if (this.parent) {
  4151. this.parent._reOrderControl(this);
  4152. }
  4153. },
  4154. enumerable: true,
  4155. configurable: true
  4156. });
  4157. Object.defineProperty(Control.prototype, "notRenderable", {
  4158. /** Gets or sets a boolean indicating if the control can be rendered */
  4159. get: function () {
  4160. return this._doNotRender;
  4161. },
  4162. set: function (value) {
  4163. if (this._doNotRender === value) {
  4164. return;
  4165. }
  4166. this._doNotRender = value;
  4167. this._markAsDirty();
  4168. },
  4169. enumerable: true,
  4170. configurable: true
  4171. });
  4172. Object.defineProperty(Control.prototype, "isVisible", {
  4173. /** Gets or sets a boolean indicating if the control is visible */
  4174. get: function () {
  4175. return this._isVisible;
  4176. },
  4177. set: function (value) {
  4178. if (this._isVisible === value) {
  4179. return;
  4180. }
  4181. this._isVisible = value;
  4182. this._markAsDirty(true);
  4183. },
  4184. enumerable: true,
  4185. configurable: true
  4186. });
  4187. Object.defineProperty(Control.prototype, "isDirty", {
  4188. /** Gets a boolean indicating that the control needs to update its rendering */
  4189. get: function () {
  4190. return this._isDirty;
  4191. },
  4192. enumerable: true,
  4193. configurable: true
  4194. });
  4195. Object.defineProperty(Control.prototype, "linkedMesh", {
  4196. /**
  4197. * Gets the current linked mesh (or null if none)
  4198. */
  4199. get: function () {
  4200. return this._linkedMesh;
  4201. },
  4202. enumerable: true,
  4203. configurable: true
  4204. });
  4205. Object.defineProperty(Control.prototype, "paddingLeft", {
  4206. /**
  4207. * Gets or sets a value indicating the padding to use on the left of the control
  4208. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4209. */
  4210. get: function () {
  4211. return this._paddingLeft.toString(this._host);
  4212. },
  4213. set: function (value) {
  4214. if (this._paddingLeft.fromString(value)) {
  4215. this._markAsDirty();
  4216. }
  4217. },
  4218. enumerable: true,
  4219. configurable: true
  4220. });
  4221. Object.defineProperty(Control.prototype, "paddingLeftInPixels", {
  4222. /**
  4223. * Gets a value indicating the padding in pixels to use on the left of the control
  4224. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4225. */
  4226. get: function () {
  4227. return this._paddingLeft.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4228. },
  4229. enumerable: true,
  4230. configurable: true
  4231. });
  4232. Object.defineProperty(Control.prototype, "paddingRight", {
  4233. /**
  4234. * Gets or sets a value indicating the padding to use on the right of the control
  4235. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4236. */
  4237. get: function () {
  4238. return this._paddingRight.toString(this._host);
  4239. },
  4240. set: function (value) {
  4241. if (this._paddingRight.fromString(value)) {
  4242. this._markAsDirty();
  4243. }
  4244. },
  4245. enumerable: true,
  4246. configurable: true
  4247. });
  4248. Object.defineProperty(Control.prototype, "paddingRightInPixels", {
  4249. /**
  4250. * Gets a value indicating the padding in pixels to use on the right of the control
  4251. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4252. */
  4253. get: function () {
  4254. return this._paddingRight.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4255. },
  4256. enumerable: true,
  4257. configurable: true
  4258. });
  4259. Object.defineProperty(Control.prototype, "paddingTop", {
  4260. /**
  4261. * Gets or sets a value indicating the padding to use on the top of the control
  4262. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4263. */
  4264. get: function () {
  4265. return this._paddingTop.toString(this._host);
  4266. },
  4267. set: function (value) {
  4268. if (this._paddingTop.fromString(value)) {
  4269. this._markAsDirty();
  4270. }
  4271. },
  4272. enumerable: true,
  4273. configurable: true
  4274. });
  4275. Object.defineProperty(Control.prototype, "paddingTopInPixels", {
  4276. /**
  4277. * Gets a value indicating the padding in pixels to use on the top of the control
  4278. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4279. */
  4280. get: function () {
  4281. return this._paddingTop.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4282. },
  4283. enumerable: true,
  4284. configurable: true
  4285. });
  4286. Object.defineProperty(Control.prototype, "paddingBottom", {
  4287. /**
  4288. * Gets or sets a value indicating the padding to use on the bottom of the control
  4289. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4290. */
  4291. get: function () {
  4292. return this._paddingBottom.toString(this._host);
  4293. },
  4294. set: function (value) {
  4295. if (this._paddingBottom.fromString(value)) {
  4296. this._markAsDirty();
  4297. }
  4298. },
  4299. enumerable: true,
  4300. configurable: true
  4301. });
  4302. Object.defineProperty(Control.prototype, "paddingBottomInPixels", {
  4303. /**
  4304. * Gets a value indicating the padding in pixels to use on the bottom of the control
  4305. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4306. */
  4307. get: function () {
  4308. return this._paddingBottom.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4309. },
  4310. enumerable: true,
  4311. configurable: true
  4312. });
  4313. Object.defineProperty(Control.prototype, "left", {
  4314. /**
  4315. * Gets or sets a value indicating the left coordinate of the control
  4316. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4317. */
  4318. get: function () {
  4319. return this._left.toString(this._host);
  4320. },
  4321. set: function (value) {
  4322. if (this._left.fromString(value)) {
  4323. this._markAsDirty();
  4324. }
  4325. },
  4326. enumerable: true,
  4327. configurable: true
  4328. });
  4329. Object.defineProperty(Control.prototype, "leftInPixels", {
  4330. /**
  4331. * Gets a value indicating the left coordinate in pixels of the control
  4332. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4333. */
  4334. get: function () {
  4335. return this._left.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4336. },
  4337. enumerable: true,
  4338. configurable: true
  4339. });
  4340. Object.defineProperty(Control.prototype, "top", {
  4341. /**
  4342. * Gets or sets a value indicating the top coordinate of the control
  4343. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4344. */
  4345. get: function () {
  4346. return this._top.toString(this._host);
  4347. },
  4348. set: function (value) {
  4349. if (this._top.fromString(value)) {
  4350. this._markAsDirty();
  4351. }
  4352. },
  4353. enumerable: true,
  4354. configurable: true
  4355. });
  4356. Object.defineProperty(Control.prototype, "topInPixels", {
  4357. /**
  4358. * Gets a value indicating the top coordinate in pixels of the control
  4359. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4360. */
  4361. get: function () {
  4362. return this._top.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4363. },
  4364. enumerable: true,
  4365. configurable: true
  4366. });
  4367. Object.defineProperty(Control.prototype, "linkOffsetX", {
  4368. /**
  4369. * Gets or sets a value indicating the offset on X axis to the linked mesh
  4370. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4371. */
  4372. get: function () {
  4373. return this._linkOffsetX.toString(this._host);
  4374. },
  4375. set: function (value) {
  4376. if (this._linkOffsetX.fromString(value)) {
  4377. this._markAsDirty();
  4378. }
  4379. },
  4380. enumerable: true,
  4381. configurable: true
  4382. });
  4383. Object.defineProperty(Control.prototype, "linkOffsetXInPixels", {
  4384. /**
  4385. * Gets a value indicating the offset in pixels on X axis to the linked mesh
  4386. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4387. */
  4388. get: function () {
  4389. return this._linkOffsetX.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4390. },
  4391. enumerable: true,
  4392. configurable: true
  4393. });
  4394. Object.defineProperty(Control.prototype, "linkOffsetY", {
  4395. /**
  4396. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  4397. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4398. */
  4399. get: function () {
  4400. return this._linkOffsetY.toString(this._host);
  4401. },
  4402. set: function (value) {
  4403. if (this._linkOffsetY.fromString(value)) {
  4404. this._markAsDirty();
  4405. }
  4406. },
  4407. enumerable: true,
  4408. configurable: true
  4409. });
  4410. Object.defineProperty(Control.prototype, "linkOffsetYInPixels", {
  4411. /**
  4412. * Gets a value indicating the offset in pixels on Y axis to the linked mesh
  4413. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4414. */
  4415. get: function () {
  4416. return this._linkOffsetY.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4417. },
  4418. enumerable: true,
  4419. configurable: true
  4420. });
  4421. Object.defineProperty(Control.prototype, "centerX", {
  4422. /** Gets the center coordinate on X axis */
  4423. get: function () {
  4424. return this._currentMeasure.left + this._currentMeasure.width / 2;
  4425. },
  4426. enumerable: true,
  4427. configurable: true
  4428. });
  4429. Object.defineProperty(Control.prototype, "centerY", {
  4430. /** Gets the center coordinate on Y axis */
  4431. get: function () {
  4432. return this._currentMeasure.top + this._currentMeasure.height / 2;
  4433. },
  4434. enumerable: true,
  4435. configurable: true
  4436. });
  4437. Object.defineProperty(Control.prototype, "isEnabled", {
  4438. /** Gets or sets if control is Enabled*/
  4439. get: function () {
  4440. return this._isEnabled;
  4441. },
  4442. set: function (value) {
  4443. if (this._isEnabled === value) {
  4444. return;
  4445. }
  4446. this._isEnabled = value;
  4447. this._markAsDirty();
  4448. },
  4449. enumerable: true,
  4450. configurable: true
  4451. });
  4452. Object.defineProperty(Control.prototype, "disabledColor", {
  4453. /** Gets or sets background color of control if it's disabled*/
  4454. get: function () {
  4455. return this._disabledColor;
  4456. },
  4457. set: function (value) {
  4458. if (this._disabledColor === value) {
  4459. return;
  4460. }
  4461. this._disabledColor = value;
  4462. this._markAsDirty();
  4463. },
  4464. enumerable: true,
  4465. configurable: true
  4466. });
  4467. /** @hidden */
  4468. Control.prototype._getTypeName = function () {
  4469. return "Control";
  4470. };
  4471. /**
  4472. * Gets the first ascendant in the hierarchy of the given type
  4473. * @param className defines the required type
  4474. * @returns the ascendant or null if not found
  4475. */
  4476. Control.prototype.getAscendantOfClass = function (className) {
  4477. if (!this.parent) {
  4478. return null;
  4479. }
  4480. if (this.parent.getClassName() === className) {
  4481. return this.parent;
  4482. }
  4483. return this.parent.getAscendantOfClass(className);
  4484. };
  4485. /** @hidden */
  4486. Control.prototype._resetFontCache = function () {
  4487. this._fontSet = true;
  4488. this._markAsDirty();
  4489. };
  4490. /**
  4491. * Determines if a container is an ascendant of the current control
  4492. * @param container defines the container to look for
  4493. * @returns true if the container is one of the ascendant of the control
  4494. */
  4495. Control.prototype.isAscendant = function (container) {
  4496. if (!this.parent) {
  4497. return false;
  4498. }
  4499. if (this.parent === container) {
  4500. return true;
  4501. }
  4502. return this.parent.isAscendant(container);
  4503. };
  4504. /**
  4505. * Gets coordinates in local control space
  4506. * @param globalCoordinates defines the coordinates to transform
  4507. * @returns the new coordinates in local space
  4508. */
  4509. Control.prototype.getLocalCoordinates = function (globalCoordinates) {
  4510. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4511. this.getLocalCoordinatesToRef(globalCoordinates, result);
  4512. return result;
  4513. };
  4514. /**
  4515. * Gets coordinates in local control space
  4516. * @param globalCoordinates defines the coordinates to transform
  4517. * @param result defines the target vector2 where to store the result
  4518. * @returns the current control
  4519. */
  4520. Control.prototype.getLocalCoordinatesToRef = function (globalCoordinates, result) {
  4521. result.x = globalCoordinates.x - this._currentMeasure.left;
  4522. result.y = globalCoordinates.y - this._currentMeasure.top;
  4523. return this;
  4524. };
  4525. /**
  4526. * Gets coordinates in parent local control space
  4527. * @param globalCoordinates defines the coordinates to transform
  4528. * @returns the new coordinates in parent local space
  4529. */
  4530. Control.prototype.getParentLocalCoordinates = function (globalCoordinates) {
  4531. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4532. result.x = globalCoordinates.x - this._cachedParentMeasure.left;
  4533. result.y = globalCoordinates.y - this._cachedParentMeasure.top;
  4534. return result;
  4535. };
  4536. /**
  4537. * Move the current control to a vector3 position projected onto the screen.
  4538. * @param position defines the target position
  4539. * @param scene defines the hosting scene
  4540. */
  4541. Control.prototype.moveToVector3 = function (position, scene) {
  4542. if (!this._host || this.parent !== this._host._rootContainer) {
  4543. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  4544. return;
  4545. }
  4546. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4547. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4548. var globalViewport = this._host._getGlobalViewport(scene);
  4549. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Project(position, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  4550. this._moveToProjectedPosition(projectedPosition);
  4551. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  4552. this.notRenderable = true;
  4553. return;
  4554. }
  4555. this.notRenderable = false;
  4556. };
  4557. /** @hidden */
  4558. Control.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  4559. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  4560. // Do nothing by default
  4561. };
  4562. /**
  4563. * Will return all controls that have this control as ascendant
  4564. * @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
  4565. * @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
  4566. * @return all child controls
  4567. */
  4568. Control.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  4569. var results = new Array();
  4570. this._getDescendants(results, directDescendantsOnly, predicate);
  4571. return results;
  4572. };
  4573. /**
  4574. * Link current control with a target mesh
  4575. * @param mesh defines the mesh to link with
  4576. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4577. */
  4578. Control.prototype.linkWithMesh = function (mesh) {
  4579. if (!this._host || this.parent && this.parent !== this._host._rootContainer) {
  4580. if (mesh) {
  4581. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot link a control to a mesh if the control is not at root level");
  4582. }
  4583. return;
  4584. }
  4585. var index = this._host._linkedControls.indexOf(this);
  4586. if (index !== -1) {
  4587. this._linkedMesh = mesh;
  4588. if (!mesh) {
  4589. this._host._linkedControls.splice(index, 1);
  4590. }
  4591. return;
  4592. }
  4593. else if (!mesh) {
  4594. return;
  4595. }
  4596. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4597. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4598. this._linkedMesh = mesh;
  4599. this._host._linkedControls.push(this);
  4600. };
  4601. /** @hidden */
  4602. Control.prototype._moveToProjectedPosition = function (projectedPosition) {
  4603. var oldLeft = this._left.getValue(this._host);
  4604. var oldTop = this._top.getValue(this._host);
  4605. var newLeft = ((projectedPosition.x + this._linkOffsetX.getValue(this._host)) - this._currentMeasure.width / 2);
  4606. var newTop = ((projectedPosition.y + this._linkOffsetY.getValue(this._host)) - this._currentMeasure.height / 2);
  4607. if (this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling) {
  4608. if (Math.abs(newLeft - oldLeft) < 0.5) {
  4609. newLeft = oldLeft;
  4610. }
  4611. if (Math.abs(newTop - oldTop) < 0.5) {
  4612. newTop = oldTop;
  4613. }
  4614. }
  4615. this.left = newLeft + "px";
  4616. this.top = newTop + "px";
  4617. this._left.ignoreAdaptiveScaling = true;
  4618. this._top.ignoreAdaptiveScaling = true;
  4619. this._markAsDirty();
  4620. };
  4621. /** @hidden */
  4622. Control.prototype._offsetLeft = function (offset) {
  4623. this._isDirty = true;
  4624. this._currentMeasure.left += offset;
  4625. };
  4626. /** @hidden */
  4627. Control.prototype._offsetTop = function (offset) {
  4628. this._isDirty = true;
  4629. this._currentMeasure.top += offset;
  4630. };
  4631. /** @hidden */
  4632. Control.prototype._markMatrixAsDirty = function () {
  4633. this._isMatrixDirty = true;
  4634. this._flagDescendantsAsMatrixDirty();
  4635. };
  4636. /** @hidden */
  4637. Control.prototype._flagDescendantsAsMatrixDirty = function () {
  4638. // No child
  4639. };
  4640. /** @hidden */
  4641. Control.prototype._intersectsRect = function (rect) {
  4642. if (this._currentMeasure.left >= rect.left + rect.width) {
  4643. return false;
  4644. }
  4645. if (this._currentMeasure.top >= rect.top + rect.height) {
  4646. return false;
  4647. }
  4648. if (this._currentMeasure.left + this._currentMeasure.width <= rect.left) {
  4649. return false;
  4650. }
  4651. if (this._currentMeasure.top + this._currentMeasure.height <= rect.top) {
  4652. return false;
  4653. }
  4654. return true;
  4655. };
  4656. /** @hidden */
  4657. Control.prototype.invalidateRect = function (left, top, right, bottom) {
  4658. if (this.host && this.host.useInvalidateRectOptimization) {
  4659. // Compute AABB of transformed container box (eg. to handle rotation and scaling)
  4660. var rectanglePoints = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Polygon"].Rectangle(left, top, right, bottom);
  4661. var min = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"](Number.MAX_VALUE, Number.MAX_VALUE);
  4662. var max = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  4663. for (var i = 0; i < 4; i++) {
  4664. this._transformMatrix.transformCoordinates(rectanglePoints[i].x, rectanglePoints[i].y, rectanglePoints[i]);
  4665. min.x = Math.min(min.x, rectanglePoints[i].x);
  4666. min.y = Math.min(min.y, rectanglePoints[i].y);
  4667. max.x = Math.max(max.x, rectanglePoints[i].x);
  4668. max.y = Math.max(max.y, rectanglePoints[i].y);
  4669. }
  4670. this.host.invalidateRect(min.x, min.y, max.x, max.y, left, top, right, bottom);
  4671. }
  4672. };
  4673. /** @hidden */
  4674. Control.prototype._markAsDirty = function (force) {
  4675. if (force === void 0) { force = false; }
  4676. if (!this._isVisible && !force) {
  4677. return;
  4678. }
  4679. this._isDirty = true;
  4680. // Redraw only this rectangle
  4681. if (this._host) {
  4682. this._host.markAsDirty();
  4683. }
  4684. };
  4685. /** @hidden */
  4686. Control.prototype._markAllAsDirty = function () {
  4687. this._markAsDirty();
  4688. if (this._font) {
  4689. this._prepareFont();
  4690. }
  4691. };
  4692. /** @hidden */
  4693. Control.prototype._link = function (host) {
  4694. this._host = host;
  4695. if (this._host) {
  4696. this.uniqueId = this._host.getScene().getUniqueId();
  4697. }
  4698. };
  4699. /** @hidden */
  4700. Control.prototype._transform = function (context) {
  4701. if (!this._isMatrixDirty && this._scaleX === 1 && this._scaleY === 1 && this._rotation === 0) {
  4702. return;
  4703. }
  4704. // postTranslate
  4705. var offsetX = this._currentMeasure.width * this._transformCenterX + this._currentMeasure.left;
  4706. var offsetY = this._currentMeasure.height * this._transformCenterY + this._currentMeasure.top;
  4707. if (context) {
  4708. context.translate(offsetX, offsetY);
  4709. // rotate
  4710. context.rotate(this._rotation);
  4711. // scale
  4712. context.scale(this._scaleX, this._scaleY);
  4713. // preTranslate
  4714. context.translate(-offsetX, -offsetY);
  4715. }
  4716. // Need to update matrices?
  4717. if (this._isMatrixDirty || this._cachedOffsetX !== offsetX || this._cachedOffsetY !== offsetY) {
  4718. this._cachedOffsetX = offsetX;
  4719. this._cachedOffsetY = offsetY;
  4720. this._isMatrixDirty = false;
  4721. this._flagDescendantsAsMatrixDirty();
  4722. _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].ComposeToRef(-offsetX, -offsetY, this._rotation, this._scaleX, this._scaleY, this.parent ? this.parent._transformMatrix : null, this._transformMatrix);
  4723. this._transformMatrix.invertToRef(this._invertTransformMatrix);
  4724. }
  4725. };
  4726. /** @hidden */
  4727. Control.prototype._renderHighlight = function (context) {
  4728. if (!this.isHighlighted) {
  4729. return;
  4730. }
  4731. context.save();
  4732. context.strokeStyle = "#4affff";
  4733. context.lineWidth = 2;
  4734. this._renderHighlightSpecific(context);
  4735. context.restore();
  4736. };
  4737. /** @hidden */
  4738. Control.prototype._renderHighlightSpecific = function (context) {
  4739. context.strokeRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  4740. };
  4741. /** @hidden */
  4742. Control.prototype._applyStates = function (context) {
  4743. if (this._isFontSizeInPercentage) {
  4744. this._fontSet = true;
  4745. }
  4746. if (this._fontSet) {
  4747. this._prepareFont();
  4748. this._fontSet = false;
  4749. }
  4750. if (this._font) {
  4751. context.font = this._font;
  4752. }
  4753. if (this._color) {
  4754. context.fillStyle = this._color;
  4755. }
  4756. if (Control.AllowAlphaInheritance) {
  4757. context.globalAlpha *= this._alpha;
  4758. }
  4759. else if (this._alphaSet) {
  4760. context.globalAlpha = this.parent ? this.parent.alpha * this._alpha : this._alpha;
  4761. }
  4762. };
  4763. /** @hidden */
  4764. Control.prototype._layout = function (parentMeasure, context) {
  4765. if (!this.isVisible || this.notRenderable) {
  4766. return false;
  4767. }
  4768. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  4769. this._tempCurrentMeasure.copyFrom(this._currentMeasure);
  4770. context.save();
  4771. this._applyStates(context);
  4772. var rebuildCount = 0;
  4773. do {
  4774. this._rebuildLayout = false;
  4775. this._processMeasures(parentMeasure, context);
  4776. rebuildCount++;
  4777. } while (this._rebuildLayout && rebuildCount < 3);
  4778. if (rebuildCount >= 3) {
  4779. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Layout cycle detected in GUI (Control name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  4780. }
  4781. context.restore();
  4782. this.invalidateRect(Math.min(this._currentMeasure.left, this._tempCurrentMeasure.left), Math.min(this._currentMeasure.top, this._tempCurrentMeasure.top), Math.max(this._currentMeasure.left + this._currentMeasure.width, this._tempCurrentMeasure.left + this._tempCurrentMeasure.width), Math.max(this._currentMeasure.top + this._currentMeasure.height, this._tempCurrentMeasure.top + this._tempCurrentMeasure.height));
  4783. this._evaluateClippingState(parentMeasure);
  4784. }
  4785. this._wasDirty = this._isDirty;
  4786. this._isDirty = false;
  4787. return true;
  4788. };
  4789. /** @hidden */
  4790. Control.prototype._processMeasures = function (parentMeasure, context) {
  4791. this._currentMeasure.copyFrom(parentMeasure);
  4792. // Let children take some pre-measurement actions
  4793. this._preMeasure(parentMeasure, context);
  4794. this._measure();
  4795. this._computeAlignment(parentMeasure, context);
  4796. // Convert to int values
  4797. this._currentMeasure.left = this._currentMeasure.left | 0;
  4798. this._currentMeasure.top = this._currentMeasure.top | 0;
  4799. this._currentMeasure.width = this._currentMeasure.width | 0;
  4800. this._currentMeasure.height = this._currentMeasure.height | 0;
  4801. // Let children add more features
  4802. this._additionalProcessing(parentMeasure, context);
  4803. this._cachedParentMeasure.copyFrom(parentMeasure);
  4804. if (this.onDirtyObservable.hasObservers()) {
  4805. this.onDirtyObservable.notifyObservers(this);
  4806. }
  4807. };
  4808. Control.prototype._evaluateClippingState = function (parentMeasure) {
  4809. if (this.parent && this.parent.clipChildren) {
  4810. // Early clip
  4811. if (this._currentMeasure.left > parentMeasure.left + parentMeasure.width) {
  4812. this._isClipped = true;
  4813. return;
  4814. }
  4815. if (this._currentMeasure.left + this._currentMeasure.width < parentMeasure.left) {
  4816. this._isClipped = true;
  4817. return;
  4818. }
  4819. if (this._currentMeasure.top > parentMeasure.top + parentMeasure.height) {
  4820. this._isClipped = true;
  4821. return;
  4822. }
  4823. if (this._currentMeasure.top + this._currentMeasure.height < parentMeasure.top) {
  4824. this._isClipped = true;
  4825. return;
  4826. }
  4827. }
  4828. this._isClipped = false;
  4829. };
  4830. /** @hidden */
  4831. Control.prototype._measure = function () {
  4832. // Width / Height
  4833. if (this._width.isPixel) {
  4834. this._currentMeasure.width = this._width.getValue(this._host);
  4835. }
  4836. else {
  4837. this._currentMeasure.width *= this._width.getValue(this._host);
  4838. }
  4839. if (this._height.isPixel) {
  4840. this._currentMeasure.height = this._height.getValue(this._host);
  4841. }
  4842. else {
  4843. this._currentMeasure.height *= this._height.getValue(this._host);
  4844. }
  4845. };
  4846. /** @hidden */
  4847. Control.prototype._computeAlignment = function (parentMeasure, context) {
  4848. var width = this._currentMeasure.width;
  4849. var height = this._currentMeasure.height;
  4850. var parentWidth = parentMeasure.width;
  4851. var parentHeight = parentMeasure.height;
  4852. // Left / top
  4853. var x = 0;
  4854. var y = 0;
  4855. switch (this.horizontalAlignment) {
  4856. case Control.HORIZONTAL_ALIGNMENT_LEFT:
  4857. x = 0;
  4858. break;
  4859. case Control.HORIZONTAL_ALIGNMENT_RIGHT:
  4860. x = parentWidth - width;
  4861. break;
  4862. case Control.HORIZONTAL_ALIGNMENT_CENTER:
  4863. x = (parentWidth - width) / 2;
  4864. break;
  4865. }
  4866. switch (this.verticalAlignment) {
  4867. case Control.VERTICAL_ALIGNMENT_TOP:
  4868. y = 0;
  4869. break;
  4870. case Control.VERTICAL_ALIGNMENT_BOTTOM:
  4871. y = parentHeight - height;
  4872. break;
  4873. case Control.VERTICAL_ALIGNMENT_CENTER:
  4874. y = (parentHeight - height) / 2;
  4875. break;
  4876. }
  4877. if (this._paddingLeft.isPixel) {
  4878. this._currentMeasure.left += this._paddingLeft.getValue(this._host);
  4879. this._currentMeasure.width -= this._paddingLeft.getValue(this._host);
  4880. }
  4881. else {
  4882. this._currentMeasure.left += parentWidth * this._paddingLeft.getValue(this._host);
  4883. this._currentMeasure.width -= parentWidth * this._paddingLeft.getValue(this._host);
  4884. }
  4885. if (this._paddingRight.isPixel) {
  4886. this._currentMeasure.width -= this._paddingRight.getValue(this._host);
  4887. }
  4888. else {
  4889. this._currentMeasure.width -= parentWidth * this._paddingRight.getValue(this._host);
  4890. }
  4891. if (this._paddingTop.isPixel) {
  4892. this._currentMeasure.top += this._paddingTop.getValue(this._host);
  4893. this._currentMeasure.height -= this._paddingTop.getValue(this._host);
  4894. }
  4895. else {
  4896. this._currentMeasure.top += parentHeight * this._paddingTop.getValue(this._host);
  4897. this._currentMeasure.height -= parentHeight * this._paddingTop.getValue(this._host);
  4898. }
  4899. if (this._paddingBottom.isPixel) {
  4900. this._currentMeasure.height -= this._paddingBottom.getValue(this._host);
  4901. }
  4902. else {
  4903. this._currentMeasure.height -= parentHeight * this._paddingBottom.getValue(this._host);
  4904. }
  4905. if (this._left.isPixel) {
  4906. this._currentMeasure.left += this._left.getValue(this._host);
  4907. }
  4908. else {
  4909. this._currentMeasure.left += parentWidth * this._left.getValue(this._host);
  4910. }
  4911. if (this._top.isPixel) {
  4912. this._currentMeasure.top += this._top.getValue(this._host);
  4913. }
  4914. else {
  4915. this._currentMeasure.top += parentHeight * this._top.getValue(this._host);
  4916. }
  4917. this._currentMeasure.left += x;
  4918. this._currentMeasure.top += y;
  4919. };
  4920. /** @hidden */
  4921. Control.prototype._preMeasure = function (parentMeasure, context) {
  4922. // Do nothing
  4923. };
  4924. /** @hidden */
  4925. Control.prototype._additionalProcessing = function (parentMeasure, context) {
  4926. // Do nothing
  4927. };
  4928. /** @hidden */
  4929. Control.prototype._clipForChildren = function (context) {
  4930. // DO nothing
  4931. };
  4932. Control.prototype._clip = function (context, invalidatedRectangle) {
  4933. context.beginPath();
  4934. Control._ClipMeasure.copyFrom(this._currentMeasure);
  4935. if (invalidatedRectangle) {
  4936. var right = Math.min(invalidatedRectangle.left + invalidatedRectangle.width, this._currentMeasure.left + this._currentMeasure.width);
  4937. var bottom = Math.min(invalidatedRectangle.top + invalidatedRectangle.height, this._currentMeasure.top + this._currentMeasure.height);
  4938. Control._ClipMeasure.left = Math.max(invalidatedRectangle.left, this._currentMeasure.left);
  4939. Control._ClipMeasure.top = Math.max(invalidatedRectangle.top, this._currentMeasure.top);
  4940. Control._ClipMeasure.width = right - Control._ClipMeasure.left;
  4941. Control._ClipMeasure.height = bottom - Control._ClipMeasure.top;
  4942. }
  4943. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4944. var shadowOffsetX = this.shadowOffsetX;
  4945. var shadowOffsetY = this.shadowOffsetY;
  4946. var shadowBlur = this.shadowBlur;
  4947. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  4948. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  4949. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  4950. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  4951. context.rect(Control._ClipMeasure.left + leftShadowOffset, Control._ClipMeasure.top + topShadowOffset, Control._ClipMeasure.width + rightShadowOffset - leftShadowOffset, Control._ClipMeasure.height + bottomShadowOffset - topShadowOffset);
  4952. }
  4953. else {
  4954. context.rect(Control._ClipMeasure.left, Control._ClipMeasure.top, Control._ClipMeasure.width, Control._ClipMeasure.height);
  4955. }
  4956. context.clip();
  4957. };
  4958. /** @hidden */
  4959. Control.prototype._render = function (context, invalidatedRectangle) {
  4960. if (!this.isVisible || this.notRenderable || this._isClipped) {
  4961. this._isDirty = false;
  4962. return false;
  4963. }
  4964. context.save();
  4965. this._applyStates(context);
  4966. // Transform
  4967. this._transform(context);
  4968. // Clip
  4969. if (this.clipChildren) {
  4970. this._clip(context, invalidatedRectangle);
  4971. }
  4972. if (this.onBeforeDrawObservable.hasObservers()) {
  4973. this.onBeforeDrawObservable.notifyObservers(this);
  4974. }
  4975. if (this.useBitmapCache && !this._wasDirty && this._cacheData) {
  4976. context.putImageData(this._cacheData, this._currentMeasure.left, this._currentMeasure.top);
  4977. }
  4978. else {
  4979. this._draw(context, invalidatedRectangle);
  4980. }
  4981. if (this.useBitmapCache && this._wasDirty) {
  4982. this._cacheData = context.getImageData(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  4983. }
  4984. this._renderHighlight(context);
  4985. if (this.onAfterDrawObservable.hasObservers()) {
  4986. this.onAfterDrawObservable.notifyObservers(this);
  4987. }
  4988. context.restore();
  4989. return true;
  4990. };
  4991. /** @hidden */
  4992. Control.prototype._draw = function (context, invalidatedRectangle) {
  4993. // Do nothing
  4994. };
  4995. /**
  4996. * Tests if a given coordinates belong to the current control
  4997. * @param x defines x coordinate to test
  4998. * @param y defines y coordinate to test
  4999. * @returns true if the coordinates are inside the control
  5000. */
  5001. Control.prototype.contains = function (x, y) {
  5002. // Invert transform
  5003. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  5004. x = this._transformedPosition.x;
  5005. y = this._transformedPosition.y;
  5006. // Check
  5007. if (x < this._currentMeasure.left) {
  5008. return false;
  5009. }
  5010. if (x > this._currentMeasure.left + this._currentMeasure.width) {
  5011. return false;
  5012. }
  5013. if (y < this._currentMeasure.top) {
  5014. return false;
  5015. }
  5016. if (y > this._currentMeasure.top + this._currentMeasure.height) {
  5017. return false;
  5018. }
  5019. if (this.isPointerBlocker) {
  5020. this._host._shouldBlockPointer = true;
  5021. }
  5022. return true;
  5023. };
  5024. /** @hidden */
  5025. Control.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  5026. if (!this._isEnabled) {
  5027. return false;
  5028. }
  5029. if (!this.isHitTestVisible || !this.isVisible || this._doNotRender) {
  5030. return false;
  5031. }
  5032. if (!this.contains(x, y)) {
  5033. return false;
  5034. }
  5035. this._processObservables(type, x, y, pointerId, buttonIndex);
  5036. return true;
  5037. };
  5038. /** @hidden */
  5039. Control.prototype._onPointerMove = function (target, coordinates) {
  5040. var canNotify = this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  5041. if (canNotify && this.parent != null) {
  5042. this.parent._onPointerMove(target, coordinates);
  5043. }
  5044. };
  5045. /** @hidden */
  5046. Control.prototype._onPointerEnter = function (target) {
  5047. if (!this._isEnabled) {
  5048. return false;
  5049. }
  5050. if (this._enterCount > 0) {
  5051. return false;
  5052. }
  5053. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  5054. this._enterCount = 0;
  5055. }
  5056. this._enterCount++;
  5057. var canNotify = this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  5058. if (canNotify && this.parent != null) {
  5059. this.parent._onPointerEnter(target);
  5060. }
  5061. return true;
  5062. };
  5063. /** @hidden */
  5064. Control.prototype._onPointerOut = function (target) {
  5065. if (!this._isEnabled || target === this) {
  5066. return;
  5067. }
  5068. this._enterCount = 0;
  5069. var canNotify = true;
  5070. if (!target.isAscendant(this)) {
  5071. canNotify = this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  5072. }
  5073. if (canNotify && this.parent != null) {
  5074. this.parent._onPointerOut(target);
  5075. }
  5076. };
  5077. /** @hidden */
  5078. Control.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  5079. // Prevent pointerout to lose control context.
  5080. // Event redundancy is checked inside the function.
  5081. this._onPointerEnter(this);
  5082. if (this._downCount !== 0) {
  5083. return false;
  5084. }
  5085. this._downCount++;
  5086. this._downPointerIds[pointerId] = true;
  5087. var canNotify = this.onPointerDownObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5088. if (canNotify && this.parent != null) {
  5089. this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex);
  5090. }
  5091. return true;
  5092. };
  5093. /** @hidden */
  5094. Control.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  5095. if (!this._isEnabled) {
  5096. return;
  5097. }
  5098. this._downCount = 0;
  5099. delete this._downPointerIds[pointerId];
  5100. var canNotifyClick = notifyClick;
  5101. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  5102. canNotifyClick = this.onPointerClickObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5103. }
  5104. var canNotify = this.onPointerUpObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5105. if (canNotify && this.parent != null) {
  5106. this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex, canNotifyClick);
  5107. }
  5108. };
  5109. /** @hidden */
  5110. Control.prototype._forcePointerUp = function (pointerId) {
  5111. if (pointerId === void 0) { pointerId = null; }
  5112. if (pointerId !== null) {
  5113. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), pointerId, 0, true);
  5114. }
  5115. else {
  5116. for (var key in this._downPointerIds) {
  5117. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), +key, 0, true);
  5118. }
  5119. }
  5120. };
  5121. /** @hidden */
  5122. Control.prototype._processObservables = function (type, x, y, pointerId, buttonIndex) {
  5123. if (!this._isEnabled) {
  5124. return false;
  5125. }
  5126. this._dummyVector2.copyFromFloats(x, y);
  5127. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  5128. this._onPointerMove(this, this._dummyVector2);
  5129. var previousControlOver = this._host._lastControlOver[pointerId];
  5130. if (previousControlOver && previousControlOver !== this) {
  5131. previousControlOver._onPointerOut(this);
  5132. }
  5133. if (previousControlOver !== this) {
  5134. this._onPointerEnter(this);
  5135. }
  5136. this._host._lastControlOver[pointerId] = this;
  5137. return true;
  5138. }
  5139. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  5140. this._onPointerDown(this, this._dummyVector2, pointerId, buttonIndex);
  5141. this._host._registerLastControlDown(this, pointerId);
  5142. this._host._lastPickedControl = this;
  5143. return true;
  5144. }
  5145. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  5146. if (this._host._lastControlDown[pointerId]) {
  5147. this._host._lastControlDown[pointerId]._onPointerUp(this, this._dummyVector2, pointerId, buttonIndex, true);
  5148. }
  5149. delete this._host._lastControlDown[pointerId];
  5150. return true;
  5151. }
  5152. return false;
  5153. };
  5154. Control.prototype._prepareFont = function () {
  5155. if (!this._font && !this._fontSet) {
  5156. return;
  5157. }
  5158. if (this._style) {
  5159. this._font = this._style.fontStyle + " " + this._style.fontWeight + " " + this.fontSizeInPixels + "px " + this._style.fontFamily;
  5160. }
  5161. else {
  5162. this._font = this._fontStyle + " " + this._fontWeight + " " + this.fontSizeInPixels + "px " + this._fontFamily;
  5163. }
  5164. this._fontOffset = Control._GetFontOffset(this._font);
  5165. };
  5166. /** Releases associated resources */
  5167. Control.prototype.dispose = function () {
  5168. this.onDirtyObservable.clear();
  5169. this.onBeforeDrawObservable.clear();
  5170. this.onAfterDrawObservable.clear();
  5171. this.onPointerDownObservable.clear();
  5172. this.onPointerEnterObservable.clear();
  5173. this.onPointerMoveObservable.clear();
  5174. this.onPointerOutObservable.clear();
  5175. this.onPointerUpObservable.clear();
  5176. this.onPointerClickObservable.clear();
  5177. if (this._styleObserver && this._style) {
  5178. this._style.onChangedObservable.remove(this._styleObserver);
  5179. this._styleObserver = null;
  5180. }
  5181. if (this.parent) {
  5182. this.parent.removeControl(this);
  5183. this.parent = null;
  5184. }
  5185. if (this._host) {
  5186. var index = this._host._linkedControls.indexOf(this);
  5187. if (index > -1) {
  5188. this.linkWithMesh(null);
  5189. }
  5190. }
  5191. };
  5192. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_LEFT", {
  5193. /** HORIZONTAL_ALIGNMENT_LEFT */
  5194. get: function () {
  5195. return Control._HORIZONTAL_ALIGNMENT_LEFT;
  5196. },
  5197. enumerable: true,
  5198. configurable: true
  5199. });
  5200. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_RIGHT", {
  5201. /** HORIZONTAL_ALIGNMENT_RIGHT */
  5202. get: function () {
  5203. return Control._HORIZONTAL_ALIGNMENT_RIGHT;
  5204. },
  5205. enumerable: true,
  5206. configurable: true
  5207. });
  5208. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_CENTER", {
  5209. /** HORIZONTAL_ALIGNMENT_CENTER */
  5210. get: function () {
  5211. return Control._HORIZONTAL_ALIGNMENT_CENTER;
  5212. },
  5213. enumerable: true,
  5214. configurable: true
  5215. });
  5216. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_TOP", {
  5217. /** VERTICAL_ALIGNMENT_TOP */
  5218. get: function () {
  5219. return Control._VERTICAL_ALIGNMENT_TOP;
  5220. },
  5221. enumerable: true,
  5222. configurable: true
  5223. });
  5224. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_BOTTOM", {
  5225. /** VERTICAL_ALIGNMENT_BOTTOM */
  5226. get: function () {
  5227. return Control._VERTICAL_ALIGNMENT_BOTTOM;
  5228. },
  5229. enumerable: true,
  5230. configurable: true
  5231. });
  5232. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_CENTER", {
  5233. /** VERTICAL_ALIGNMENT_CENTER */
  5234. get: function () {
  5235. return Control._VERTICAL_ALIGNMENT_CENTER;
  5236. },
  5237. enumerable: true,
  5238. configurable: true
  5239. });
  5240. /** @hidden */
  5241. Control._GetFontOffset = function (font) {
  5242. if (Control._FontHeightSizes[font]) {
  5243. return Control._FontHeightSizes[font];
  5244. }
  5245. var text = document.createElement("span");
  5246. text.innerHTML = "Hg";
  5247. text.style.font = font;
  5248. var block = document.createElement("div");
  5249. block.style.display = "inline-block";
  5250. block.style.width = "1px";
  5251. block.style.height = "0px";
  5252. block.style.verticalAlign = "bottom";
  5253. var div = document.createElement("div");
  5254. div.appendChild(text);
  5255. div.appendChild(block);
  5256. document.body.appendChild(div);
  5257. var fontAscent = 0;
  5258. var fontHeight = 0;
  5259. try {
  5260. fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5261. block.style.verticalAlign = "baseline";
  5262. fontAscent = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5263. }
  5264. finally {
  5265. document.body.removeChild(div);
  5266. }
  5267. var result = { ascent: fontAscent, height: fontHeight, descent: fontHeight - fontAscent };
  5268. Control._FontHeightSizes[font] = result;
  5269. return result;
  5270. };
  5271. /** @hidden */
  5272. Control.drawEllipse = function (x, y, width, height, context) {
  5273. context.translate(x, y);
  5274. context.scale(width, height);
  5275. context.beginPath();
  5276. context.arc(0, 0, 1, 0, 2 * Math.PI);
  5277. context.closePath();
  5278. context.scale(1 / width, 1 / height);
  5279. context.translate(-x, -y);
  5280. };
  5281. /**
  5282. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  5283. */
  5284. Control.AllowAlphaInheritance = false;
  5285. Control._ClipMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5286. // Statics
  5287. Control._HORIZONTAL_ALIGNMENT_LEFT = 0;
  5288. Control._HORIZONTAL_ALIGNMENT_RIGHT = 1;
  5289. Control._HORIZONTAL_ALIGNMENT_CENTER = 2;
  5290. Control._VERTICAL_ALIGNMENT_TOP = 0;
  5291. Control._VERTICAL_ALIGNMENT_BOTTOM = 1;
  5292. Control._VERTICAL_ALIGNMENT_CENTER = 2;
  5293. Control._FontHeightSizes = {};
  5294. /**
  5295. * Creates a stack panel that can be used to render headers
  5296. * @param control defines the control to associate with the header
  5297. * @param text defines the text of the header
  5298. * @param size defines the size of the header
  5299. * @param options defines options used to configure the header
  5300. * @returns a new StackPanel
  5301. * @ignore
  5302. * @hidden
  5303. */
  5304. Control.AddHeader = function () { };
  5305. return Control;
  5306. }());
  5307. /***/ }),
  5308. /***/ "./2D/controls/displayGrid.ts":
  5309. /*!************************************!*\
  5310. !*** ./2D/controls/displayGrid.ts ***!
  5311. \************************************/
  5312. /*! exports provided: DisplayGrid */
  5313. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5314. "use strict";
  5315. __webpack_require__.r(__webpack_exports__);
  5316. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return DisplayGrid; });
  5317. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5318. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5319. /** Class used to render a grid */
  5320. var DisplayGrid = /** @class */ (function (_super) {
  5321. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DisplayGrid, _super);
  5322. /**
  5323. * Creates a new GridDisplayRectangle
  5324. * @param name defines the control name
  5325. */
  5326. function DisplayGrid(name) {
  5327. var _this = _super.call(this, name) || this;
  5328. _this.name = name;
  5329. _this._cellWidth = 20;
  5330. _this._cellHeight = 20;
  5331. _this._minorLineTickness = 1;
  5332. _this._minorLineColor = "DarkGray";
  5333. _this._majorLineTickness = 2;
  5334. _this._majorLineColor = "White";
  5335. _this._majorLineFrequency = 5;
  5336. _this._background = "Black";
  5337. _this._displayMajorLines = true;
  5338. _this._displayMinorLines = true;
  5339. return _this;
  5340. }
  5341. Object.defineProperty(DisplayGrid.prototype, "displayMinorLines", {
  5342. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  5343. get: function () {
  5344. return this._displayMinorLines;
  5345. },
  5346. set: function (value) {
  5347. if (this._displayMinorLines === value) {
  5348. return;
  5349. }
  5350. this._displayMinorLines = value;
  5351. this._markAsDirty();
  5352. },
  5353. enumerable: true,
  5354. configurable: true
  5355. });
  5356. Object.defineProperty(DisplayGrid.prototype, "displayMajorLines", {
  5357. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  5358. get: function () {
  5359. return this._displayMajorLines;
  5360. },
  5361. set: function (value) {
  5362. if (this._displayMajorLines === value) {
  5363. return;
  5364. }
  5365. this._displayMajorLines = value;
  5366. this._markAsDirty();
  5367. },
  5368. enumerable: true,
  5369. configurable: true
  5370. });
  5371. Object.defineProperty(DisplayGrid.prototype, "background", {
  5372. /** Gets or sets background color (Black by default) */
  5373. get: function () {
  5374. return this._background;
  5375. },
  5376. set: function (value) {
  5377. if (this._background === value) {
  5378. return;
  5379. }
  5380. this._background = value;
  5381. this._markAsDirty();
  5382. },
  5383. enumerable: true,
  5384. configurable: true
  5385. });
  5386. Object.defineProperty(DisplayGrid.prototype, "cellWidth", {
  5387. /** Gets or sets the width of each cell (20 by default) */
  5388. get: function () {
  5389. return this._cellWidth;
  5390. },
  5391. set: function (value) {
  5392. this._cellWidth = value;
  5393. this._markAsDirty();
  5394. },
  5395. enumerable: true,
  5396. configurable: true
  5397. });
  5398. Object.defineProperty(DisplayGrid.prototype, "cellHeight", {
  5399. /** Gets or sets the height of each cell (20 by default) */
  5400. get: function () {
  5401. return this._cellHeight;
  5402. },
  5403. set: function (value) {
  5404. this._cellHeight = value;
  5405. this._markAsDirty();
  5406. },
  5407. enumerable: true,
  5408. configurable: true
  5409. });
  5410. Object.defineProperty(DisplayGrid.prototype, "minorLineTickness", {
  5411. /** Gets or sets the tickness of minor lines (1 by default) */
  5412. get: function () {
  5413. return this._minorLineTickness;
  5414. },
  5415. set: function (value) {
  5416. this._minorLineTickness = value;
  5417. this._markAsDirty();
  5418. },
  5419. enumerable: true,
  5420. configurable: true
  5421. });
  5422. Object.defineProperty(DisplayGrid.prototype, "minorLineColor", {
  5423. /** Gets or sets the color of minor lines (DarkGray by default) */
  5424. get: function () {
  5425. return this._minorLineColor;
  5426. },
  5427. set: function (value) {
  5428. this._minorLineColor = value;
  5429. this._markAsDirty();
  5430. },
  5431. enumerable: true,
  5432. configurable: true
  5433. });
  5434. Object.defineProperty(DisplayGrid.prototype, "majorLineTickness", {
  5435. /** Gets or sets the tickness of major lines (2 by default) */
  5436. get: function () {
  5437. return this._majorLineTickness;
  5438. },
  5439. set: function (value) {
  5440. this._majorLineTickness = value;
  5441. this._markAsDirty();
  5442. },
  5443. enumerable: true,
  5444. configurable: true
  5445. });
  5446. Object.defineProperty(DisplayGrid.prototype, "majorLineColor", {
  5447. /** Gets or sets the color of major lines (White by default) */
  5448. get: function () {
  5449. return this._majorLineColor;
  5450. },
  5451. set: function (value) {
  5452. this._majorLineColor = value;
  5453. this._markAsDirty();
  5454. },
  5455. enumerable: true,
  5456. configurable: true
  5457. });
  5458. Object.defineProperty(DisplayGrid.prototype, "majorLineFrequency", {
  5459. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  5460. get: function () {
  5461. return this._majorLineFrequency;
  5462. },
  5463. set: function (value) {
  5464. this._majorLineFrequency = value;
  5465. this._markAsDirty();
  5466. },
  5467. enumerable: true,
  5468. configurable: true
  5469. });
  5470. DisplayGrid.prototype._draw = function (context) {
  5471. context.save();
  5472. this._applyStates(context);
  5473. if (this._isEnabled) {
  5474. if (this._background) {
  5475. context.fillStyle = this._background;
  5476. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5477. }
  5478. var cellCountX = this._currentMeasure.width / this._cellWidth;
  5479. var cellCountY = this._currentMeasure.height / this._cellHeight;
  5480. // Minor lines
  5481. var left = this._currentMeasure.left + this._currentMeasure.width / 2;
  5482. var top_1 = this._currentMeasure.top + this._currentMeasure.height / 2;
  5483. if (this._displayMinorLines) {
  5484. context.strokeStyle = this._minorLineColor;
  5485. context.lineWidth = this._minorLineTickness;
  5486. for (var x = -cellCountX / 2; x < cellCountX / 2; x++) {
  5487. var cellX = left + x * this.cellWidth;
  5488. context.beginPath();
  5489. context.moveTo(cellX, this._currentMeasure.top);
  5490. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5491. context.stroke();
  5492. }
  5493. for (var y = -cellCountY / 2; y < cellCountY / 2; y++) {
  5494. var cellY = top_1 + y * this.cellHeight;
  5495. context.beginPath();
  5496. context.moveTo(this._currentMeasure.left, cellY);
  5497. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5498. context.stroke();
  5499. }
  5500. }
  5501. // Major lines
  5502. if (this._displayMajorLines) {
  5503. context.strokeStyle = this._majorLineColor;
  5504. context.lineWidth = this._majorLineTickness;
  5505. for (var x = -cellCountX / 2 + this._majorLineFrequency; x < cellCountX / 2; x += this._majorLineFrequency) {
  5506. var cellX = left + x * this.cellWidth;
  5507. context.beginPath();
  5508. context.moveTo(cellX, this._currentMeasure.top);
  5509. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5510. context.stroke();
  5511. }
  5512. for (var y = -cellCountY / 2 + this._majorLineFrequency; y < cellCountY / 2; y += this._majorLineFrequency) {
  5513. var cellY = top_1 + y * this.cellHeight;
  5514. context.moveTo(this._currentMeasure.left, cellY);
  5515. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5516. context.closePath();
  5517. context.stroke();
  5518. }
  5519. }
  5520. }
  5521. context.restore();
  5522. };
  5523. DisplayGrid.prototype._getTypeName = function () {
  5524. return "DisplayGrid";
  5525. };
  5526. return DisplayGrid;
  5527. }(_control__WEBPACK_IMPORTED_MODULE_1__["Control"]));
  5528. /***/ }),
  5529. /***/ "./2D/controls/ellipse.ts":
  5530. /*!********************************!*\
  5531. !*** ./2D/controls/ellipse.ts ***!
  5532. \********************************/
  5533. /*! exports provided: Ellipse */
  5534. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5535. "use strict";
  5536. __webpack_require__.r(__webpack_exports__);
  5537. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return Ellipse; });
  5538. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5539. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5540. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5541. /** Class used to create 2D ellipse containers */
  5542. var Ellipse = /** @class */ (function (_super) {
  5543. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Ellipse, _super);
  5544. /**
  5545. * Creates a new Ellipse
  5546. * @param name defines the control name
  5547. */
  5548. function Ellipse(name) {
  5549. var _this = _super.call(this, name) || this;
  5550. _this.name = name;
  5551. _this._thickness = 1;
  5552. return _this;
  5553. }
  5554. Object.defineProperty(Ellipse.prototype, "thickness", {
  5555. /** Gets or sets border thickness */
  5556. get: function () {
  5557. return this._thickness;
  5558. },
  5559. set: function (value) {
  5560. if (this._thickness === value) {
  5561. return;
  5562. }
  5563. this._thickness = value;
  5564. this._markAsDirty();
  5565. },
  5566. enumerable: true,
  5567. configurable: true
  5568. });
  5569. Ellipse.prototype._getTypeName = function () {
  5570. return "Ellipse";
  5571. };
  5572. Ellipse.prototype._localDraw = function (context) {
  5573. context.save();
  5574. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5575. context.shadowColor = this.shadowColor;
  5576. context.shadowBlur = this.shadowBlur;
  5577. context.shadowOffsetX = this.shadowOffsetX;
  5578. context.shadowOffsetY = this.shadowOffsetY;
  5579. }
  5580. _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);
  5581. if (this._background) {
  5582. context.fillStyle = this._background;
  5583. context.fill();
  5584. }
  5585. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5586. context.shadowBlur = 0;
  5587. context.shadowOffsetX = 0;
  5588. context.shadowOffsetY = 0;
  5589. }
  5590. if (this._thickness) {
  5591. if (this.color) {
  5592. context.strokeStyle = this.color;
  5593. }
  5594. context.lineWidth = this._thickness;
  5595. context.stroke();
  5596. }
  5597. context.restore();
  5598. };
  5599. Ellipse.prototype._additionalProcessing = function (parentMeasure, context) {
  5600. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  5601. this._measureForChildren.width -= 2 * this._thickness;
  5602. this._measureForChildren.height -= 2 * this._thickness;
  5603. this._measureForChildren.left += this._thickness;
  5604. this._measureForChildren.top += this._thickness;
  5605. };
  5606. Ellipse.prototype._clipForChildren = function (context) {
  5607. _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);
  5608. context.clip();
  5609. };
  5610. return Ellipse;
  5611. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  5612. /***/ }),
  5613. /***/ "./2D/controls/grid.ts":
  5614. /*!*****************************!*\
  5615. !*** ./2D/controls/grid.ts ***!
  5616. \*****************************/
  5617. /*! exports provided: Grid */
  5618. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5619. "use strict";
  5620. __webpack_require__.r(__webpack_exports__);
  5621. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return Grid; });
  5622. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5623. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5624. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  5625. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5626. /**
  5627. * Class used to create a 2D grid container
  5628. */
  5629. var Grid = /** @class */ (function (_super) {
  5630. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Grid, _super);
  5631. /**
  5632. * Creates a new Grid
  5633. * @param name defines control name
  5634. */
  5635. function Grid(name) {
  5636. var _this = _super.call(this, name) || this;
  5637. _this.name = name;
  5638. _this._rowDefinitions = new Array();
  5639. _this._columnDefinitions = new Array();
  5640. _this._cells = {};
  5641. _this._childControls = new Array();
  5642. return _this;
  5643. }
  5644. Object.defineProperty(Grid.prototype, "columnCount", {
  5645. /**
  5646. * Gets the number of columns
  5647. */
  5648. get: function () {
  5649. return this._columnDefinitions.length;
  5650. },
  5651. enumerable: true,
  5652. configurable: true
  5653. });
  5654. Object.defineProperty(Grid.prototype, "rowCount", {
  5655. /**
  5656. * Gets the number of rows
  5657. */
  5658. get: function () {
  5659. return this._rowDefinitions.length;
  5660. },
  5661. enumerable: true,
  5662. configurable: true
  5663. });
  5664. Object.defineProperty(Grid.prototype, "children", {
  5665. /** Gets the list of children */
  5666. get: function () {
  5667. return this._childControls;
  5668. },
  5669. enumerable: true,
  5670. configurable: true
  5671. });
  5672. /**
  5673. * Gets the definition of a specific row
  5674. * @param index defines the index of the row
  5675. * @returns the row definition
  5676. */
  5677. Grid.prototype.getRowDefinition = function (index) {
  5678. if (index < 0 || index >= this._rowDefinitions.length) {
  5679. return null;
  5680. }
  5681. return this._rowDefinitions[index];
  5682. };
  5683. /**
  5684. * Gets the definition of a specific column
  5685. * @param index defines the index of the column
  5686. * @returns the column definition
  5687. */
  5688. Grid.prototype.getColumnDefinition = function (index) {
  5689. if (index < 0 || index >= this._columnDefinitions.length) {
  5690. return null;
  5691. }
  5692. return this._columnDefinitions[index];
  5693. };
  5694. /**
  5695. * Adds a new row to the grid
  5696. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5697. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  5698. * @returns the current grid
  5699. */
  5700. Grid.prototype.addRowDefinition = function (height, isPixel) {
  5701. if (isPixel === void 0) { isPixel = false; }
  5702. 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));
  5703. this._markAsDirty();
  5704. return this;
  5705. };
  5706. /**
  5707. * Adds a new column to the grid
  5708. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5709. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5710. * @returns the current grid
  5711. */
  5712. Grid.prototype.addColumnDefinition = function (width, isPixel) {
  5713. if (isPixel === void 0) { isPixel = false; }
  5714. 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));
  5715. this._markAsDirty();
  5716. return this;
  5717. };
  5718. /**
  5719. * Update a row definition
  5720. * @param index defines the index of the row to update
  5721. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5722. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  5723. * @returns the current grid
  5724. */
  5725. Grid.prototype.setRowDefinition = function (index, height, isPixel) {
  5726. if (isPixel === void 0) { isPixel = false; }
  5727. if (index < 0 || index >= this._rowDefinitions.length) {
  5728. return this;
  5729. }
  5730. var current = this._rowDefinitions[index];
  5731. if (current && current.isPixel === isPixel && current.internalValue === height) {
  5732. return this;
  5733. }
  5734. 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);
  5735. this._markAsDirty();
  5736. return this;
  5737. };
  5738. /**
  5739. * Update a column definition
  5740. * @param index defines the index of the column to update
  5741. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5742. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5743. * @returns the current grid
  5744. */
  5745. Grid.prototype.setColumnDefinition = function (index, width, isPixel) {
  5746. if (isPixel === void 0) { isPixel = false; }
  5747. if (index < 0 || index >= this._columnDefinitions.length) {
  5748. return this;
  5749. }
  5750. var current = this._columnDefinitions[index];
  5751. if (current && current.isPixel === isPixel && current.internalValue === width) {
  5752. return this;
  5753. }
  5754. 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);
  5755. this._markAsDirty();
  5756. return this;
  5757. };
  5758. /**
  5759. * Gets the list of children stored in a specific cell
  5760. * @param row defines the row to check
  5761. * @param column defines the column to check
  5762. * @returns the list of controls
  5763. */
  5764. Grid.prototype.getChildrenAt = function (row, column) {
  5765. var cell = this._cells[row + ":" + column];
  5766. if (!cell) {
  5767. return null;
  5768. }
  5769. return cell.children;
  5770. };
  5771. /**
  5772. * Gets a string representing the child cell info (row x column)
  5773. * @param child defines the control to get info from
  5774. * @returns a string containing the child cell info (row x column)
  5775. */
  5776. Grid.prototype.getChildCellInfo = function (child) {
  5777. return child._tag;
  5778. };
  5779. Grid.prototype._removeCell = function (cell, key) {
  5780. if (!cell) {
  5781. return;
  5782. }
  5783. _super.prototype.removeControl.call(this, cell);
  5784. for (var _i = 0, _a = cell.children; _i < _a.length; _i++) {
  5785. var control = _a[_i];
  5786. var childIndex = this._childControls.indexOf(control);
  5787. if (childIndex !== -1) {
  5788. this._childControls.splice(childIndex, 1);
  5789. }
  5790. }
  5791. delete this._cells[key];
  5792. };
  5793. Grid.prototype._offsetCell = function (previousKey, key) {
  5794. if (!this._cells[key]) {
  5795. return;
  5796. }
  5797. this._cells[previousKey] = this._cells[key];
  5798. for (var _i = 0, _a = this._cells[previousKey].children; _i < _a.length; _i++) {
  5799. var control = _a[_i];
  5800. control._tag = previousKey;
  5801. }
  5802. delete this._cells[key];
  5803. };
  5804. /**
  5805. * Remove a column definition at specified index
  5806. * @param index defines the index of the column to remove
  5807. * @returns the current grid
  5808. */
  5809. Grid.prototype.removeColumnDefinition = function (index) {
  5810. if (index < 0 || index >= this._columnDefinitions.length) {
  5811. return this;
  5812. }
  5813. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5814. var key = x + ":" + index;
  5815. var cell = this._cells[key];
  5816. this._removeCell(cell, key);
  5817. }
  5818. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5819. for (var y = index + 1; y < this._columnDefinitions.length; y++) {
  5820. var previousKey = x + ":" + (y - 1);
  5821. var key = x + ":" + y;
  5822. this._offsetCell(previousKey, key);
  5823. }
  5824. }
  5825. this._columnDefinitions.splice(index, 1);
  5826. this._markAsDirty();
  5827. return this;
  5828. };
  5829. /**
  5830. * Remove a row definition at specified index
  5831. * @param index defines the index of the row to remove
  5832. * @returns the current grid
  5833. */
  5834. Grid.prototype.removeRowDefinition = function (index) {
  5835. if (index < 0 || index >= this._rowDefinitions.length) {
  5836. return this;
  5837. }
  5838. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5839. var key = index + ":" + y;
  5840. var cell = this._cells[key];
  5841. this._removeCell(cell, key);
  5842. }
  5843. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5844. for (var x = index + 1; x < this._rowDefinitions.length; x++) {
  5845. var previousKey = x - 1 + ":" + y;
  5846. var key = x + ":" + y;
  5847. this._offsetCell(previousKey, key);
  5848. }
  5849. }
  5850. this._rowDefinitions.splice(index, 1);
  5851. this._markAsDirty();
  5852. return this;
  5853. };
  5854. /**
  5855. * Adds a new control to the current grid
  5856. * @param control defines the control to add
  5857. * @param row defines the row where to add the control (0 by default)
  5858. * @param column defines the column where to add the control (0 by default)
  5859. * @returns the current grid
  5860. */
  5861. Grid.prototype.addControl = function (control, row, column) {
  5862. if (row === void 0) { row = 0; }
  5863. if (column === void 0) { column = 0; }
  5864. if (this._rowDefinitions.length === 0) {
  5865. // Add default row definition
  5866. this.addRowDefinition(1, false);
  5867. }
  5868. if (this._columnDefinitions.length === 0) {
  5869. // Add default column definition
  5870. this.addColumnDefinition(1, false);
  5871. }
  5872. var x = Math.min(row, this._rowDefinitions.length - 1);
  5873. var y = Math.min(column, this._columnDefinitions.length - 1);
  5874. var key = x + ":" + y;
  5875. var goodContainer = this._cells[key];
  5876. if (!goodContainer) {
  5877. goodContainer = new _container__WEBPACK_IMPORTED_MODULE_1__["Container"](key);
  5878. this._cells[key] = goodContainer;
  5879. goodContainer.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  5880. goodContainer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  5881. _super.prototype.addControl.call(this, goodContainer);
  5882. }
  5883. goodContainer.addControl(control);
  5884. this._childControls.push(control);
  5885. control._tag = key;
  5886. control.parent = this;
  5887. this._markAsDirty();
  5888. return this;
  5889. };
  5890. /**
  5891. * Removes a control from the current container
  5892. * @param control defines the control to remove
  5893. * @returns the current container
  5894. */
  5895. Grid.prototype.removeControl = function (control) {
  5896. var index = this._childControls.indexOf(control);
  5897. if (index !== -1) {
  5898. this._childControls.splice(index, 1);
  5899. }
  5900. var cell = this._cells[control._tag];
  5901. if (cell) {
  5902. cell.removeControl(control);
  5903. }
  5904. this._markAsDirty();
  5905. return this;
  5906. };
  5907. Grid.prototype._getTypeName = function () {
  5908. return "Grid";
  5909. };
  5910. Grid.prototype._getGridDefinitions = function (definitionCallback) {
  5911. var widths = [];
  5912. var heights = [];
  5913. var lefts = [];
  5914. var tops = [];
  5915. var availableWidth = this._currentMeasure.width;
  5916. var globalWidthPercentage = 0;
  5917. var availableHeight = this._currentMeasure.height;
  5918. var globalHeightPercentage = 0;
  5919. // Heights
  5920. var index = 0;
  5921. for (var _i = 0, _a = this._rowDefinitions; _i < _a.length; _i++) {
  5922. var value = _a[_i];
  5923. if (value.isPixel) {
  5924. var height = value.getValue(this._host);
  5925. availableHeight -= height;
  5926. heights[index] = height;
  5927. }
  5928. else {
  5929. globalHeightPercentage += value.internalValue;
  5930. }
  5931. index++;
  5932. }
  5933. var top = 0;
  5934. index = 0;
  5935. for (var _b = 0, _c = this._rowDefinitions; _b < _c.length; _b++) {
  5936. var value = _c[_b];
  5937. tops.push(top);
  5938. if (!value.isPixel) {
  5939. var height = (value.internalValue / globalHeightPercentage) * availableHeight;
  5940. top += height;
  5941. heights[index] = height;
  5942. }
  5943. else {
  5944. top += value.getValue(this._host);
  5945. }
  5946. index++;
  5947. }
  5948. // Widths
  5949. index = 0;
  5950. for (var _d = 0, _e = this._columnDefinitions; _d < _e.length; _d++) {
  5951. var value = _e[_d];
  5952. if (value.isPixel) {
  5953. var width = value.getValue(this._host);
  5954. availableWidth -= width;
  5955. widths[index] = width;
  5956. }
  5957. else {
  5958. globalWidthPercentage += value.internalValue;
  5959. }
  5960. index++;
  5961. }
  5962. var left = 0;
  5963. index = 0;
  5964. for (var _f = 0, _g = this._columnDefinitions; _f < _g.length; _f++) {
  5965. var value = _g[_f];
  5966. lefts.push(left);
  5967. if (!value.isPixel) {
  5968. var width = (value.internalValue / globalWidthPercentage) * availableWidth;
  5969. left += width;
  5970. widths[index] = width;
  5971. }
  5972. else {
  5973. left += value.getValue(this._host);
  5974. }
  5975. index++;
  5976. }
  5977. definitionCallback(lefts, tops, widths, heights);
  5978. };
  5979. Grid.prototype._additionalProcessing = function (parentMeasure, context) {
  5980. var _this = this;
  5981. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  5982. // Setting child sizes
  5983. for (var key in _this._cells) {
  5984. if (!_this._cells.hasOwnProperty(key)) {
  5985. continue;
  5986. }
  5987. var split = key.split(":");
  5988. var x = parseInt(split[0]);
  5989. var y = parseInt(split[1]);
  5990. var cell = _this._cells[key];
  5991. cell.left = lefts[y] + "px";
  5992. cell.top = tops[x] + "px";
  5993. cell.width = widths[y] + "px";
  5994. cell.height = heights[x] + "px";
  5995. }
  5996. });
  5997. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  5998. };
  5999. Grid.prototype._flagDescendantsAsMatrixDirty = function () {
  6000. for (var key in this._cells) {
  6001. if (!this._cells.hasOwnProperty(key)) {
  6002. continue;
  6003. }
  6004. var child = this._cells[key];
  6005. child._markMatrixAsDirty();
  6006. }
  6007. };
  6008. Grid.prototype._renderHighlightSpecific = function (context) {
  6009. var _this = this;
  6010. _super.prototype._renderHighlightSpecific.call(this, context);
  6011. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6012. // Columns
  6013. for (var index = 0; index < lefts.length; index++) {
  6014. var left = _this._currentMeasure.left + lefts[index] + widths[index];
  6015. context.beginPath();
  6016. context.moveTo(left, _this._currentMeasure.top);
  6017. context.lineTo(left, _this._currentMeasure.top + _this._currentMeasure.height);
  6018. context.stroke();
  6019. }
  6020. // Rows
  6021. for (var index = 0; index < tops.length; index++) {
  6022. var top_1 = _this._currentMeasure.top + tops[index] + heights[index];
  6023. context.beginPath();
  6024. context.moveTo(_this._currentMeasure.left, top_1);
  6025. context.lineTo(_this._currentMeasure.left + _this._currentMeasure.width, top_1);
  6026. context.stroke();
  6027. }
  6028. });
  6029. context.restore();
  6030. };
  6031. /** Releases associated resources */
  6032. Grid.prototype.dispose = function () {
  6033. _super.prototype.dispose.call(this);
  6034. for (var _i = 0, _a = this._childControls; _i < _a.length; _i++) {
  6035. var control = _a[_i];
  6036. control.dispose();
  6037. }
  6038. this._childControls = [];
  6039. };
  6040. return Grid;
  6041. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6042. /***/ }),
  6043. /***/ "./2D/controls/image.ts":
  6044. /*!******************************!*\
  6045. !*** ./2D/controls/image.ts ***!
  6046. \******************************/
  6047. /*! exports provided: Image */
  6048. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6049. "use strict";
  6050. __webpack_require__.r(__webpack_exports__);
  6051. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return Image; });
  6052. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6053. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  6054. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6055. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6056. /**
  6057. * Class used to create 2D images
  6058. */
  6059. var Image = /** @class */ (function (_super) {
  6060. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Image, _super);
  6061. /**
  6062. * Creates a new Image
  6063. * @param name defines the control name
  6064. * @param url defines the image url
  6065. */
  6066. function Image(name, url) {
  6067. if (url === void 0) { url = null; }
  6068. var _this = _super.call(this, name) || this;
  6069. _this.name = name;
  6070. _this._loaded = false;
  6071. _this._stretch = Image.STRETCH_FILL;
  6072. _this._autoScale = false;
  6073. _this._sourceLeft = 0;
  6074. _this._sourceTop = 0;
  6075. _this._sourceWidth = 0;
  6076. _this._sourceHeight = 0;
  6077. _this._cellWidth = 0;
  6078. _this._cellHeight = 0;
  6079. _this._cellId = -1;
  6080. _this._populateNinePatchSlicesFromImage = false;
  6081. /**
  6082. * Observable notified when the content is loaded
  6083. */
  6084. _this.onImageLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6085. _this.source = url;
  6086. return _this;
  6087. }
  6088. Object.defineProperty(Image.prototype, "isLoaded", {
  6089. /**
  6090. * Gets a boolean indicating that the content is loaded
  6091. */
  6092. get: function () {
  6093. return this._loaded;
  6094. },
  6095. enumerable: true,
  6096. configurable: true
  6097. });
  6098. Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
  6099. /**
  6100. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  6101. */
  6102. get: function () {
  6103. return this._populateNinePatchSlicesFromImage;
  6104. },
  6105. set: function (value) {
  6106. if (this._populateNinePatchSlicesFromImage === value) {
  6107. return;
  6108. }
  6109. this._populateNinePatchSlicesFromImage = value;
  6110. if (this._populateNinePatchSlicesFromImage && this._loaded) {
  6111. this._extractNinePatchSliceDataFromImage();
  6112. }
  6113. },
  6114. enumerable: true,
  6115. configurable: true
  6116. });
  6117. Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
  6118. /**
  6119. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  6120. * Beware using this as this will comsume more memory as the image has to be stored twice
  6121. */
  6122. get: function () {
  6123. return this._detectPointerOnOpaqueOnly;
  6124. },
  6125. set: function (value) {
  6126. if (this._detectPointerOnOpaqueOnly === value) {
  6127. return;
  6128. }
  6129. this._detectPointerOnOpaqueOnly = value;
  6130. },
  6131. enumerable: true,
  6132. configurable: true
  6133. });
  6134. Object.defineProperty(Image.prototype, "sliceLeft", {
  6135. /**
  6136. * Gets or sets the left value for slicing (9-patch)
  6137. */
  6138. get: function () {
  6139. return this._sliceLeft;
  6140. },
  6141. set: function (value) {
  6142. if (this._sliceLeft === value) {
  6143. return;
  6144. }
  6145. this._sliceLeft = value;
  6146. this._markAsDirty();
  6147. },
  6148. enumerable: true,
  6149. configurable: true
  6150. });
  6151. Object.defineProperty(Image.prototype, "sliceRight", {
  6152. /**
  6153. * Gets or sets the right value for slicing (9-patch)
  6154. */
  6155. get: function () {
  6156. return this._sliceRight;
  6157. },
  6158. set: function (value) {
  6159. if (this._sliceRight === value) {
  6160. return;
  6161. }
  6162. this._sliceRight = value;
  6163. this._markAsDirty();
  6164. },
  6165. enumerable: true,
  6166. configurable: true
  6167. });
  6168. Object.defineProperty(Image.prototype, "sliceTop", {
  6169. /**
  6170. * Gets or sets the top value for slicing (9-patch)
  6171. */
  6172. get: function () {
  6173. return this._sliceTop;
  6174. },
  6175. set: function (value) {
  6176. if (this._sliceTop === value) {
  6177. return;
  6178. }
  6179. this._sliceTop = value;
  6180. this._markAsDirty();
  6181. },
  6182. enumerable: true,
  6183. configurable: true
  6184. });
  6185. Object.defineProperty(Image.prototype, "sliceBottom", {
  6186. /**
  6187. * Gets or sets the bottom value for slicing (9-patch)
  6188. */
  6189. get: function () {
  6190. return this._sliceBottom;
  6191. },
  6192. set: function (value) {
  6193. if (this._sliceBottom === value) {
  6194. return;
  6195. }
  6196. this._sliceBottom = value;
  6197. this._markAsDirty();
  6198. },
  6199. enumerable: true,
  6200. configurable: true
  6201. });
  6202. Object.defineProperty(Image.prototype, "sourceLeft", {
  6203. /**
  6204. * Gets or sets the left coordinate in the source image
  6205. */
  6206. get: function () {
  6207. return this._sourceLeft;
  6208. },
  6209. set: function (value) {
  6210. if (this._sourceLeft === value) {
  6211. return;
  6212. }
  6213. this._sourceLeft = value;
  6214. this._markAsDirty();
  6215. },
  6216. enumerable: true,
  6217. configurable: true
  6218. });
  6219. Object.defineProperty(Image.prototype, "sourceTop", {
  6220. /**
  6221. * Gets or sets the top coordinate in the source image
  6222. */
  6223. get: function () {
  6224. return this._sourceTop;
  6225. },
  6226. set: function (value) {
  6227. if (this._sourceTop === value) {
  6228. return;
  6229. }
  6230. this._sourceTop = value;
  6231. this._markAsDirty();
  6232. },
  6233. enumerable: true,
  6234. configurable: true
  6235. });
  6236. Object.defineProperty(Image.prototype, "sourceWidth", {
  6237. /**
  6238. * Gets or sets the width to capture in the source image
  6239. */
  6240. get: function () {
  6241. return this._sourceWidth;
  6242. },
  6243. set: function (value) {
  6244. if (this._sourceWidth === value) {
  6245. return;
  6246. }
  6247. this._sourceWidth = value;
  6248. this._markAsDirty();
  6249. },
  6250. enumerable: true,
  6251. configurable: true
  6252. });
  6253. Object.defineProperty(Image.prototype, "sourceHeight", {
  6254. /**
  6255. * Gets or sets the height to capture in the source image
  6256. */
  6257. get: function () {
  6258. return this._sourceHeight;
  6259. },
  6260. set: function (value) {
  6261. if (this._sourceHeight === value) {
  6262. return;
  6263. }
  6264. this._sourceHeight = value;
  6265. this._markAsDirty();
  6266. },
  6267. enumerable: true,
  6268. configurable: true
  6269. });
  6270. Object.defineProperty(Image.prototype, "autoScale", {
  6271. /**
  6272. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  6273. * @see http://doc.babylonjs.com/how_to/gui#image
  6274. */
  6275. get: function () {
  6276. return this._autoScale;
  6277. },
  6278. set: function (value) {
  6279. if (this._autoScale === value) {
  6280. return;
  6281. }
  6282. this._autoScale = value;
  6283. if (value && this._loaded) {
  6284. this.synchronizeSizeWithContent();
  6285. }
  6286. },
  6287. enumerable: true,
  6288. configurable: true
  6289. });
  6290. Object.defineProperty(Image.prototype, "stretch", {
  6291. /** Gets or sets the streching mode used by the image */
  6292. get: function () {
  6293. return this._stretch;
  6294. },
  6295. set: function (value) {
  6296. if (this._stretch === value) {
  6297. return;
  6298. }
  6299. this._stretch = value;
  6300. this._markAsDirty();
  6301. },
  6302. enumerable: true,
  6303. configurable: true
  6304. });
  6305. Object.defineProperty(Image.prototype, "domImage", {
  6306. get: function () {
  6307. return this._domImage;
  6308. },
  6309. /**
  6310. * Gets or sets the internal DOM image used to render the control
  6311. */
  6312. set: function (value) {
  6313. var _this = this;
  6314. this._domImage = value;
  6315. this._loaded = false;
  6316. if (this._domImage.width) {
  6317. this._onImageLoaded();
  6318. }
  6319. else {
  6320. this._domImage.onload = function () {
  6321. _this._onImageLoaded();
  6322. };
  6323. }
  6324. },
  6325. enumerable: true,
  6326. configurable: true
  6327. });
  6328. Image.prototype._onImageLoaded = function () {
  6329. this._imageWidth = this._domImage.width;
  6330. this._imageHeight = this._domImage.height;
  6331. this._loaded = true;
  6332. if (this._populateNinePatchSlicesFromImage) {
  6333. this._extractNinePatchSliceDataFromImage();
  6334. }
  6335. if (this._autoScale) {
  6336. this.synchronizeSizeWithContent();
  6337. }
  6338. this.onImageLoadedObservable.notifyObservers(this);
  6339. this._markAsDirty();
  6340. };
  6341. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  6342. if (!Image._WorkingCanvas) {
  6343. Image._WorkingCanvas = document.createElement('canvas');
  6344. }
  6345. var canvas = Image._WorkingCanvas;
  6346. var context = canvas.getContext('2d');
  6347. var width = this._domImage.width;
  6348. var height = this._domImage.height;
  6349. canvas.width = width;
  6350. canvas.height = height;
  6351. context.drawImage(this._domImage, 0, 0, width, height);
  6352. var imageData = context.getImageData(0, 0, width, height);
  6353. // Left and right
  6354. this._sliceLeft = -1;
  6355. this._sliceRight = -1;
  6356. for (var x = 0; x < width; x++) {
  6357. var alpha = imageData.data[x * 4 + 3];
  6358. if (alpha > 127 && this._sliceLeft === -1) {
  6359. this._sliceLeft = x;
  6360. continue;
  6361. }
  6362. if (alpha < 127 && this._sliceLeft > -1) {
  6363. this._sliceRight = x;
  6364. break;
  6365. }
  6366. }
  6367. // top and bottom
  6368. this._sliceTop = -1;
  6369. this._sliceBottom = -1;
  6370. for (var y = 0; y < height; y++) {
  6371. var alpha = imageData.data[y * width * 4 + 3];
  6372. if (alpha > 127 && this._sliceTop === -1) {
  6373. this._sliceTop = y;
  6374. continue;
  6375. }
  6376. if (alpha < 127 && this._sliceTop > -1) {
  6377. this._sliceBottom = y;
  6378. break;
  6379. }
  6380. }
  6381. };
  6382. Object.defineProperty(Image.prototype, "source", {
  6383. /**
  6384. * Gets or sets image source url
  6385. */
  6386. set: function (value) {
  6387. var _this = this;
  6388. if (this._source === value) {
  6389. return;
  6390. }
  6391. this._loaded = false;
  6392. this._source = value;
  6393. this._domImage = document.createElement("img");
  6394. this._domImage.onload = function () {
  6395. _this._onImageLoaded();
  6396. };
  6397. if (value) {
  6398. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  6399. this._domImage.src = value;
  6400. }
  6401. },
  6402. enumerable: true,
  6403. configurable: true
  6404. });
  6405. Object.defineProperty(Image.prototype, "cellWidth", {
  6406. /**
  6407. * Gets or sets the cell width to use when animation sheet is enabled
  6408. * @see http://doc.babylonjs.com/how_to/gui#image
  6409. */
  6410. get: function () {
  6411. return this._cellWidth;
  6412. },
  6413. set: function (value) {
  6414. if (this._cellWidth === value) {
  6415. return;
  6416. }
  6417. this._cellWidth = value;
  6418. this._markAsDirty();
  6419. },
  6420. enumerable: true,
  6421. configurable: true
  6422. });
  6423. Object.defineProperty(Image.prototype, "cellHeight", {
  6424. /**
  6425. * Gets or sets the cell height to use when animation sheet is enabled
  6426. * @see http://doc.babylonjs.com/how_to/gui#image
  6427. */
  6428. get: function () {
  6429. return this._cellHeight;
  6430. },
  6431. set: function (value) {
  6432. if (this._cellHeight === value) {
  6433. return;
  6434. }
  6435. this._cellHeight = value;
  6436. this._markAsDirty();
  6437. },
  6438. enumerable: true,
  6439. configurable: true
  6440. });
  6441. Object.defineProperty(Image.prototype, "cellId", {
  6442. /**
  6443. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  6444. * @see http://doc.babylonjs.com/how_to/gui#image
  6445. */
  6446. get: function () {
  6447. return this._cellId;
  6448. },
  6449. set: function (value) {
  6450. if (this._cellId === value) {
  6451. return;
  6452. }
  6453. this._cellId = value;
  6454. this._markAsDirty();
  6455. },
  6456. enumerable: true,
  6457. configurable: true
  6458. });
  6459. /**
  6460. * Tests if a given coordinates belong to the current control
  6461. * @param x defines x coordinate to test
  6462. * @param y defines y coordinate to test
  6463. * @returns true if the coordinates are inside the control
  6464. */
  6465. Image.prototype.contains = function (x, y) {
  6466. if (!_super.prototype.contains.call(this, x, y)) {
  6467. return false;
  6468. }
  6469. if (!this._detectPointerOnOpaqueOnly || !Image._WorkingCanvas) {
  6470. return true;
  6471. }
  6472. var canvas = Image._WorkingCanvas;
  6473. var context = canvas.getContext("2d");
  6474. var width = this._currentMeasure.width | 0;
  6475. var height = this._currentMeasure.height | 0;
  6476. var imageData = context.getImageData(0, 0, width, height).data;
  6477. x = (x - this._currentMeasure.left) | 0;
  6478. y = (y - this._currentMeasure.top) | 0;
  6479. var pickedPixel = imageData[(x + y * this._currentMeasure.width) * 4 + 3];
  6480. return pickedPixel > 0;
  6481. };
  6482. Image.prototype._getTypeName = function () {
  6483. return "Image";
  6484. };
  6485. /** Force the control to synchronize with its content */
  6486. Image.prototype.synchronizeSizeWithContent = function () {
  6487. if (!this._loaded) {
  6488. return;
  6489. }
  6490. this.width = this._domImage.width + "px";
  6491. this.height = this._domImage.height + "px";
  6492. };
  6493. Image.prototype._processMeasures = function (parentMeasure, context) {
  6494. if (this._loaded) {
  6495. switch (this._stretch) {
  6496. case Image.STRETCH_NONE:
  6497. break;
  6498. case Image.STRETCH_FILL:
  6499. break;
  6500. case Image.STRETCH_UNIFORM:
  6501. break;
  6502. case Image.STRETCH_NINE_PATCH:
  6503. break;
  6504. case Image.STRETCH_EXTEND:
  6505. if (this._autoScale) {
  6506. this.synchronizeSizeWithContent();
  6507. }
  6508. if (this.parent && this.parent.parent) { // Will update root size if root is not the top root
  6509. this.parent.adaptWidthToChildren = true;
  6510. this.parent.adaptHeightToChildren = true;
  6511. }
  6512. break;
  6513. }
  6514. }
  6515. _super.prototype._processMeasures.call(this, parentMeasure, context);
  6516. };
  6517. Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
  6518. if (!this._detectPointerOnOpaqueOnly) {
  6519. return;
  6520. }
  6521. if (!Image._WorkingCanvas) {
  6522. Image._WorkingCanvas = document.createElement('canvas');
  6523. }
  6524. var canvas = Image._WorkingCanvas;
  6525. var width = this._currentMeasure.width;
  6526. var height = this._currentMeasure.height;
  6527. var context = canvas.getContext("2d");
  6528. canvas.width = width;
  6529. canvas.height = height;
  6530. context.clearRect(0, 0, width, height);
  6531. };
  6532. Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
  6533. context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
  6534. if (!this._detectPointerOnOpaqueOnly) {
  6535. return;
  6536. }
  6537. var canvas = Image._WorkingCanvas;
  6538. context = canvas.getContext("2d");
  6539. context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
  6540. };
  6541. Image.prototype._draw = function (context) {
  6542. context.save();
  6543. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  6544. context.shadowColor = this.shadowColor;
  6545. context.shadowBlur = this.shadowBlur;
  6546. context.shadowOffsetX = this.shadowOffsetX;
  6547. context.shadowOffsetY = this.shadowOffsetY;
  6548. }
  6549. var x, y, width, height;
  6550. if (this.cellId == -1) {
  6551. x = this._sourceLeft;
  6552. y = this._sourceTop;
  6553. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  6554. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  6555. }
  6556. else {
  6557. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  6558. var column = (this.cellId / rowCount) >> 0;
  6559. var row = this.cellId % rowCount;
  6560. x = this.cellWidth * row;
  6561. y = this.cellHeight * column;
  6562. width = this.cellWidth;
  6563. height = this.cellHeight;
  6564. }
  6565. this._prepareWorkingCanvasForOpaqueDetection();
  6566. this._applyStates(context);
  6567. if (this._loaded) {
  6568. switch (this._stretch) {
  6569. case Image.STRETCH_NONE:
  6570. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6571. break;
  6572. case Image.STRETCH_FILL:
  6573. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6574. break;
  6575. case Image.STRETCH_UNIFORM:
  6576. var hRatio = this._currentMeasure.width / width;
  6577. var vRatio = this._currentMeasure.height / height;
  6578. var ratio = Math.min(hRatio, vRatio);
  6579. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  6580. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  6581. this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  6582. break;
  6583. case Image.STRETCH_EXTEND:
  6584. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6585. break;
  6586. case Image.STRETCH_NINE_PATCH:
  6587. this._renderNinePatch(context);
  6588. break;
  6589. }
  6590. }
  6591. context.restore();
  6592. };
  6593. Image.prototype._renderCornerPatch = function (context, x, y, width, height, targetX, targetY) {
  6594. this._drawImage(context, x, y, width, height, this._currentMeasure.left + targetX, this._currentMeasure.top + targetY, width, height);
  6595. };
  6596. Image.prototype._renderNinePatch = function (context) {
  6597. var height = this._imageHeight;
  6598. var leftWidth = this._sliceLeft;
  6599. var topHeight = this._sliceTop;
  6600. var bottomHeight = this._imageHeight - this._sliceBottom;
  6601. var rightWidth = this._imageWidth - this._sliceRight;
  6602. var left = 0;
  6603. var top = 0;
  6604. if (this._populateNinePatchSlicesFromImage) {
  6605. left = 1;
  6606. top = 1;
  6607. height -= 2;
  6608. leftWidth -= 1;
  6609. topHeight -= 1;
  6610. bottomHeight -= 1;
  6611. rightWidth -= 1;
  6612. }
  6613. var centerWidth = this._sliceRight - this._sliceLeft + 1;
  6614. var targetCenterWidth = this._currentMeasure.width - rightWidth - this.sliceLeft + 1;
  6615. var targetTopHeight = this._currentMeasure.height - height + this._sliceBottom;
  6616. // Corners
  6617. this._renderCornerPatch(context, left, top, leftWidth, topHeight, 0, 0);
  6618. this._renderCornerPatch(context, left, this._sliceBottom, leftWidth, height - this._sliceBottom, 0, targetTopHeight);
  6619. this._renderCornerPatch(context, this._sliceRight, top, rightWidth, topHeight, this._currentMeasure.width - rightWidth, 0);
  6620. this._renderCornerPatch(context, this._sliceRight, this._sliceBottom, rightWidth, height - this._sliceBottom, this._currentMeasure.width - rightWidth, targetTopHeight);
  6621. // Center
  6622. 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);
  6623. // Borders
  6624. this._drawImage(context, left, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  6625. 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);
  6626. this._drawImage(context, this._sliceLeft, top, centerWidth, topHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top, targetCenterWidth, topHeight);
  6627. this._drawImage(context, this._sliceLeft, this._sliceBottom, centerWidth, bottomHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top + targetTopHeight, targetCenterWidth, bottomHeight);
  6628. };
  6629. Image.prototype.dispose = function () {
  6630. _super.prototype.dispose.call(this);
  6631. this.onImageLoadedObservable.clear();
  6632. };
  6633. Image._WorkingCanvas = null;
  6634. // Static
  6635. /** STRETCH_NONE */
  6636. Image.STRETCH_NONE = 0;
  6637. /** STRETCH_FILL */
  6638. Image.STRETCH_FILL = 1;
  6639. /** STRETCH_UNIFORM */
  6640. Image.STRETCH_UNIFORM = 2;
  6641. /** STRETCH_EXTEND */
  6642. Image.STRETCH_EXTEND = 3;
  6643. /** NINE_PATCH */
  6644. Image.STRETCH_NINE_PATCH = 4;
  6645. return Image;
  6646. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  6647. /***/ }),
  6648. /***/ "./2D/controls/index.ts":
  6649. /*!******************************!*\
  6650. !*** ./2D/controls/index.ts ***!
  6651. \******************************/
  6652. /*! 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 */
  6653. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6654. "use strict";
  6655. __webpack_require__.r(__webpack_exports__);
  6656. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  6657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  6658. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  6659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  6660. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  6661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  6662. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  6663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  6664. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  6666. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  6667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  6668. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  6669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]; });
  6670. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  6671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_7__["Image"]; });
  6672. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_8__["InputText"]; });
  6674. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  6675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_9__["InputPassword"]; });
  6676. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  6677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_10__["Line"]; });
  6678. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  6679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_11__["MultiLine"]; });
  6680. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  6681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_12__["RadioButton"]; });
  6682. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  6683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_13__["StackPanel"]; });
  6684. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  6685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectorGroup"]; });
  6686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["CheckboxGroup"]; });
  6687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["RadioGroup"]; });
  6688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SliderGroup"]; });
  6689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectionPanel"]; });
  6690. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  6691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__["ScrollViewer"]; });
  6692. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  6693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextWrapping"]; });
  6694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextBlock"]; });
  6695. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  6696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["KeyPropertySet"]; });
  6697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["VirtualKeyboard"]; });
  6698. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  6699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_18__["Rectangle"]; });
  6700. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  6701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_19__["DisplayGrid"]; });
  6702. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  6703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__["BaseSlider"]; });
  6704. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  6705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_21__["Slider"]; });
  6706. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  6707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__["ImageBasedSlider"]; });
  6708. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  6709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_23__["name"]; });
  6710. /***/ }),
  6711. /***/ "./2D/controls/inputPassword.ts":
  6712. /*!**************************************!*\
  6713. !*** ./2D/controls/inputPassword.ts ***!
  6714. \**************************************/
  6715. /*! exports provided: InputPassword */
  6716. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6717. "use strict";
  6718. __webpack_require__.r(__webpack_exports__);
  6719. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  6720. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6721. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6722. /**
  6723. * Class used to create a password control
  6724. */
  6725. var InputPassword = /** @class */ (function (_super) {
  6726. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InputPassword, _super);
  6727. function InputPassword() {
  6728. return _super !== null && _super.apply(this, arguments) || this;
  6729. }
  6730. InputPassword.prototype._beforeRenderText = function (text) {
  6731. var txt = "";
  6732. for (var i = 0; i < text.length; i++) {
  6733. txt += "\u2022";
  6734. }
  6735. return txt;
  6736. };
  6737. return InputPassword;
  6738. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  6739. /***/ }),
  6740. /***/ "./2D/controls/inputText.ts":
  6741. /*!**********************************!*\
  6742. !*** ./2D/controls/inputText.ts ***!
  6743. \**********************************/
  6744. /*! exports provided: InputText */
  6745. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6746. "use strict";
  6747. __webpack_require__.r(__webpack_exports__);
  6748. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  6749. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6750. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  6751. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6752. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6753. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  6754. /**
  6755. * Class used to create input text control
  6756. */
  6757. var InputText = /** @class */ (function (_super) {
  6758. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InputText, _super);
  6759. /**
  6760. * Creates a new InputText
  6761. * @param name defines the control name
  6762. * @param text defines the text of the control
  6763. */
  6764. function InputText(name, text) {
  6765. if (text === void 0) { text = ""; }
  6766. var _this = _super.call(this, name) || this;
  6767. _this.name = name;
  6768. _this._text = "";
  6769. _this._placeholderText = "";
  6770. _this._background = "#222222";
  6771. _this._focusedBackground = "#000000";
  6772. _this._focusedColor = "white";
  6773. _this._placeholderColor = "gray";
  6774. _this._thickness = 1;
  6775. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  6776. _this._autoStretchWidth = true;
  6777. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  6778. _this._isFocused = false;
  6779. _this._blinkIsEven = false;
  6780. _this._cursorOffset = 0;
  6781. _this._deadKey = false;
  6782. _this._addKey = true;
  6783. _this._currentKey = "";
  6784. _this._isTextHighlightOn = false;
  6785. _this._textHighlightColor = "#d5e0ff";
  6786. _this._highligherOpacity = 0.4;
  6787. _this._highlightedText = "";
  6788. _this._startHighlightIndex = 0;
  6789. _this._endHighlightIndex = 0;
  6790. _this._cursorIndex = -1;
  6791. _this._onFocusSelectAll = false;
  6792. _this._isPointerDown = false;
  6793. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  6794. _this.promptMessage = "Please enter text:";
  6795. /** Observable raised when the text changes */
  6796. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6797. /** Observable raised just before an entered character is to be added */
  6798. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6799. /** Observable raised when the control gets the focus */
  6800. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6801. /** Observable raised when the control loses the focus */
  6802. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6803. /**Observable raised when the text is highlighted */
  6804. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6805. /**Observable raised when copy event is triggered */
  6806. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6807. /** Observable raised when cut event is triggered */
  6808. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6809. /** Observable raised when paste event is triggered */
  6810. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6811. /** Observable raised when a key event was processed */
  6812. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6813. _this.text = text;
  6814. _this.isPointerBlocker = true;
  6815. return _this;
  6816. }
  6817. Object.defineProperty(InputText.prototype, "maxWidth", {
  6818. /** Gets or sets the maximum width allowed by the control */
  6819. get: function () {
  6820. return this._maxWidth.toString(this._host);
  6821. },
  6822. set: function (value) {
  6823. if (this._maxWidth.toString(this._host) === value) {
  6824. return;
  6825. }
  6826. if (this._maxWidth.fromString(value)) {
  6827. this._markAsDirty();
  6828. }
  6829. },
  6830. enumerable: true,
  6831. configurable: true
  6832. });
  6833. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  6834. /** Gets the maximum width allowed by the control in pixels */
  6835. get: function () {
  6836. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  6837. },
  6838. enumerable: true,
  6839. configurable: true
  6840. });
  6841. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  6842. /** Gets or sets the text highlighter transparency; default: 0.4 */
  6843. get: function () {
  6844. return this._highligherOpacity;
  6845. },
  6846. set: function (value) {
  6847. if (this._highligherOpacity === value) {
  6848. return;
  6849. }
  6850. this._highligherOpacity = value;
  6851. this._markAsDirty();
  6852. },
  6853. enumerable: true,
  6854. configurable: true
  6855. });
  6856. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  6857. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  6858. get: function () {
  6859. return this._onFocusSelectAll;
  6860. },
  6861. set: function (value) {
  6862. if (this._onFocusSelectAll === value) {
  6863. return;
  6864. }
  6865. this._onFocusSelectAll = value;
  6866. this._markAsDirty();
  6867. },
  6868. enumerable: true,
  6869. configurable: true
  6870. });
  6871. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  6872. /** Gets or sets the text hightlight color */
  6873. get: function () {
  6874. return this._textHighlightColor;
  6875. },
  6876. set: function (value) {
  6877. if (this._textHighlightColor === value) {
  6878. return;
  6879. }
  6880. this._textHighlightColor = value;
  6881. this._markAsDirty();
  6882. },
  6883. enumerable: true,
  6884. configurable: true
  6885. });
  6886. Object.defineProperty(InputText.prototype, "margin", {
  6887. /** Gets or sets control margin */
  6888. get: function () {
  6889. return this._margin.toString(this._host);
  6890. },
  6891. set: function (value) {
  6892. if (this._margin.toString(this._host) === value) {
  6893. return;
  6894. }
  6895. if (this._margin.fromString(value)) {
  6896. this._markAsDirty();
  6897. }
  6898. },
  6899. enumerable: true,
  6900. configurable: true
  6901. });
  6902. Object.defineProperty(InputText.prototype, "marginInPixels", {
  6903. /** Gets control margin in pixels */
  6904. get: function () {
  6905. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  6906. },
  6907. enumerable: true,
  6908. configurable: true
  6909. });
  6910. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  6911. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  6912. get: function () {
  6913. return this._autoStretchWidth;
  6914. },
  6915. set: function (value) {
  6916. if (this._autoStretchWidth === value) {
  6917. return;
  6918. }
  6919. this._autoStretchWidth = value;
  6920. this._markAsDirty();
  6921. },
  6922. enumerable: true,
  6923. configurable: true
  6924. });
  6925. Object.defineProperty(InputText.prototype, "thickness", {
  6926. /** Gets or sets border thickness */
  6927. get: function () {
  6928. return this._thickness;
  6929. },
  6930. set: function (value) {
  6931. if (this._thickness === value) {
  6932. return;
  6933. }
  6934. this._thickness = value;
  6935. this._markAsDirty();
  6936. },
  6937. enumerable: true,
  6938. configurable: true
  6939. });
  6940. Object.defineProperty(InputText.prototype, "focusedBackground", {
  6941. /** Gets or sets the background color when focused */
  6942. get: function () {
  6943. return this._focusedBackground;
  6944. },
  6945. set: function (value) {
  6946. if (this._focusedBackground === value) {
  6947. return;
  6948. }
  6949. this._focusedBackground = value;
  6950. this._markAsDirty();
  6951. },
  6952. enumerable: true,
  6953. configurable: true
  6954. });
  6955. Object.defineProperty(InputText.prototype, "focusedColor", {
  6956. /** Gets or sets the background color when focused */
  6957. get: function () {
  6958. return this._focusedColor;
  6959. },
  6960. set: function (value) {
  6961. if (this._focusedColor === value) {
  6962. return;
  6963. }
  6964. this._focusedColor = value;
  6965. this._markAsDirty();
  6966. },
  6967. enumerable: true,
  6968. configurable: true
  6969. });
  6970. Object.defineProperty(InputText.prototype, "background", {
  6971. /** Gets or sets the background color */
  6972. get: function () {
  6973. return this._background;
  6974. },
  6975. set: function (value) {
  6976. if (this._background === value) {
  6977. return;
  6978. }
  6979. this._background = value;
  6980. this._markAsDirty();
  6981. },
  6982. enumerable: true,
  6983. configurable: true
  6984. });
  6985. Object.defineProperty(InputText.prototype, "placeholderColor", {
  6986. /** Gets or sets the placeholder color */
  6987. get: function () {
  6988. return this._placeholderColor;
  6989. },
  6990. set: function (value) {
  6991. if (this._placeholderColor === value) {
  6992. return;
  6993. }
  6994. this._placeholderColor = value;
  6995. this._markAsDirty();
  6996. },
  6997. enumerable: true,
  6998. configurable: true
  6999. });
  7000. Object.defineProperty(InputText.prototype, "placeholderText", {
  7001. /** Gets or sets the text displayed when the control is empty */
  7002. get: function () {
  7003. return this._placeholderText;
  7004. },
  7005. set: function (value) {
  7006. if (this._placeholderText === value) {
  7007. return;
  7008. }
  7009. this._placeholderText = value;
  7010. this._markAsDirty();
  7011. },
  7012. enumerable: true,
  7013. configurable: true
  7014. });
  7015. Object.defineProperty(InputText.prototype, "deadKey", {
  7016. /** Gets or sets the dead key flag */
  7017. get: function () {
  7018. return this._deadKey;
  7019. },
  7020. set: function (flag) {
  7021. this._deadKey = flag;
  7022. },
  7023. enumerable: true,
  7024. configurable: true
  7025. });
  7026. Object.defineProperty(InputText.prototype, "highlightedText", {
  7027. /** Gets or sets the highlight text */
  7028. get: function () {
  7029. return this._highlightedText;
  7030. },
  7031. set: function (text) {
  7032. if (this._highlightedText === text) {
  7033. return;
  7034. }
  7035. this._highlightedText = text;
  7036. this._markAsDirty();
  7037. },
  7038. enumerable: true,
  7039. configurable: true
  7040. });
  7041. Object.defineProperty(InputText.prototype, "addKey", {
  7042. /** Gets or sets if the current key should be added */
  7043. get: function () {
  7044. return this._addKey;
  7045. },
  7046. set: function (flag) {
  7047. this._addKey = flag;
  7048. },
  7049. enumerable: true,
  7050. configurable: true
  7051. });
  7052. Object.defineProperty(InputText.prototype, "currentKey", {
  7053. /** Gets or sets the value of the current key being entered */
  7054. get: function () {
  7055. return this._currentKey;
  7056. },
  7057. set: function (key) {
  7058. this._currentKey = key;
  7059. },
  7060. enumerable: true,
  7061. configurable: true
  7062. });
  7063. Object.defineProperty(InputText.prototype, "text", {
  7064. /** Gets or sets the text displayed in the control */
  7065. get: function () {
  7066. return this._text;
  7067. },
  7068. set: function (value) {
  7069. var valueAsString = value.toString(); // Forcing convertion
  7070. if (this._text === valueAsString) {
  7071. return;
  7072. }
  7073. this._text = valueAsString;
  7074. this._markAsDirty();
  7075. this.onTextChangedObservable.notifyObservers(this);
  7076. },
  7077. enumerable: true,
  7078. configurable: true
  7079. });
  7080. Object.defineProperty(InputText.prototype, "width", {
  7081. /** Gets or sets control width */
  7082. get: function () {
  7083. return this._width.toString(this._host);
  7084. },
  7085. set: function (value) {
  7086. if (this._width.toString(this._host) === value) {
  7087. return;
  7088. }
  7089. if (this._width.fromString(value)) {
  7090. this._markAsDirty();
  7091. }
  7092. this.autoStretchWidth = false;
  7093. },
  7094. enumerable: true,
  7095. configurable: true
  7096. });
  7097. /** @hidden */
  7098. InputText.prototype.onBlur = function () {
  7099. this._isFocused = false;
  7100. this._scrollLeft = null;
  7101. this._cursorOffset = 0;
  7102. clearTimeout(this._blinkTimeout);
  7103. this._markAsDirty();
  7104. this.onBlurObservable.notifyObservers(this);
  7105. this._host.unRegisterClipboardEvents();
  7106. if (this._onClipboardObserver) {
  7107. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  7108. }
  7109. var scene = this._host.getScene();
  7110. if (this._onPointerDblTapObserver && scene) {
  7111. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  7112. }
  7113. };
  7114. /** @hidden */
  7115. InputText.prototype.onFocus = function () {
  7116. var _this = this;
  7117. if (!this._isEnabled) {
  7118. return;
  7119. }
  7120. this._scrollLeft = null;
  7121. this._isFocused = true;
  7122. this._blinkIsEven = false;
  7123. this._cursorOffset = 0;
  7124. this._markAsDirty();
  7125. this.onFocusObservable.notifyObservers(this);
  7126. if (navigator.userAgent.indexOf("Mobile") !== -1) {
  7127. var value = prompt(this.promptMessage);
  7128. if (value !== null) {
  7129. this.text = value;
  7130. }
  7131. this._host.focusedControl = null;
  7132. return;
  7133. }
  7134. this._host.registerClipboardEvents();
  7135. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  7136. // process clipboard event, can be configured.
  7137. switch (clipboardInfo.type) {
  7138. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  7139. _this._onCopyText(clipboardInfo.event);
  7140. _this.onTextCopyObservable.notifyObservers(_this);
  7141. break;
  7142. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  7143. _this._onCutText(clipboardInfo.event);
  7144. _this.onTextCutObservable.notifyObservers(_this);
  7145. break;
  7146. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  7147. _this._onPasteText(clipboardInfo.event);
  7148. _this.onTextPasteObservable.notifyObservers(_this);
  7149. break;
  7150. default: return;
  7151. }
  7152. });
  7153. var scene = this._host.getScene();
  7154. if (scene) {
  7155. //register the pointer double tap event
  7156. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  7157. if (!_this._isFocused) {
  7158. return;
  7159. }
  7160. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  7161. _this._processDblClick(pointerInfo);
  7162. }
  7163. });
  7164. }
  7165. if (this._onFocusSelectAll) {
  7166. this._selectAllText();
  7167. }
  7168. };
  7169. InputText.prototype._getTypeName = function () {
  7170. return "InputText";
  7171. };
  7172. /**
  7173. * Function called to get the list of controls that should not steal the focus from this control
  7174. * @returns an array of controls
  7175. */
  7176. InputText.prototype.keepsFocusWith = function () {
  7177. if (!this._connectedVirtualKeyboard) {
  7178. return null;
  7179. }
  7180. return [this._connectedVirtualKeyboard];
  7181. };
  7182. /** @hidden */
  7183. InputText.prototype.processKey = function (keyCode, key, evt) {
  7184. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  7185. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  7186. return;
  7187. }
  7188. //select all
  7189. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  7190. this._selectAllText();
  7191. evt.preventDefault();
  7192. return;
  7193. }
  7194. // Specific cases
  7195. switch (keyCode) {
  7196. case 32: //SPACE
  7197. key = " "; //ie11 key for space is "Spacebar"
  7198. break;
  7199. case 191: //SLASH
  7200. if (evt) {
  7201. evt.preventDefault();
  7202. }
  7203. break;
  7204. case 8: // BACKSPACE
  7205. if (this._text && this._text.length > 0) {
  7206. //delete the highlighted text
  7207. if (this._isTextHighlightOn) {
  7208. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7209. this._isTextHighlightOn = false;
  7210. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7211. this._blinkIsEven = false;
  7212. if (evt) {
  7213. evt.preventDefault();
  7214. }
  7215. return;
  7216. }
  7217. //delete single character
  7218. if (this._cursorOffset === 0) {
  7219. this.text = this._text.substr(0, this._text.length - 1);
  7220. }
  7221. else {
  7222. var deletePosition = this._text.length - this._cursorOffset;
  7223. if (deletePosition > 0) {
  7224. this.text = this._text.slice(0, deletePosition - 1) + this._text.slice(deletePosition);
  7225. }
  7226. }
  7227. }
  7228. if (evt) {
  7229. evt.preventDefault();
  7230. }
  7231. return;
  7232. case 46: // DELETE
  7233. if (this._isTextHighlightOn) {
  7234. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7235. var decrementor = (this._endHighlightIndex - this._startHighlightIndex);
  7236. while (decrementor > 0 && this._cursorOffset > 0) {
  7237. this._cursorOffset--;
  7238. }
  7239. this._isTextHighlightOn = false;
  7240. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7241. if (evt) {
  7242. evt.preventDefault();
  7243. }
  7244. return;
  7245. }
  7246. if (this._text && this._text.length > 0 && this._cursorOffset > 0) {
  7247. var deletePosition = this._text.length - this._cursorOffset;
  7248. this.text = this._text.slice(0, deletePosition) + this._text.slice(deletePosition + 1);
  7249. this._cursorOffset--;
  7250. }
  7251. if (evt) {
  7252. evt.preventDefault();
  7253. }
  7254. return;
  7255. case 13: // RETURN
  7256. this._host.focusedControl = null;
  7257. this._isTextHighlightOn = false;
  7258. return;
  7259. case 35: // END
  7260. this._cursorOffset = 0;
  7261. this._blinkIsEven = false;
  7262. this._isTextHighlightOn = false;
  7263. this._markAsDirty();
  7264. return;
  7265. case 36: // HOME
  7266. this._cursorOffset = this._text.length;
  7267. this._blinkIsEven = false;
  7268. this._isTextHighlightOn = false;
  7269. this._markAsDirty();
  7270. return;
  7271. case 37: // LEFT
  7272. this._cursorOffset++;
  7273. if (this._cursorOffset > this._text.length) {
  7274. this._cursorOffset = this._text.length;
  7275. }
  7276. if (evt && evt.shiftKey) {
  7277. // update the cursor
  7278. this._blinkIsEven = false;
  7279. // shift + ctrl/cmd + <-
  7280. if (evt.ctrlKey || evt.metaKey) {
  7281. if (!this._isTextHighlightOn) {
  7282. if (this._text.length === this._cursorOffset) {
  7283. return;
  7284. }
  7285. else {
  7286. this._endHighlightIndex = this._text.length - this._cursorOffset + 1;
  7287. }
  7288. }
  7289. this._startHighlightIndex = 0;
  7290. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7291. this._cursorOffset = this._text.length;
  7292. this._isTextHighlightOn = true;
  7293. this._markAsDirty();
  7294. return;
  7295. }
  7296. //store the starting point
  7297. if (!this._isTextHighlightOn) {
  7298. this._isTextHighlightOn = true;
  7299. this._cursorIndex = (this._cursorOffset >= this._text.length) ? this._text.length : this._cursorOffset - 1;
  7300. }
  7301. //if text is already highlighted
  7302. else if (this._cursorIndex === -1) {
  7303. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7304. this._cursorOffset = (this._startHighlightIndex === 0) ? this._text.length : this._text.length - this._startHighlightIndex + 1;
  7305. }
  7306. //set the highlight indexes
  7307. if (this._cursorIndex < this._cursorOffset) {
  7308. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7309. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7310. }
  7311. else if (this._cursorIndex > this._cursorOffset) {
  7312. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7313. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7314. }
  7315. else {
  7316. this._isTextHighlightOn = false;
  7317. }
  7318. this._markAsDirty();
  7319. return;
  7320. }
  7321. if (this._isTextHighlightOn) {
  7322. this._cursorOffset = this._text.length - this._startHighlightIndex;
  7323. this._isTextHighlightOn = false;
  7324. }
  7325. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7326. this._cursorOffset = this.text.length;
  7327. evt.preventDefault();
  7328. }
  7329. this._blinkIsEven = false;
  7330. this._isTextHighlightOn = false;
  7331. this._cursorIndex = -1;
  7332. this._markAsDirty();
  7333. return;
  7334. case 39: // RIGHT
  7335. this._cursorOffset--;
  7336. if (this._cursorOffset < 0) {
  7337. this._cursorOffset = 0;
  7338. }
  7339. if (evt && evt.shiftKey) {
  7340. //update the cursor
  7341. this._blinkIsEven = false;
  7342. //shift + ctrl/cmd + ->
  7343. if (evt.ctrlKey || evt.metaKey) {
  7344. if (!this._isTextHighlightOn) {
  7345. if (this._cursorOffset === 0) {
  7346. return;
  7347. }
  7348. else {
  7349. this._startHighlightIndex = this._text.length - this._cursorOffset - 1;
  7350. }
  7351. }
  7352. this._endHighlightIndex = this._text.length;
  7353. this._isTextHighlightOn = true;
  7354. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7355. this._cursorOffset = 0;
  7356. this._markAsDirty();
  7357. return;
  7358. }
  7359. if (!this._isTextHighlightOn) {
  7360. this._isTextHighlightOn = true;
  7361. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  7362. }
  7363. //if text is already highlighted
  7364. else if (this._cursorIndex === -1) {
  7365. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7366. this._cursorOffset = (this._text.length === this._endHighlightIndex) ? 0 : this._text.length - this._endHighlightIndex - 1;
  7367. }
  7368. //set the highlight indexes
  7369. if (this._cursorIndex < this._cursorOffset) {
  7370. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7371. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7372. }
  7373. else if (this._cursorIndex > this._cursorOffset) {
  7374. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7375. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7376. }
  7377. else {
  7378. this._isTextHighlightOn = false;
  7379. }
  7380. this._markAsDirty();
  7381. return;
  7382. }
  7383. if (this._isTextHighlightOn) {
  7384. this._cursorOffset = this._text.length - this._endHighlightIndex;
  7385. this._isTextHighlightOn = false;
  7386. }
  7387. //ctr + ->
  7388. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7389. this._cursorOffset = 0;
  7390. evt.preventDefault();
  7391. }
  7392. this._blinkIsEven = false;
  7393. this._isTextHighlightOn = false;
  7394. this._cursorIndex = -1;
  7395. this._markAsDirty();
  7396. return;
  7397. case 222: // Dead
  7398. if (evt) {
  7399. evt.preventDefault();
  7400. }
  7401. this._cursorIndex = -1;
  7402. this.deadKey = true;
  7403. break;
  7404. }
  7405. // Printable characters
  7406. if (key &&
  7407. ((keyCode === -1) || // Direct access
  7408. (keyCode === 32) || // Space
  7409. (keyCode > 47 && keyCode < 64) || // Numbers
  7410. (keyCode > 64 && keyCode < 91) || // Letters
  7411. (keyCode > 159 && keyCode < 193) || // Special characters
  7412. (keyCode > 218 && keyCode < 223) || // Special characters
  7413. (keyCode > 95 && keyCode < 112))) { // Numpad
  7414. this._currentKey = key;
  7415. this.onBeforeKeyAddObservable.notifyObservers(this);
  7416. key = this._currentKey;
  7417. if (this._addKey) {
  7418. if (this._isTextHighlightOn) {
  7419. this.text = this._text.slice(0, this._startHighlightIndex) + key + this._text.slice(this._endHighlightIndex);
  7420. this._cursorOffset = this.text.length - (this._startHighlightIndex + 1);
  7421. this._isTextHighlightOn = false;
  7422. this._blinkIsEven = false;
  7423. this._markAsDirty();
  7424. }
  7425. else if (this._cursorOffset === 0) {
  7426. this.text += key;
  7427. }
  7428. else {
  7429. var insertPosition = this._text.length - this._cursorOffset;
  7430. this.text = this._text.slice(0, insertPosition) + key + this._text.slice(insertPosition);
  7431. }
  7432. }
  7433. }
  7434. };
  7435. /** @hidden */
  7436. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  7437. //update the cursor
  7438. this._blinkIsEven = false;
  7439. if (this._cursorIndex === -1) {
  7440. this._cursorIndex = offset;
  7441. }
  7442. else {
  7443. if (this._cursorIndex < this._cursorOffset) {
  7444. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7445. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7446. }
  7447. else if (this._cursorIndex > this._cursorOffset) {
  7448. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7449. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7450. }
  7451. else {
  7452. this._isTextHighlightOn = false;
  7453. this._markAsDirty();
  7454. return;
  7455. }
  7456. }
  7457. this._isTextHighlightOn = true;
  7458. this._markAsDirty();
  7459. };
  7460. /** @hidden */
  7461. InputText.prototype._processDblClick = function (evt) {
  7462. //pre-find the start and end index of the word under cursor, speeds up the rendering
  7463. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7464. this._endHighlightIndex = this._startHighlightIndex;
  7465. var rWord = /\w+/g, moveLeft, moveRight;
  7466. do {
  7467. moveRight = this._endHighlightIndex < this._text.length && (this._text[this._endHighlightIndex].search(rWord) !== -1) ? ++this._endHighlightIndex : 0;
  7468. moveLeft = this._startHighlightIndex > 0 && (this._text[this._startHighlightIndex - 1].search(rWord) !== -1) ? --this._startHighlightIndex : 0;
  7469. } while (moveLeft || moveRight);
  7470. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7471. this.onTextHighlightObservable.notifyObservers(this);
  7472. this._isTextHighlightOn = true;
  7473. this._clickedCoordinate = null;
  7474. this._blinkIsEven = true;
  7475. this._cursorIndex = -1;
  7476. this._markAsDirty();
  7477. };
  7478. /** @hidden */
  7479. InputText.prototype._selectAllText = function () {
  7480. this._blinkIsEven = true;
  7481. this._isTextHighlightOn = true;
  7482. this._startHighlightIndex = 0;
  7483. this._endHighlightIndex = this._text.length;
  7484. this._cursorOffset = this._text.length;
  7485. this._cursorIndex = -1;
  7486. this._markAsDirty();
  7487. };
  7488. /**
  7489. * Handles the keyboard event
  7490. * @param evt Defines the KeyboardEvent
  7491. */
  7492. InputText.prototype.processKeyboard = function (evt) {
  7493. // process pressed key
  7494. this.processKey(evt.keyCode, evt.key, evt);
  7495. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  7496. };
  7497. /** @hidden */
  7498. InputText.prototype._onCopyText = function (ev) {
  7499. this._isTextHighlightOn = false;
  7500. //when write permission to clipbaord data is denied
  7501. try {
  7502. ev.clipboardData.setData("text/plain", this._highlightedText);
  7503. }
  7504. catch (_a) { } //pass
  7505. this._host.clipboardData = this._highlightedText;
  7506. };
  7507. /** @hidden */
  7508. InputText.prototype._onCutText = function (ev) {
  7509. if (!this._highlightedText) {
  7510. return;
  7511. }
  7512. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7513. this._isTextHighlightOn = false;
  7514. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7515. //when write permission to clipbaord data is denied
  7516. try {
  7517. ev.clipboardData.setData("text/plain", this._highlightedText);
  7518. }
  7519. catch (_a) { } //pass
  7520. this._host.clipboardData = this._highlightedText;
  7521. this._highlightedText = "";
  7522. };
  7523. /** @hidden */
  7524. InputText.prototype._onPasteText = function (ev) {
  7525. var data = "";
  7526. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  7527. data = ev.clipboardData.getData("text/plain");
  7528. }
  7529. else {
  7530. //get the cached data; returns blank string by default
  7531. data = this._host.clipboardData;
  7532. }
  7533. var insertPosition = this._text.length - this._cursorOffset;
  7534. this.text = this._text.slice(0, insertPosition) + data + this._text.slice(insertPosition);
  7535. };
  7536. InputText.prototype._draw = function (context) {
  7537. var _this = this;
  7538. context.save();
  7539. this._applyStates(context);
  7540. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7541. context.shadowColor = this.shadowColor;
  7542. context.shadowBlur = this.shadowBlur;
  7543. context.shadowOffsetX = this.shadowOffsetX;
  7544. context.shadowOffsetY = this.shadowOffsetY;
  7545. }
  7546. // Background
  7547. if (this._isFocused) {
  7548. if (this._focusedBackground) {
  7549. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  7550. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7551. }
  7552. }
  7553. else if (this._background) {
  7554. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  7555. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7556. }
  7557. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7558. context.shadowBlur = 0;
  7559. context.shadowOffsetX = 0;
  7560. context.shadowOffsetY = 0;
  7561. }
  7562. if (!this._fontOffset) {
  7563. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  7564. }
  7565. // Text
  7566. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  7567. if (this.color) {
  7568. context.fillStyle = this.color;
  7569. }
  7570. var text = this._beforeRenderText(this._text);
  7571. if (!this._isFocused && !this._text && this._placeholderText) {
  7572. text = this._placeholderText;
  7573. if (this._placeholderColor) {
  7574. context.fillStyle = this._placeholderColor;
  7575. }
  7576. }
  7577. this._textWidth = context.measureText(text).width;
  7578. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  7579. if (this._autoStretchWidth) {
  7580. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  7581. }
  7582. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  7583. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  7584. context.save();
  7585. context.beginPath();
  7586. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  7587. context.clip();
  7588. if (this._isFocused && this._textWidth > availableWidth) {
  7589. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  7590. if (!this._scrollLeft) {
  7591. this._scrollLeft = textLeft;
  7592. }
  7593. }
  7594. else {
  7595. this._scrollLeft = clipTextLeft;
  7596. }
  7597. context.fillText(text, this._scrollLeft, this._currentMeasure.top + rootY);
  7598. // Cursor
  7599. if (this._isFocused) {
  7600. // Need to move cursor
  7601. if (this._clickedCoordinate) {
  7602. var rightPosition = this._scrollLeft + this._textWidth;
  7603. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  7604. var currentSize = 0;
  7605. this._cursorOffset = 0;
  7606. var previousDist = 0;
  7607. do {
  7608. if (this._cursorOffset) {
  7609. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  7610. }
  7611. this._cursorOffset++;
  7612. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  7613. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  7614. // Find closest move
  7615. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  7616. this._cursorOffset--;
  7617. }
  7618. this._blinkIsEven = false;
  7619. this._clickedCoordinate = null;
  7620. }
  7621. // Render cursor
  7622. if (!this._blinkIsEven) {
  7623. var cursorOffsetText = this.text.substr(this._text.length - this._cursorOffset);
  7624. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  7625. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  7626. if (cursorLeft < clipTextLeft) {
  7627. this._scrollLeft += (clipTextLeft - cursorLeft);
  7628. cursorLeft = clipTextLeft;
  7629. this._markAsDirty();
  7630. }
  7631. else if (cursorLeft > clipTextLeft + availableWidth) {
  7632. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  7633. cursorLeft = clipTextLeft + availableWidth;
  7634. this._markAsDirty();
  7635. }
  7636. if (!this._isTextHighlightOn) {
  7637. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  7638. }
  7639. }
  7640. clearTimeout(this._blinkTimeout);
  7641. this._blinkTimeout = setTimeout(function () {
  7642. _this._blinkIsEven = !_this._blinkIsEven;
  7643. _this._markAsDirty();
  7644. }, 500);
  7645. //show the highlighted text
  7646. if (this._isTextHighlightOn) {
  7647. clearTimeout(this._blinkTimeout);
  7648. var highlightCursorOffsetWidth = context.measureText(this.text.substring(this._startHighlightIndex)).width;
  7649. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  7650. this._highlightedText = this.text.substring(this._startHighlightIndex, this._endHighlightIndex);
  7651. var width = context.measureText(this.text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  7652. if (highlightCursorLeft < clipTextLeft) {
  7653. width = width - (clipTextLeft - highlightCursorLeft);
  7654. if (!width) {
  7655. // when using left arrow on text.length > availableWidth;
  7656. // assigns the width of the first letter after clipTextLeft
  7657. width = context.measureText(this.text.charAt(this.text.length - this._cursorOffset)).width;
  7658. }
  7659. highlightCursorLeft = clipTextLeft;
  7660. }
  7661. //for transparancy
  7662. context.globalAlpha = this._highligherOpacity;
  7663. context.fillStyle = this._textHighlightColor;
  7664. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  7665. context.globalAlpha = 1.0;
  7666. }
  7667. }
  7668. context.restore();
  7669. // Border
  7670. if (this._thickness) {
  7671. if (this._isFocused) {
  7672. if (this.focusedColor) {
  7673. context.strokeStyle = this.focusedColor;
  7674. }
  7675. }
  7676. else {
  7677. if (this.color) {
  7678. context.strokeStyle = this.color;
  7679. }
  7680. }
  7681. context.lineWidth = this._thickness;
  7682. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  7683. }
  7684. context.restore();
  7685. };
  7686. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  7687. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  7688. return false;
  7689. }
  7690. this._clickedCoordinate = coordinates.x;
  7691. this._isTextHighlightOn = false;
  7692. this._highlightedText = "";
  7693. this._cursorIndex = -1;
  7694. this._isPointerDown = true;
  7695. this._host._capturingControl[pointerId] = this;
  7696. if (this._host.focusedControl === this) {
  7697. // Move cursor
  7698. clearTimeout(this._blinkTimeout);
  7699. this._markAsDirty();
  7700. return true;
  7701. }
  7702. if (!this._isEnabled) {
  7703. return false;
  7704. }
  7705. this._host.focusedControl = this;
  7706. return true;
  7707. };
  7708. InputText.prototype._onPointerMove = function (target, coordinates) {
  7709. if (this._host.focusedControl === this && this._isPointerDown) {
  7710. this._clickedCoordinate = coordinates.x;
  7711. this._markAsDirty();
  7712. this._updateValueFromCursorIndex(this._cursorOffset);
  7713. }
  7714. _super.prototype._onPointerMove.call(this, target, coordinates);
  7715. };
  7716. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  7717. this._isPointerDown = false;
  7718. delete this._host._capturingControl[pointerId];
  7719. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  7720. };
  7721. InputText.prototype._beforeRenderText = function (text) {
  7722. return text;
  7723. };
  7724. InputText.prototype.dispose = function () {
  7725. _super.prototype.dispose.call(this);
  7726. this.onBlurObservable.clear();
  7727. this.onFocusObservable.clear();
  7728. this.onTextChangedObservable.clear();
  7729. this.onTextCopyObservable.clear();
  7730. this.onTextCutObservable.clear();
  7731. this.onTextPasteObservable.clear();
  7732. this.onTextHighlightObservable.clear();
  7733. this.onKeyboardEventProcessedObservable.clear();
  7734. };
  7735. return InputText;
  7736. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7737. /***/ }),
  7738. /***/ "./2D/controls/line.ts":
  7739. /*!*****************************!*\
  7740. !*** ./2D/controls/line.ts ***!
  7741. \*****************************/
  7742. /*! exports provided: Line */
  7743. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7744. "use strict";
  7745. __webpack_require__.r(__webpack_exports__);
  7746. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  7747. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7748. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  7749. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  7750. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7751. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7752. /** Class used to render 2D lines */
  7753. var Line = /** @class */ (function (_super) {
  7754. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Line, _super);
  7755. /**
  7756. * Creates a new Line
  7757. * @param name defines the control name
  7758. */
  7759. function Line(name) {
  7760. var _this = _super.call(this, name) || this;
  7761. _this.name = name;
  7762. _this._lineWidth = 1;
  7763. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7764. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7765. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7766. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7767. _this._dash = new Array();
  7768. _this.isHitTestVisible = false;
  7769. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  7770. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  7771. return _this;
  7772. }
  7773. Object.defineProperty(Line.prototype, "dash", {
  7774. /** Gets or sets the dash pattern */
  7775. get: function () {
  7776. return this._dash;
  7777. },
  7778. set: function (value) {
  7779. if (this._dash === value) {
  7780. return;
  7781. }
  7782. this._dash = value;
  7783. this._markAsDirty();
  7784. },
  7785. enumerable: true,
  7786. configurable: true
  7787. });
  7788. Object.defineProperty(Line.prototype, "connectedControl", {
  7789. /** Gets or sets the control connected with the line end */
  7790. get: function () {
  7791. return this._connectedControl;
  7792. },
  7793. set: function (value) {
  7794. var _this = this;
  7795. if (this._connectedControl === value) {
  7796. return;
  7797. }
  7798. if (this._connectedControlDirtyObserver && this._connectedControl) {
  7799. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  7800. this._connectedControlDirtyObserver = null;
  7801. }
  7802. if (value) {
  7803. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  7804. }
  7805. this._connectedControl = value;
  7806. this._markAsDirty();
  7807. },
  7808. enumerable: true,
  7809. configurable: true
  7810. });
  7811. Object.defineProperty(Line.prototype, "x1", {
  7812. /** Gets or sets start coordinates on X axis */
  7813. get: function () {
  7814. return this._x1.toString(this._host);
  7815. },
  7816. set: function (value) {
  7817. if (this._x1.toString(this._host) === value) {
  7818. return;
  7819. }
  7820. if (this._x1.fromString(value)) {
  7821. this._markAsDirty();
  7822. }
  7823. },
  7824. enumerable: true,
  7825. configurable: true
  7826. });
  7827. Object.defineProperty(Line.prototype, "y1", {
  7828. /** Gets or sets start coordinates on Y axis */
  7829. get: function () {
  7830. return this._y1.toString(this._host);
  7831. },
  7832. set: function (value) {
  7833. if (this._y1.toString(this._host) === value) {
  7834. return;
  7835. }
  7836. if (this._y1.fromString(value)) {
  7837. this._markAsDirty();
  7838. }
  7839. },
  7840. enumerable: true,
  7841. configurable: true
  7842. });
  7843. Object.defineProperty(Line.prototype, "x2", {
  7844. /** Gets or sets end coordinates on X axis */
  7845. get: function () {
  7846. return this._x2.toString(this._host);
  7847. },
  7848. set: function (value) {
  7849. if (this._x2.toString(this._host) === value) {
  7850. return;
  7851. }
  7852. if (this._x2.fromString(value)) {
  7853. this._markAsDirty();
  7854. }
  7855. },
  7856. enumerable: true,
  7857. configurable: true
  7858. });
  7859. Object.defineProperty(Line.prototype, "y2", {
  7860. /** Gets or sets end coordinates on Y axis */
  7861. get: function () {
  7862. return this._y2.toString(this._host);
  7863. },
  7864. set: function (value) {
  7865. if (this._y2.toString(this._host) === value) {
  7866. return;
  7867. }
  7868. if (this._y2.fromString(value)) {
  7869. this._markAsDirty();
  7870. }
  7871. },
  7872. enumerable: true,
  7873. configurable: true
  7874. });
  7875. Object.defineProperty(Line.prototype, "lineWidth", {
  7876. /** Gets or sets line width */
  7877. get: function () {
  7878. return this._lineWidth;
  7879. },
  7880. set: function (value) {
  7881. if (this._lineWidth === value) {
  7882. return;
  7883. }
  7884. this._lineWidth = value;
  7885. this._markAsDirty();
  7886. },
  7887. enumerable: true,
  7888. configurable: true
  7889. });
  7890. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  7891. /** Gets or sets horizontal alignment */
  7892. set: function (value) {
  7893. return;
  7894. },
  7895. enumerable: true,
  7896. configurable: true
  7897. });
  7898. Object.defineProperty(Line.prototype, "verticalAlignment", {
  7899. /** Gets or sets vertical alignment */
  7900. set: function (value) {
  7901. return;
  7902. },
  7903. enumerable: true,
  7904. configurable: true
  7905. });
  7906. Object.defineProperty(Line.prototype, "_effectiveX2", {
  7907. get: function () {
  7908. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  7909. },
  7910. enumerable: true,
  7911. configurable: true
  7912. });
  7913. Object.defineProperty(Line.prototype, "_effectiveY2", {
  7914. get: function () {
  7915. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  7916. },
  7917. enumerable: true,
  7918. configurable: true
  7919. });
  7920. Line.prototype._getTypeName = function () {
  7921. return "Line";
  7922. };
  7923. Line.prototype._draw = function (context) {
  7924. context.save();
  7925. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7926. context.shadowColor = this.shadowColor;
  7927. context.shadowBlur = this.shadowBlur;
  7928. context.shadowOffsetX = this.shadowOffsetX;
  7929. context.shadowOffsetY = this.shadowOffsetY;
  7930. }
  7931. this._applyStates(context);
  7932. context.strokeStyle = this.color;
  7933. context.lineWidth = this._lineWidth;
  7934. context.setLineDash(this._dash);
  7935. context.beginPath();
  7936. context.moveTo(this._x1.getValue(this._host), this._y1.getValue(this._host));
  7937. context.lineTo(this._effectiveX2, this._effectiveY2);
  7938. context.stroke();
  7939. context.restore();
  7940. };
  7941. Line.prototype._measure = function () {
  7942. // Width / Height
  7943. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  7944. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  7945. };
  7946. Line.prototype._computeAlignment = function (parentMeasure, context) {
  7947. this._currentMeasure.left = Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  7948. this._currentMeasure.top = Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  7949. };
  7950. /**
  7951. * Move one end of the line given 3D cartesian coordinates.
  7952. * @param position Targeted world position
  7953. * @param scene Scene
  7954. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  7955. */
  7956. Line.prototype.moveToVector3 = function (position, scene, end) {
  7957. if (end === void 0) { end = false; }
  7958. if (!this._host || this.parent !== this._host._rootContainer) {
  7959. babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  7960. return;
  7961. }
  7962. var globalViewport = this._host._getGlobalViewport(scene);
  7963. var projectedPosition = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  7964. this._moveToProjectedPosition(projectedPosition, end);
  7965. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  7966. this.notRenderable = true;
  7967. return;
  7968. }
  7969. this.notRenderable = false;
  7970. };
  7971. /**
  7972. * Move one end of the line to a position in screen absolute space.
  7973. * @param projectedPosition Position in screen absolute space (X, Y)
  7974. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  7975. */
  7976. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  7977. if (end === void 0) { end = false; }
  7978. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  7979. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  7980. if (end) {
  7981. this.x2 = x;
  7982. this.y2 = y;
  7983. this._x2.ignoreAdaptiveScaling = true;
  7984. this._y2.ignoreAdaptiveScaling = true;
  7985. }
  7986. else {
  7987. this.x1 = x;
  7988. this.y1 = y;
  7989. this._x1.ignoreAdaptiveScaling = true;
  7990. this._y1.ignoreAdaptiveScaling = true;
  7991. }
  7992. };
  7993. return Line;
  7994. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7995. /***/ }),
  7996. /***/ "./2D/controls/multiLine.ts":
  7997. /*!**********************************!*\
  7998. !*** ./2D/controls/multiLine.ts ***!
  7999. \**********************************/
  8000. /*! exports provided: MultiLine */
  8001. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8002. "use strict";
  8003. __webpack_require__.r(__webpack_exports__);
  8004. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  8005. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8006. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Misc/observable");
  8007. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  8008. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8009. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  8010. /**
  8011. * Class used to create multi line control
  8012. */
  8013. var MultiLine = /** @class */ (function (_super) {
  8014. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiLine, _super);
  8015. /**
  8016. * Creates a new MultiLine
  8017. * @param name defines the control name
  8018. */
  8019. function MultiLine(name) {
  8020. var _this = _super.call(this, name) || this;
  8021. _this.name = name;
  8022. _this._lineWidth = 1;
  8023. /** Function called when a point is updated */
  8024. _this.onPointUpdate = function () {
  8025. _this._markAsDirty();
  8026. };
  8027. _this.isHitTestVisible = false;
  8028. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8029. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8030. _this._dash = [];
  8031. _this._points = [];
  8032. return _this;
  8033. }
  8034. Object.defineProperty(MultiLine.prototype, "dash", {
  8035. /** Gets or sets dash pattern */
  8036. get: function () {
  8037. return this._dash;
  8038. },
  8039. set: function (value) {
  8040. if (this._dash === value) {
  8041. return;
  8042. }
  8043. this._dash = value;
  8044. this._markAsDirty();
  8045. },
  8046. enumerable: true,
  8047. configurable: true
  8048. });
  8049. /**
  8050. * Gets point stored at specified index
  8051. * @param index defines the index to look for
  8052. * @returns the requested point if found
  8053. */
  8054. MultiLine.prototype.getAt = function (index) {
  8055. if (!this._points[index]) {
  8056. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  8057. }
  8058. return this._points[index];
  8059. };
  8060. /**
  8061. * Adds new points to the point collection
  8062. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  8063. * @returns the list of created MultiLinePoint
  8064. */
  8065. MultiLine.prototype.add = function () {
  8066. var _this = this;
  8067. var items = [];
  8068. for (var _i = 0; _i < arguments.length; _i++) {
  8069. items[_i] = arguments[_i];
  8070. }
  8071. return items.map(function (item) { return _this.push(item); });
  8072. };
  8073. /**
  8074. * Adds a new point to the point collection
  8075. * @param item defines the item (mesh, control or 2d coordiantes) to add
  8076. * @returns the created MultiLinePoint
  8077. */
  8078. MultiLine.prototype.push = function (item) {
  8079. var point = this.getAt(this._points.length);
  8080. if (item == null) {
  8081. return point;
  8082. }
  8083. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  8084. point.mesh = item;
  8085. }
  8086. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  8087. point.control = item;
  8088. }
  8089. else if (item.x != null && item.y != null) {
  8090. point.x = item.x;
  8091. point.y = item.y;
  8092. }
  8093. return point;
  8094. };
  8095. /**
  8096. * Remove a specific value or point from the active point collection
  8097. * @param value defines the value or point to remove
  8098. */
  8099. MultiLine.prototype.remove = function (value) {
  8100. var index;
  8101. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  8102. index = this._points.indexOf(value);
  8103. if (index === -1) {
  8104. return;
  8105. }
  8106. }
  8107. else {
  8108. index = value;
  8109. }
  8110. var point = this._points[index];
  8111. if (!point) {
  8112. return;
  8113. }
  8114. point.dispose();
  8115. this._points.splice(index, 1);
  8116. };
  8117. /**
  8118. * Resets this object to initial state (no point)
  8119. */
  8120. MultiLine.prototype.reset = function () {
  8121. while (this._points.length > 0) {
  8122. this.remove(this._points.length - 1);
  8123. }
  8124. };
  8125. /**
  8126. * Resets all links
  8127. */
  8128. MultiLine.prototype.resetLinks = function () {
  8129. this._points.forEach(function (point) {
  8130. if (point != null) {
  8131. point.resetLinks();
  8132. }
  8133. });
  8134. };
  8135. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  8136. /** Gets or sets line width */
  8137. get: function () {
  8138. return this._lineWidth;
  8139. },
  8140. set: function (value) {
  8141. if (this._lineWidth === value) {
  8142. return;
  8143. }
  8144. this._lineWidth = value;
  8145. this._markAsDirty();
  8146. },
  8147. enumerable: true,
  8148. configurable: true
  8149. });
  8150. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  8151. set: function (value) {
  8152. return;
  8153. },
  8154. enumerable: true,
  8155. configurable: true
  8156. });
  8157. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  8158. set: function (value) {
  8159. return;
  8160. },
  8161. enumerable: true,
  8162. configurable: true
  8163. });
  8164. MultiLine.prototype._getTypeName = function () {
  8165. return "MultiLine";
  8166. };
  8167. MultiLine.prototype._draw = function (context) {
  8168. context.save();
  8169. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8170. context.shadowColor = this.shadowColor;
  8171. context.shadowBlur = this.shadowBlur;
  8172. context.shadowOffsetX = this.shadowOffsetX;
  8173. context.shadowOffsetY = this.shadowOffsetY;
  8174. }
  8175. this._applyStates(context);
  8176. context.strokeStyle = this.color;
  8177. context.lineWidth = this._lineWidth;
  8178. context.setLineDash(this._dash);
  8179. context.beginPath();
  8180. var first = true; //first index is not necessarily 0
  8181. this._points.forEach(function (point) {
  8182. if (!point) {
  8183. return;
  8184. }
  8185. if (first) {
  8186. context.moveTo(point._point.x, point._point.y);
  8187. first = false;
  8188. }
  8189. else {
  8190. context.lineTo(point._point.x, point._point.y);
  8191. }
  8192. });
  8193. context.stroke();
  8194. context.restore();
  8195. };
  8196. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  8197. var _this = this;
  8198. this._minX = null;
  8199. this._minY = null;
  8200. this._maxX = null;
  8201. this._maxY = null;
  8202. this._points.forEach(function (point, index) {
  8203. if (!point) {
  8204. return;
  8205. }
  8206. point.translate();
  8207. if (_this._minX == null || point._point.x < _this._minX) {
  8208. _this._minX = point._point.x;
  8209. }
  8210. if (_this._minY == null || point._point.y < _this._minY) {
  8211. _this._minY = point._point.y;
  8212. }
  8213. if (_this._maxX == null || point._point.x > _this._maxX) {
  8214. _this._maxX = point._point.x;
  8215. }
  8216. if (_this._maxY == null || point._point.y > _this._maxY) {
  8217. _this._maxY = point._point.y;
  8218. }
  8219. });
  8220. if (this._minX == null) {
  8221. this._minX = 0;
  8222. }
  8223. if (this._minY == null) {
  8224. this._minY = 0;
  8225. }
  8226. if (this._maxX == null) {
  8227. this._maxX = 0;
  8228. }
  8229. if (this._maxY == null) {
  8230. this._maxY = 0;
  8231. }
  8232. };
  8233. MultiLine.prototype._measure = function () {
  8234. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  8235. return;
  8236. }
  8237. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  8238. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  8239. };
  8240. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  8241. if (this._minX == null || this._minY == null) {
  8242. return;
  8243. }
  8244. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  8245. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  8246. };
  8247. MultiLine.prototype.dispose = function () {
  8248. this.reset();
  8249. _super.prototype.dispose.call(this);
  8250. };
  8251. return MultiLine;
  8252. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8253. /***/ }),
  8254. /***/ "./2D/controls/radioButton.ts":
  8255. /*!************************************!*\
  8256. !*** ./2D/controls/radioButton.ts ***!
  8257. \************************************/
  8258. /*! exports provided: RadioButton */
  8259. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8260. "use strict";
  8261. __webpack_require__.r(__webpack_exports__);
  8262. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  8263. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8264. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  8265. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  8266. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8267. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  8268. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  8269. /**
  8270. * Class used to create radio button controls
  8271. */
  8272. var RadioButton = /** @class */ (function (_super) {
  8273. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RadioButton, _super);
  8274. /**
  8275. * Creates a new RadioButton
  8276. * @param name defines the control name
  8277. */
  8278. function RadioButton(name) {
  8279. var _this = _super.call(this, name) || this;
  8280. _this.name = name;
  8281. _this._isChecked = false;
  8282. _this._background = "black";
  8283. _this._checkSizeRatio = 0.8;
  8284. _this._thickness = 1;
  8285. /** Gets or sets group name */
  8286. _this.group = "";
  8287. /** Observable raised when isChecked is changed */
  8288. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  8289. _this.isPointerBlocker = true;
  8290. return _this;
  8291. }
  8292. Object.defineProperty(RadioButton.prototype, "thickness", {
  8293. /** Gets or sets border thickness */
  8294. get: function () {
  8295. return this._thickness;
  8296. },
  8297. set: function (value) {
  8298. if (this._thickness === value) {
  8299. return;
  8300. }
  8301. this._thickness = value;
  8302. this._markAsDirty();
  8303. },
  8304. enumerable: true,
  8305. configurable: true
  8306. });
  8307. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  8308. /** Gets or sets a value indicating the ratio between overall size and check size */
  8309. get: function () {
  8310. return this._checkSizeRatio;
  8311. },
  8312. set: function (value) {
  8313. value = Math.max(Math.min(1, value), 0);
  8314. if (this._checkSizeRatio === value) {
  8315. return;
  8316. }
  8317. this._checkSizeRatio = value;
  8318. this._markAsDirty();
  8319. },
  8320. enumerable: true,
  8321. configurable: true
  8322. });
  8323. Object.defineProperty(RadioButton.prototype, "background", {
  8324. /** Gets or sets background color */
  8325. get: function () {
  8326. return this._background;
  8327. },
  8328. set: function (value) {
  8329. if (this._background === value) {
  8330. return;
  8331. }
  8332. this._background = value;
  8333. this._markAsDirty();
  8334. },
  8335. enumerable: true,
  8336. configurable: true
  8337. });
  8338. Object.defineProperty(RadioButton.prototype, "isChecked", {
  8339. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  8340. get: function () {
  8341. return this._isChecked;
  8342. },
  8343. set: function (value) {
  8344. var _this = this;
  8345. if (this._isChecked === value) {
  8346. return;
  8347. }
  8348. this._isChecked = value;
  8349. this._markAsDirty();
  8350. this.onIsCheckedChangedObservable.notifyObservers(value);
  8351. if (this._isChecked && this._host) {
  8352. // Update all controls from same group
  8353. this._host.executeOnAllControls(function (control) {
  8354. if (control === _this) {
  8355. return;
  8356. }
  8357. if (control.group === undefined) {
  8358. return;
  8359. }
  8360. var childRadio = control;
  8361. if (childRadio.group === _this.group) {
  8362. childRadio.isChecked = false;
  8363. }
  8364. });
  8365. }
  8366. },
  8367. enumerable: true,
  8368. configurable: true
  8369. });
  8370. RadioButton.prototype._getTypeName = function () {
  8371. return "RadioButton";
  8372. };
  8373. RadioButton.prototype._draw = function (context) {
  8374. context.save();
  8375. this._applyStates(context);
  8376. var actualWidth = this._currentMeasure.width - this._thickness;
  8377. var actualHeight = this._currentMeasure.height - this._thickness;
  8378. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8379. context.shadowColor = this.shadowColor;
  8380. context.shadowBlur = this.shadowBlur;
  8381. context.shadowOffsetX = this.shadowOffsetX;
  8382. context.shadowOffsetY = this.shadowOffsetY;
  8383. }
  8384. // Outer
  8385. _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);
  8386. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8387. context.fill();
  8388. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8389. context.shadowBlur = 0;
  8390. context.shadowOffsetX = 0;
  8391. context.shadowOffsetY = 0;
  8392. }
  8393. context.strokeStyle = this.color;
  8394. context.lineWidth = this._thickness;
  8395. context.stroke();
  8396. // Inner
  8397. if (this._isChecked) {
  8398. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  8399. var offsetWidth = actualWidth * this._checkSizeRatio;
  8400. var offseHeight = actualHeight * this._checkSizeRatio;
  8401. _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);
  8402. context.fill();
  8403. }
  8404. context.restore();
  8405. };
  8406. // Events
  8407. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8408. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8409. return false;
  8410. }
  8411. if (!this.isChecked) {
  8412. this.isChecked = true;
  8413. }
  8414. return true;
  8415. };
  8416. /**
  8417. * Utility function to easily create a radio button with a header
  8418. * @param title defines the label to use for the header
  8419. * @param group defines the group to use for the radio button
  8420. * @param isChecked defines the initial state of the radio button
  8421. * @param onValueChanged defines the callback to call when value changes
  8422. * @returns a StackPanel containing the radio button and a textBlock
  8423. */
  8424. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  8425. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  8426. panel.isVertical = false;
  8427. panel.height = "30px";
  8428. var radio = new RadioButton();
  8429. radio.width = "20px";
  8430. radio.height = "20px";
  8431. radio.isChecked = isChecked;
  8432. radio.color = "green";
  8433. radio.group = group;
  8434. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  8435. panel.addControl(radio);
  8436. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  8437. header.text = title;
  8438. header.width = "180px";
  8439. header.paddingLeft = "5px";
  8440. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8441. header.color = "white";
  8442. panel.addControl(header);
  8443. return panel;
  8444. };
  8445. return RadioButton;
  8446. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8447. /***/ }),
  8448. /***/ "./2D/controls/rectangle.ts":
  8449. /*!**********************************!*\
  8450. !*** ./2D/controls/rectangle.ts ***!
  8451. \**********************************/
  8452. /*! exports provided: Rectangle */
  8453. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8454. "use strict";
  8455. __webpack_require__.r(__webpack_exports__);
  8456. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  8457. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8458. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  8459. /** Class used to create rectangle container */
  8460. var Rectangle = /** @class */ (function (_super) {
  8461. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Rectangle, _super);
  8462. /**
  8463. * Creates a new Rectangle
  8464. * @param name defines the control name
  8465. */
  8466. function Rectangle(name) {
  8467. var _this = _super.call(this, name) || this;
  8468. _this.name = name;
  8469. _this._thickness = 1;
  8470. _this._cornerRadius = 0;
  8471. return _this;
  8472. }
  8473. Object.defineProperty(Rectangle.prototype, "thickness", {
  8474. /** Gets or sets border thickness */
  8475. get: function () {
  8476. return this._thickness;
  8477. },
  8478. set: function (value) {
  8479. if (this._thickness === value) {
  8480. return;
  8481. }
  8482. this._thickness = value;
  8483. this._markAsDirty();
  8484. },
  8485. enumerable: true,
  8486. configurable: true
  8487. });
  8488. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  8489. /** Gets or sets the corner radius angle */
  8490. get: function () {
  8491. return this._cornerRadius;
  8492. },
  8493. set: function (value) {
  8494. if (value < 0) {
  8495. value = 0;
  8496. }
  8497. if (this._cornerRadius === value) {
  8498. return;
  8499. }
  8500. this._cornerRadius = value;
  8501. this._markAsDirty();
  8502. },
  8503. enumerable: true,
  8504. configurable: true
  8505. });
  8506. Rectangle.prototype._getTypeName = function () {
  8507. return "Rectangle";
  8508. };
  8509. Rectangle.prototype._localDraw = function (context) {
  8510. context.save();
  8511. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8512. context.shadowColor = this.shadowColor;
  8513. context.shadowBlur = this.shadowBlur;
  8514. context.shadowOffsetX = this.shadowOffsetX;
  8515. context.shadowOffsetY = this.shadowOffsetY;
  8516. }
  8517. if (this._background) {
  8518. context.fillStyle = this._background;
  8519. if (this._cornerRadius) {
  8520. this._drawRoundedRect(context, this._thickness / 2);
  8521. context.fill();
  8522. }
  8523. else {
  8524. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8525. }
  8526. }
  8527. if (this._thickness) {
  8528. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8529. context.shadowBlur = 0;
  8530. context.shadowOffsetX = 0;
  8531. context.shadowOffsetY = 0;
  8532. }
  8533. if (this.color) {
  8534. context.strokeStyle = this.color;
  8535. }
  8536. context.lineWidth = this._thickness;
  8537. if (this._cornerRadius) {
  8538. this._drawRoundedRect(context, this._thickness / 2);
  8539. context.stroke();
  8540. }
  8541. else {
  8542. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8543. }
  8544. }
  8545. context.restore();
  8546. };
  8547. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  8548. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8549. this._measureForChildren.width -= 2 * this._thickness;
  8550. this._measureForChildren.height -= 2 * this._thickness;
  8551. this._measureForChildren.left += this._thickness;
  8552. this._measureForChildren.top += this._thickness;
  8553. };
  8554. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  8555. if (offset === void 0) { offset = 0; }
  8556. var x = this._currentMeasure.left + offset;
  8557. var y = this._currentMeasure.top + offset;
  8558. var width = this._currentMeasure.width - offset * 2;
  8559. var height = this._currentMeasure.height - offset * 2;
  8560. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  8561. context.beginPath();
  8562. context.moveTo(x + radius, y);
  8563. context.lineTo(x + width - radius, y);
  8564. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  8565. context.lineTo(x + width, y + height - radius);
  8566. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  8567. context.lineTo(x + radius, y + height);
  8568. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  8569. context.lineTo(x, y + radius);
  8570. context.quadraticCurveTo(x, y, x + radius, y);
  8571. context.closePath();
  8572. };
  8573. Rectangle.prototype._clipForChildren = function (context) {
  8574. if (this._cornerRadius) {
  8575. this._drawRoundedRect(context, this._thickness);
  8576. context.clip();
  8577. }
  8578. };
  8579. return Rectangle;
  8580. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  8581. /***/ }),
  8582. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  8583. /*!***************************************************!*\
  8584. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  8585. \***************************************************/
  8586. /*! exports provided: ScrollViewer */
  8587. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8588. "use strict";
  8589. __webpack_require__.r(__webpack_exports__);
  8590. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  8591. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8592. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Events/pointerEvents */ "babylonjs/Misc/observable");
  8593. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__);
  8594. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  8595. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  8596. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8597. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  8598. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  8599. /**
  8600. * Class used to hold a viewer window and sliders in a grid
  8601. */
  8602. var ScrollViewer = /** @class */ (function (_super) {
  8603. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScrollViewer, _super);
  8604. /**
  8605. * Creates a new ScrollViewer
  8606. * @param name of ScrollViewer
  8607. */
  8608. function ScrollViewer(name) {
  8609. var _this = _super.call(this, name) || this;
  8610. _this._barSize = 20;
  8611. _this._pointerIsOver = false;
  8612. _this._wheelPrecision = 0.05;
  8613. _this.onDirtyObservable.add(function () {
  8614. _this._horizontalBarSpace.color = _this.color;
  8615. _this._verticalBarSpace.color = _this.color;
  8616. _this._dragSpace.color = _this.color;
  8617. });
  8618. _this.onPointerEnterObservable.add(function () {
  8619. _this._pointerIsOver = true;
  8620. });
  8621. _this.onPointerOutObservable.add(function () {
  8622. _this._pointerIsOver = false;
  8623. });
  8624. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_3__["Grid"]();
  8625. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8626. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8627. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__["_ScrollViewerWindow"]();
  8628. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8629. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8630. _this._grid.addColumnDefinition(1);
  8631. _this._grid.addColumnDefinition(0, true);
  8632. _this._grid.addRowDefinition(1);
  8633. _this._grid.addRowDefinition(0, true);
  8634. _super.prototype.addControl.call(_this, _this._grid);
  8635. _this._grid.addControl(_this._window, 0, 0);
  8636. _this._verticalBar.paddingLeft = 0;
  8637. _this._verticalBar.width = "100%";
  8638. _this._verticalBar.height = "100%";
  8639. _this._verticalBar.barOffset = 0;
  8640. _this._verticalBar.value = 0;
  8641. _this._verticalBar.maximum = 1;
  8642. _this._verticalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8643. _this._verticalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8644. _this._verticalBar.isVertical = true;
  8645. _this._verticalBar.rotation = Math.PI;
  8646. _this._verticalBar.isVisible = false;
  8647. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8648. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8649. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8650. _this._verticalBarSpace.thickness = 1;
  8651. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  8652. _this._verticalBarSpace.addControl(_this._verticalBar);
  8653. _this._verticalBar.onValueChangedObservable.add(function (value) {
  8654. _this._window.top = value * _this._endTop + "px";
  8655. });
  8656. _this._horizontalBar.paddingLeft = 0;
  8657. _this._horizontalBar.width = "100%";
  8658. _this._horizontalBar.height = "100%";
  8659. _this._horizontalBar.barOffset = 0;
  8660. _this._horizontalBar.value = 0;
  8661. _this._horizontalBar.maximum = 1;
  8662. _this._horizontalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8663. _this._horizontalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8664. _this._horizontalBar.isVisible = false;
  8665. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8666. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8667. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8668. _this._horizontalBarSpace.thickness = 1;
  8669. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  8670. _this._horizontalBarSpace.addControl(_this._horizontalBar);
  8671. _this._horizontalBar.onValueChangedObservable.add(function (value) {
  8672. _this._window.left = value * _this._endLeft + "px";
  8673. });
  8674. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8675. _this._dragSpace.thickness = 1;
  8676. _this._grid.addControl(_this._dragSpace, 1, 1);
  8677. // Colors
  8678. _this.barColor = "grey";
  8679. _this.barBackground = "transparent";
  8680. return _this;
  8681. }
  8682. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  8683. /**
  8684. * Gets the horizontal scrollbar
  8685. */
  8686. get: function () {
  8687. return this._horizontalBar;
  8688. },
  8689. enumerable: true,
  8690. configurable: true
  8691. });
  8692. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  8693. /**
  8694. * Gets the vertical scrollbar
  8695. */
  8696. get: function () {
  8697. return this._verticalBar;
  8698. },
  8699. enumerable: true,
  8700. configurable: true
  8701. });
  8702. /**
  8703. * Adds a new control to the current container
  8704. * @param control defines the control to add
  8705. * @returns the current container
  8706. */
  8707. ScrollViewer.prototype.addControl = function (control) {
  8708. if (!control) {
  8709. return this;
  8710. }
  8711. this._window.addControl(control);
  8712. return this;
  8713. };
  8714. /**
  8715. * Removes a control from the current container
  8716. * @param control defines the control to remove
  8717. * @returns the current container
  8718. */
  8719. ScrollViewer.prototype.removeControl = function (control) {
  8720. this._window.removeControl(control);
  8721. return this;
  8722. };
  8723. Object.defineProperty(ScrollViewer.prototype, "children", {
  8724. /** Gets the list of children */
  8725. get: function () {
  8726. return this._window.children;
  8727. },
  8728. enumerable: true,
  8729. configurable: true
  8730. });
  8731. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  8732. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  8733. var child = _a[_i];
  8734. child._markMatrixAsDirty();
  8735. }
  8736. };
  8737. /** Reset the scroll viewer window to initial size */
  8738. ScrollViewer.prototype.resetWindow = function () {
  8739. this._window.width = "100%";
  8740. this._window.height = "100%";
  8741. };
  8742. ScrollViewer.prototype._getTypeName = function () {
  8743. return "ScrollViewer";
  8744. };
  8745. ScrollViewer.prototype._buildClientSizes = function () {
  8746. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8747. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8748. this._clientWidth = this._window.parentClientWidth;
  8749. this._clientHeight = this._window.parentClientHeight;
  8750. };
  8751. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  8752. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8753. this._buildClientSizes();
  8754. };
  8755. ScrollViewer.prototype._postMeasure = function () {
  8756. _super.prototype._postMeasure.call(this);
  8757. this._updateScroller();
  8758. };
  8759. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  8760. /**
  8761. * Gets or sets the mouse wheel precision
  8762. * from 0 to 1 with a default value of 0.05
  8763. * */
  8764. get: function () {
  8765. return this._wheelPrecision;
  8766. },
  8767. set: function (value) {
  8768. if (this._wheelPrecision === value) {
  8769. return;
  8770. }
  8771. if (value < 0) {
  8772. value = 0;
  8773. }
  8774. if (value > 1) {
  8775. value = 1;
  8776. }
  8777. this._wheelPrecision = value;
  8778. },
  8779. enumerable: true,
  8780. configurable: true
  8781. });
  8782. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  8783. /** Gets or sets the bar color */
  8784. get: function () {
  8785. return this._barColor;
  8786. },
  8787. set: function (color) {
  8788. if (this._barColor === color) {
  8789. return;
  8790. }
  8791. this._barColor = color;
  8792. this._horizontalBar.color = color;
  8793. this._verticalBar.color = color;
  8794. },
  8795. enumerable: true,
  8796. configurable: true
  8797. });
  8798. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  8799. /** Gets or sets the size of the bar */
  8800. get: function () {
  8801. return this._barSize;
  8802. },
  8803. set: function (value) {
  8804. if (this._barSize === value) {
  8805. return;
  8806. }
  8807. this._barSize = value;
  8808. this._markAsDirty();
  8809. if (this._horizontalBar.isVisible) {
  8810. this._grid.setRowDefinition(1, this._barSize, true);
  8811. }
  8812. if (this._verticalBar.isVisible) {
  8813. this._grid.setColumnDefinition(1, this._barSize, true);
  8814. }
  8815. },
  8816. enumerable: true,
  8817. configurable: true
  8818. });
  8819. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  8820. /** Gets or sets the bar background */
  8821. get: function () {
  8822. return this._barBackground;
  8823. },
  8824. set: function (color) {
  8825. if (this._barBackground === color) {
  8826. return;
  8827. }
  8828. this._barBackground = color;
  8829. this._horizontalBar.background = color;
  8830. this._verticalBar.background = color;
  8831. this._dragSpace.background = color;
  8832. },
  8833. enumerable: true,
  8834. configurable: true
  8835. });
  8836. /** @hidden */
  8837. ScrollViewer.prototype._updateScroller = function () {
  8838. var windowContentsWidth = this._window._currentMeasure.width;
  8839. var windowContentsHeight = this._window._currentMeasure.height;
  8840. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth) {
  8841. this._grid.setRowDefinition(1, 0, true);
  8842. this._horizontalBar.isVisible = false;
  8843. this._horizontalBar.value = 0;
  8844. this._rebuildLayout = true;
  8845. }
  8846. else if (!this._horizontalBar.isVisible && windowContentsWidth > this._clientWidth) {
  8847. this._grid.setRowDefinition(1, this._barSize, true);
  8848. this._horizontalBar.isVisible = true;
  8849. this._rebuildLayout = true;
  8850. }
  8851. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight) {
  8852. this._grid.setColumnDefinition(1, 0, true);
  8853. this._verticalBar.isVisible = false;
  8854. this._verticalBar.value = 0;
  8855. this._rebuildLayout = true;
  8856. }
  8857. else if (!this._verticalBar.isVisible && windowContentsHeight > this._clientHeight) {
  8858. this._grid.setColumnDefinition(1, this._barSize, true);
  8859. this._verticalBar.isVisible = true;
  8860. this._rebuildLayout = true;
  8861. }
  8862. this._buildClientSizes();
  8863. this._endLeft = this._clientWidth - windowContentsWidth;
  8864. this._endTop = this._clientHeight - windowContentsHeight;
  8865. var newLeft = this._horizontalBar.value * this._endLeft + "px";
  8866. var newTop = this._verticalBar.value * this._endTop + "px";
  8867. if (newLeft !== this._window.left) {
  8868. this._window.left = newLeft;
  8869. this._rebuildLayout = true;
  8870. }
  8871. if (newTop !== this._window.top) {
  8872. this._window.top = newTop;
  8873. this._rebuildLayout = true;
  8874. }
  8875. var horizontalMultiplicator = this._clientWidth / windowContentsWidth;
  8876. var verticalMultiplicator = this._clientHeight / windowContentsHeight;
  8877. this._horizontalBar.thumbWidth = (this._clientWidth * horizontalMultiplicator) + "px";
  8878. this._verticalBar.thumbWidth = (this._clientHeight * verticalMultiplicator) + "px";
  8879. };
  8880. ScrollViewer.prototype._link = function (host) {
  8881. _super.prototype._link.call(this, host);
  8882. this._attachWheel();
  8883. };
  8884. /** @hidden */
  8885. ScrollViewer.prototype._attachWheel = function () {
  8886. var _this = this;
  8887. if (this._onPointerObserver) {
  8888. return;
  8889. }
  8890. var scene = this._host.getScene();
  8891. this._onPointerObserver = scene.onPointerObservable.add(function (pi, state) {
  8892. if (!_this._pointerIsOver || pi.type !== babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  8893. return;
  8894. }
  8895. if (_this._verticalBar.isVisible == true) {
  8896. if (pi.event.deltaY < 0 && _this._verticalBar.value > 0) {
  8897. _this._verticalBar.value -= _this._wheelPrecision;
  8898. }
  8899. else if (pi.event.deltaY > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  8900. _this._verticalBar.value += _this._wheelPrecision;
  8901. }
  8902. }
  8903. if (_this._horizontalBar.isVisible == true) {
  8904. if (pi.event.deltaX < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  8905. _this._horizontalBar.value += _this._wheelPrecision;
  8906. }
  8907. else if (pi.event.deltaX > 0 && _this._horizontalBar.value > 0) {
  8908. _this._horizontalBar.value -= _this._wheelPrecision;
  8909. }
  8910. }
  8911. });
  8912. };
  8913. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  8914. if (!this.isHighlighted) {
  8915. return;
  8916. }
  8917. _super.prototype._renderHighlightSpecific.call(this, context);
  8918. this._grid._renderHighlightSpecific(context);
  8919. context.restore();
  8920. };
  8921. /** Releases associated resources */
  8922. ScrollViewer.prototype.dispose = function () {
  8923. var scene = this._host.getScene();
  8924. if (scene && this._onPointerObserver) {
  8925. scene.onPointerObservable.remove(this._onPointerObserver);
  8926. this._onPointerObserver = null;
  8927. }
  8928. _super.prototype.dispose.call(this);
  8929. };
  8930. return ScrollViewer;
  8931. }(_rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]));
  8932. /***/ }),
  8933. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  8934. /*!*********************************************************!*\
  8935. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  8936. \*********************************************************/
  8937. /*! exports provided: _ScrollViewerWindow */
  8938. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8939. "use strict";
  8940. __webpack_require__.r(__webpack_exports__);
  8941. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  8942. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8943. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  8944. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  8945. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8946. /**
  8947. * Class used to hold a the container for ScrollViewer
  8948. * @hidden
  8949. */
  8950. var _ScrollViewerWindow = /** @class */ (function (_super) {
  8951. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](_ScrollViewerWindow, _super);
  8952. /**
  8953. * Creates a new ScrollViewerWindow
  8954. * @param name of ScrollViewerWindow
  8955. */
  8956. function _ScrollViewerWindow(name) {
  8957. return _super.call(this, name) || this;
  8958. }
  8959. _ScrollViewerWindow.prototype._getTypeName = function () {
  8960. return "ScrollViewerWindow";
  8961. };
  8962. /** @hidden */
  8963. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  8964. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8965. this._measureForChildren.left = this._currentMeasure.left;
  8966. this._measureForChildren.top = this._currentMeasure.top;
  8967. this._measureForChildren.width = parentMeasure.width;
  8968. this._measureForChildren.height = parentMeasure.height;
  8969. };
  8970. _ScrollViewerWindow.prototype._postMeasure = function () {
  8971. var maxWidth = this.parentClientWidth;
  8972. var maxHeight = this.parentClientHeight;
  8973. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  8974. var child = _a[_i];
  8975. if (!child.isVisible || child.notRenderable) {
  8976. continue;
  8977. }
  8978. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  8979. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  8980. }
  8981. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  8982. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  8983. }
  8984. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width);
  8985. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height);
  8986. }
  8987. if (this._currentMeasure.width !== maxWidth) {
  8988. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  8989. this._currentMeasure.width = maxWidth;
  8990. this._rebuildLayout = true;
  8991. this._isDirty = true;
  8992. }
  8993. if (this._currentMeasure.height !== maxHeight) {
  8994. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  8995. this._currentMeasure.height = maxHeight;
  8996. this._rebuildLayout = true;
  8997. this._isDirty = true;
  8998. }
  8999. _super.prototype._postMeasure.call(this);
  9000. };
  9001. return _ScrollViewerWindow;
  9002. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  9003. /***/ }),
  9004. /***/ "./2D/controls/selector.ts":
  9005. /*!*********************************!*\
  9006. !*** ./2D/controls/selector.ts ***!
  9007. \*********************************/
  9008. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  9009. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9010. "use strict";
  9011. __webpack_require__.r(__webpack_exports__);
  9012. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  9013. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  9014. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  9015. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  9016. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  9017. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9018. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  9019. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  9020. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  9021. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  9022. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  9023. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  9024. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  9025. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  9026. /** Class used to create a RadioGroup
  9027. * which contains groups of radio buttons
  9028. */
  9029. var SelectorGroup = /** @class */ (function () {
  9030. /**
  9031. * Creates a new SelectorGroup
  9032. * @param name of group, used as a group heading
  9033. */
  9034. function SelectorGroup(
  9035. /** name of SelectorGroup */
  9036. name) {
  9037. this.name = name;
  9038. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9039. this._selectors = new Array();
  9040. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9041. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9042. this._groupHeader = this._addGroupHeader(name);
  9043. }
  9044. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  9045. /** Gets the groupPanel of the SelectorGroup */
  9046. get: function () {
  9047. return this._groupPanel;
  9048. },
  9049. enumerable: true,
  9050. configurable: true
  9051. });
  9052. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  9053. /** Gets the selectors array */
  9054. get: function () {
  9055. return this._selectors;
  9056. },
  9057. enumerable: true,
  9058. configurable: true
  9059. });
  9060. Object.defineProperty(SelectorGroup.prototype, "header", {
  9061. /** Gets and sets the group header */
  9062. get: function () {
  9063. return this._groupHeader.text;
  9064. },
  9065. set: function (label) {
  9066. if (this._groupHeader.text === "label") {
  9067. return;
  9068. }
  9069. this._groupHeader.text = label;
  9070. },
  9071. enumerable: true,
  9072. configurable: true
  9073. });
  9074. /** @hidden */
  9075. SelectorGroup.prototype._addGroupHeader = function (text) {
  9076. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  9077. groupHeading.width = 0.9;
  9078. groupHeading.height = "30px";
  9079. groupHeading.textWrapping = true;
  9080. groupHeading.color = "black";
  9081. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9082. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9083. groupHeading.left = "2px";
  9084. this._groupPanel.addControl(groupHeading);
  9085. return groupHeading;
  9086. };
  9087. /** @hidden*/
  9088. SelectorGroup.prototype._getSelector = function (selectorNb) {
  9089. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9090. return;
  9091. }
  9092. return this._selectors[selectorNb];
  9093. };
  9094. /** Removes the selector at the given position
  9095. * @param selectorNb the position of the selector within the group
  9096. */
  9097. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  9098. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9099. return;
  9100. }
  9101. this._groupPanel.removeControl(this._selectors[selectorNb]);
  9102. this._selectors.splice(selectorNb, 1);
  9103. };
  9104. return SelectorGroup;
  9105. }());
  9106. /** Class used to create a CheckboxGroup
  9107. * which contains groups of checkbox buttons
  9108. */
  9109. var CheckboxGroup = /** @class */ (function (_super) {
  9110. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CheckboxGroup, _super);
  9111. function CheckboxGroup() {
  9112. return _super !== null && _super.apply(this, arguments) || this;
  9113. }
  9114. /** Adds a checkbox as a control
  9115. * @param text is the label for the selector
  9116. * @param func is the function called when the Selector is checked
  9117. * @param checked is true when Selector is checked
  9118. */
  9119. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  9120. if (func === void 0) { func = function (s) { }; }
  9121. if (checked === void 0) { checked = false; }
  9122. var checked = checked || false;
  9123. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  9124. button.width = "20px";
  9125. button.height = "20px";
  9126. button.color = "#364249";
  9127. button.background = "#CCCCCC";
  9128. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9129. button.onIsCheckedChangedObservable.add(function (state) {
  9130. func(state);
  9131. });
  9132. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  9133. _selector.height = "30px";
  9134. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9135. _selector.left = "4px";
  9136. this.groupPanel.addControl(_selector);
  9137. this.selectors.push(_selector);
  9138. button.isChecked = checked;
  9139. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9140. button.color = this.groupPanel.parent.parent.buttonColor;
  9141. button.background = this.groupPanel.parent.parent.buttonBackground;
  9142. }
  9143. };
  9144. /** @hidden */
  9145. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9146. this.selectors[selectorNb].children[1].text = label;
  9147. };
  9148. /** @hidden */
  9149. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9150. this.selectors[selectorNb].children[1].color = color;
  9151. };
  9152. /** @hidden */
  9153. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9154. this.selectors[selectorNb].children[0].color = color;
  9155. };
  9156. /** @hidden */
  9157. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9158. this.selectors[selectorNb].children[0].background = color;
  9159. };
  9160. return CheckboxGroup;
  9161. }(SelectorGroup));
  9162. /** Class used to create a RadioGroup
  9163. * which contains groups of radio buttons
  9164. */
  9165. var RadioGroup = /** @class */ (function (_super) {
  9166. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RadioGroup, _super);
  9167. function RadioGroup() {
  9168. var _this = _super !== null && _super.apply(this, arguments) || this;
  9169. _this._selectNb = 0;
  9170. return _this;
  9171. }
  9172. /** Adds a radio button as a control
  9173. * @param label is the label for the selector
  9174. * @param func is the function called when the Selector is checked
  9175. * @param checked is true when Selector is checked
  9176. */
  9177. RadioGroup.prototype.addRadio = function (label, func, checked) {
  9178. if (func === void 0) { func = function (n) { }; }
  9179. if (checked === void 0) { checked = false; }
  9180. var nb = this._selectNb++;
  9181. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  9182. button.name = label;
  9183. button.width = "20px";
  9184. button.height = "20px";
  9185. button.color = "#364249";
  9186. button.background = "#CCCCCC";
  9187. button.group = this.name;
  9188. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9189. button.onIsCheckedChangedObservable.add(function (state) {
  9190. if (state) {
  9191. func(nb);
  9192. }
  9193. });
  9194. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  9195. _selector.height = "30px";
  9196. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9197. _selector.left = "4px";
  9198. this.groupPanel.addControl(_selector);
  9199. this.selectors.push(_selector);
  9200. button.isChecked = checked;
  9201. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9202. button.color = this.groupPanel.parent.parent.buttonColor;
  9203. button.background = this.groupPanel.parent.parent.buttonBackground;
  9204. }
  9205. };
  9206. /** @hidden */
  9207. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9208. this.selectors[selectorNb].children[1].text = label;
  9209. };
  9210. /** @hidden */
  9211. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9212. this.selectors[selectorNb].children[1].color = color;
  9213. };
  9214. /** @hidden */
  9215. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9216. this.selectors[selectorNb].children[0].color = color;
  9217. };
  9218. /** @hidden */
  9219. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9220. this.selectors[selectorNb].children[0].background = color;
  9221. };
  9222. return RadioGroup;
  9223. }(SelectorGroup));
  9224. /** Class used to create a SliderGroup
  9225. * which contains groups of slider buttons
  9226. */
  9227. var SliderGroup = /** @class */ (function (_super) {
  9228. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SliderGroup, _super);
  9229. function SliderGroup() {
  9230. return _super !== null && _super.apply(this, arguments) || this;
  9231. }
  9232. /**
  9233. * Adds a slider to the SelectorGroup
  9234. * @param label is the label for the SliderBar
  9235. * @param func is the function called when the Slider moves
  9236. * @param unit is a string describing the units used, eg degrees or metres
  9237. * @param min is the minimum value for the Slider
  9238. * @param max is the maximum value for the Slider
  9239. * @param value is the start value for the Slider between min and max
  9240. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  9241. */
  9242. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  9243. if (func === void 0) { func = function (v) { }; }
  9244. if (unit === void 0) { unit = "Units"; }
  9245. if (min === void 0) { min = 0; }
  9246. if (max === void 0) { max = 0; }
  9247. if (value === void 0) { value = 0; }
  9248. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  9249. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  9250. button.name = unit;
  9251. button.value = value;
  9252. button.minimum = min;
  9253. button.maximum = max;
  9254. button.width = 0.9;
  9255. button.height = "20px";
  9256. button.color = "#364249";
  9257. button.background = "#CCCCCC";
  9258. button.borderColor = "black";
  9259. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9260. button.left = "4px";
  9261. button.paddingBottom = "4px";
  9262. button.onValueChangedObservable.add(function (value) {
  9263. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  9264. func(value);
  9265. });
  9266. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  9267. _selector.height = "60px";
  9268. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9269. _selector.left = "4px";
  9270. _selector.children[0].name = label;
  9271. this.groupPanel.addControl(_selector);
  9272. this.selectors.push(_selector);
  9273. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9274. button.color = this.groupPanel.parent.parent.buttonColor;
  9275. button.background = this.groupPanel.parent.parent.buttonBackground;
  9276. }
  9277. };
  9278. /** @hidden */
  9279. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9280. this.selectors[selectorNb].children[0].name = label;
  9281. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  9282. };
  9283. /** @hidden */
  9284. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9285. this.selectors[selectorNb].children[0].color = color;
  9286. };
  9287. /** @hidden */
  9288. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9289. this.selectors[selectorNb].children[1].color = color;
  9290. };
  9291. /** @hidden */
  9292. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9293. this.selectors[selectorNb].children[1].background = color;
  9294. };
  9295. return SliderGroup;
  9296. }(SelectorGroup));
  9297. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  9298. * @see http://doc.babylonjs.com/how_to/selector
  9299. */
  9300. var SelectionPanel = /** @class */ (function (_super) {
  9301. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SelectionPanel, _super);
  9302. /**
  9303. * Creates a new SelectionPanel
  9304. * @param name of SelectionPanel
  9305. * @param groups is an array of SelectionGroups
  9306. */
  9307. function SelectionPanel(
  9308. /** name of SelectionPanel */
  9309. name,
  9310. /** an array of SelectionGroups */
  9311. groups) {
  9312. if (groups === void 0) { groups = []; }
  9313. var _this = _super.call(this, name) || this;
  9314. _this.name = name;
  9315. _this.groups = groups;
  9316. _this._buttonColor = "#364249";
  9317. _this._buttonBackground = "#CCCCCC";
  9318. _this._headerColor = "black";
  9319. _this._barColor = "white";
  9320. _this._barHeight = "2px";
  9321. _this._spacerHeight = "20px";
  9322. _this._bars = new Array();
  9323. _this._groups = groups;
  9324. _this.thickness = 2;
  9325. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9326. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9327. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9328. _this._panel.top = 5;
  9329. _this._panel.left = 5;
  9330. _this._panel.width = 0.95;
  9331. if (groups.length > 0) {
  9332. for (var i = 0; i < groups.length - 1; i++) {
  9333. _this._panel.addControl(groups[i].groupPanel);
  9334. _this._addSpacer();
  9335. }
  9336. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  9337. }
  9338. _this.addControl(_this._panel);
  9339. return _this;
  9340. }
  9341. SelectionPanel.prototype._getTypeName = function () {
  9342. return "SelectionPanel";
  9343. };
  9344. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  9345. /** Gets or sets the headerColor */
  9346. get: function () {
  9347. return this._headerColor;
  9348. },
  9349. set: function (color) {
  9350. if (this._headerColor === color) {
  9351. return;
  9352. }
  9353. this._headerColor = color;
  9354. this._setHeaderColor();
  9355. },
  9356. enumerable: true,
  9357. configurable: true
  9358. });
  9359. SelectionPanel.prototype._setHeaderColor = function () {
  9360. for (var i = 0; i < this._groups.length; i++) {
  9361. this._groups[i].groupPanel.children[0].color = this._headerColor;
  9362. }
  9363. };
  9364. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  9365. /** Gets or sets the button color */
  9366. get: function () {
  9367. return this._buttonColor;
  9368. },
  9369. set: function (color) {
  9370. if (this._buttonColor === color) {
  9371. return;
  9372. }
  9373. this._buttonColor = color;
  9374. this._setbuttonColor();
  9375. },
  9376. enumerable: true,
  9377. configurable: true
  9378. });
  9379. SelectionPanel.prototype._setbuttonColor = function () {
  9380. for (var i = 0; i < this._groups.length; i++) {
  9381. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9382. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  9383. }
  9384. }
  9385. };
  9386. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  9387. /** Gets or sets the label color */
  9388. get: function () {
  9389. return this._labelColor;
  9390. },
  9391. set: function (color) {
  9392. if (this._labelColor === color) {
  9393. return;
  9394. }
  9395. this._labelColor = color;
  9396. this._setLabelColor();
  9397. },
  9398. enumerable: true,
  9399. configurable: true
  9400. });
  9401. SelectionPanel.prototype._setLabelColor = function () {
  9402. for (var i = 0; i < this._groups.length; i++) {
  9403. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9404. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  9405. }
  9406. }
  9407. };
  9408. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  9409. /** Gets or sets the button background */
  9410. get: function () {
  9411. return this._buttonBackground;
  9412. },
  9413. set: function (color) {
  9414. if (this._buttonBackground === color) {
  9415. return;
  9416. }
  9417. this._buttonBackground = color;
  9418. this._setButtonBackground();
  9419. },
  9420. enumerable: true,
  9421. configurable: true
  9422. });
  9423. SelectionPanel.prototype._setButtonBackground = function () {
  9424. for (var i = 0; i < this._groups.length; i++) {
  9425. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9426. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  9427. }
  9428. }
  9429. };
  9430. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  9431. /** Gets or sets the color of separator bar */
  9432. get: function () {
  9433. return this._barColor;
  9434. },
  9435. set: function (color) {
  9436. if (this._barColor === color) {
  9437. return;
  9438. }
  9439. this._barColor = color;
  9440. this._setBarColor();
  9441. },
  9442. enumerable: true,
  9443. configurable: true
  9444. });
  9445. SelectionPanel.prototype._setBarColor = function () {
  9446. for (var i = 0; i < this._bars.length; i++) {
  9447. this._bars[i].children[0].background = this._barColor;
  9448. }
  9449. };
  9450. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  9451. /** Gets or sets the height of separator bar */
  9452. get: function () {
  9453. return this._barHeight;
  9454. },
  9455. set: function (value) {
  9456. if (this._barHeight === value) {
  9457. return;
  9458. }
  9459. this._barHeight = value;
  9460. this._setBarHeight();
  9461. },
  9462. enumerable: true,
  9463. configurable: true
  9464. });
  9465. SelectionPanel.prototype._setBarHeight = function () {
  9466. for (var i = 0; i < this._bars.length; i++) {
  9467. this._bars[i].children[0].height = this._barHeight;
  9468. }
  9469. };
  9470. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  9471. /** Gets or sets the height of spacers*/
  9472. get: function () {
  9473. return this._spacerHeight;
  9474. },
  9475. set: function (value) {
  9476. if (this._spacerHeight === value) {
  9477. return;
  9478. }
  9479. this._spacerHeight = value;
  9480. this._setSpacerHeight();
  9481. },
  9482. enumerable: true,
  9483. configurable: true
  9484. });
  9485. SelectionPanel.prototype._setSpacerHeight = function () {
  9486. for (var i = 0; i < this._bars.length; i++) {
  9487. this._bars[i].height = this._spacerHeight;
  9488. }
  9489. };
  9490. /** Adds a bar between groups */
  9491. SelectionPanel.prototype._addSpacer = function () {
  9492. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  9493. separator.width = 1;
  9494. separator.height = this._spacerHeight;
  9495. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9496. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9497. bar.width = 1;
  9498. bar.height = this._barHeight;
  9499. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9500. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9501. bar.background = this._barColor;
  9502. bar.color = "transparent";
  9503. separator.addControl(bar);
  9504. this._panel.addControl(separator);
  9505. this._bars.push(separator);
  9506. };
  9507. /** Add a group to the selection panel
  9508. * @param group is the selector group to add
  9509. */
  9510. SelectionPanel.prototype.addGroup = function (group) {
  9511. if (this._groups.length > 0) {
  9512. this._addSpacer();
  9513. }
  9514. this._panel.addControl(group.groupPanel);
  9515. this._groups.push(group);
  9516. group.groupPanel.children[0].color = this._headerColor;
  9517. for (var j = 0; j < group.selectors.length; j++) {
  9518. group._setSelectorButtonColor(j, this._buttonColor);
  9519. group._setSelectorButtonBackground(j, this._buttonBackground);
  9520. }
  9521. };
  9522. /** Remove the group from the given position
  9523. * @param groupNb is the position of the group in the list
  9524. */
  9525. SelectionPanel.prototype.removeGroup = function (groupNb) {
  9526. if (groupNb < 0 || groupNb >= this._groups.length) {
  9527. return;
  9528. }
  9529. var group = this._groups[groupNb];
  9530. this._panel.removeControl(group.groupPanel);
  9531. this._groups.splice(groupNb, 1);
  9532. if (groupNb < this._bars.length) {
  9533. this._panel.removeControl(this._bars[groupNb]);
  9534. this._bars.splice(groupNb, 1);
  9535. }
  9536. };
  9537. /** Change a group header label
  9538. * @param label is the new group header label
  9539. * @param groupNb is the number of the group to relabel
  9540. * */
  9541. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  9542. if (groupNb < 0 || groupNb >= this._groups.length) {
  9543. return;
  9544. }
  9545. var group = this._groups[groupNb];
  9546. group.groupPanel.children[0].text = label;
  9547. };
  9548. /** Change selector label to the one given
  9549. * @param label is the new selector label
  9550. * @param groupNb is the number of the groupcontaining the selector
  9551. * @param selectorNb is the number of the selector within a group to relabel
  9552. * */
  9553. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  9554. if (groupNb < 0 || groupNb >= this._groups.length) {
  9555. return;
  9556. }
  9557. var group = this._groups[groupNb];
  9558. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9559. return;
  9560. }
  9561. group._setSelectorLabel(selectorNb, label);
  9562. };
  9563. /** For a given group position remove the selector at the given position
  9564. * @param groupNb is the number of the group to remove the selector from
  9565. * @param selectorNb is the number of the selector within the group
  9566. */
  9567. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  9568. if (groupNb < 0 || groupNb >= this._groups.length) {
  9569. return;
  9570. }
  9571. var group = this._groups[groupNb];
  9572. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9573. return;
  9574. }
  9575. group.removeSelector(selectorNb);
  9576. };
  9577. /** For a given group position of correct type add a checkbox button
  9578. * @param groupNb is the number of the group to remove the selector from
  9579. * @param label is the label for the selector
  9580. * @param func is the function called when the Selector is checked
  9581. * @param checked is true when Selector is checked
  9582. */
  9583. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  9584. if (func === void 0) { func = function () { }; }
  9585. if (checked === void 0) { checked = false; }
  9586. if (groupNb < 0 || groupNb >= this._groups.length) {
  9587. return;
  9588. }
  9589. var group = this._groups[groupNb];
  9590. group.addCheckbox(label, func, checked);
  9591. };
  9592. /** For a given group position of correct type add a radio button
  9593. * @param groupNb is the number of the group to remove the selector from
  9594. * @param label is the label for the selector
  9595. * @param func is the function called when the Selector is checked
  9596. * @param checked is true when Selector is checked
  9597. */
  9598. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  9599. if (func === void 0) { func = function () { }; }
  9600. if (checked === void 0) { checked = false; }
  9601. if (groupNb < 0 || groupNb >= this._groups.length) {
  9602. return;
  9603. }
  9604. var group = this._groups[groupNb];
  9605. group.addRadio(label, func, checked);
  9606. };
  9607. /**
  9608. * For a given slider group add a slider
  9609. * @param groupNb is the number of the group to add the slider to
  9610. * @param label is the label for the Slider
  9611. * @param func is the function called when the Slider moves
  9612. * @param unit is a string describing the units used, eg degrees or metres
  9613. * @param min is the minimum value for the Slider
  9614. * @param max is the maximum value for the Slider
  9615. * @param value is the start value for the Slider between min and max
  9616. * @param onVal is the function used to format the value displayed, eg radians to degrees
  9617. */
  9618. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  9619. if (func === void 0) { func = function () { }; }
  9620. if (unit === void 0) { unit = "Units"; }
  9621. if (min === void 0) { min = 0; }
  9622. if (max === void 0) { max = 0; }
  9623. if (value === void 0) { value = 0; }
  9624. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  9625. if (groupNb < 0 || groupNb >= this._groups.length) {
  9626. return;
  9627. }
  9628. var group = this._groups[groupNb];
  9629. group.addSlider(label, func, unit, min, max, value, onVal);
  9630. };
  9631. return SelectionPanel;
  9632. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  9633. /***/ }),
  9634. /***/ "./2D/controls/sliders/baseSlider.ts":
  9635. /*!*******************************************!*\
  9636. !*** ./2D/controls/sliders/baseSlider.ts ***!
  9637. \*******************************************/
  9638. /*! exports provided: BaseSlider */
  9639. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9640. "use strict";
  9641. __webpack_require__.r(__webpack_exports__);
  9642. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  9643. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9644. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  9645. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  9646. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9647. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9648. /**
  9649. * Class used to create slider controls
  9650. */
  9651. var BaseSlider = /** @class */ (function (_super) {
  9652. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BaseSlider, _super);
  9653. /**
  9654. * Creates a new BaseSlider
  9655. * @param name defines the control name
  9656. */
  9657. function BaseSlider(name) {
  9658. var _this = _super.call(this, name) || this;
  9659. _this.name = name;
  9660. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9661. _this._minimum = 0;
  9662. _this._maximum = 100;
  9663. _this._value = 50;
  9664. _this._isVertical = false;
  9665. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9666. _this._isThumbClamped = false;
  9667. _this._displayThumb = true;
  9668. // Shared rendering info
  9669. _this._effectiveBarOffset = 0;
  9670. /** Observable raised when the sldier value changes */
  9671. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  9672. // Events
  9673. _this._pointerIsDown = false;
  9674. _this.isPointerBlocker = true;
  9675. return _this;
  9676. }
  9677. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  9678. /** Gets or sets a boolean indicating if the thumb must be rendered */
  9679. get: function () {
  9680. return this._displayThumb;
  9681. },
  9682. set: function (value) {
  9683. if (this._displayThumb === value) {
  9684. return;
  9685. }
  9686. this._displayThumb = value;
  9687. this._markAsDirty();
  9688. },
  9689. enumerable: true,
  9690. configurable: true
  9691. });
  9692. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  9693. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  9694. get: function () {
  9695. return this._barOffset.toString(this._host);
  9696. },
  9697. set: function (value) {
  9698. if (this._barOffset.toString(this._host) === value) {
  9699. return;
  9700. }
  9701. if (this._barOffset.fromString(value)) {
  9702. this._markAsDirty();
  9703. }
  9704. },
  9705. enumerable: true,
  9706. configurable: true
  9707. });
  9708. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  9709. /** Gets main bar offset in pixels*/
  9710. get: function () {
  9711. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9712. },
  9713. enumerable: true,
  9714. configurable: true
  9715. });
  9716. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  9717. /** Gets or sets thumb width */
  9718. get: function () {
  9719. return this._thumbWidth.toString(this._host);
  9720. },
  9721. set: function (value) {
  9722. if (this._thumbWidth.toString(this._host) === value) {
  9723. return;
  9724. }
  9725. if (this._thumbWidth.fromString(value)) {
  9726. this._markAsDirty();
  9727. }
  9728. },
  9729. enumerable: true,
  9730. configurable: true
  9731. });
  9732. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  9733. /** Gets thumb width in pixels */
  9734. get: function () {
  9735. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9736. },
  9737. enumerable: true,
  9738. configurable: true
  9739. });
  9740. Object.defineProperty(BaseSlider.prototype, "minimum", {
  9741. /** Gets or sets minimum value */
  9742. get: function () {
  9743. return this._minimum;
  9744. },
  9745. set: function (value) {
  9746. if (this._minimum === value) {
  9747. return;
  9748. }
  9749. this._minimum = value;
  9750. this._markAsDirty();
  9751. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9752. },
  9753. enumerable: true,
  9754. configurable: true
  9755. });
  9756. Object.defineProperty(BaseSlider.prototype, "maximum", {
  9757. /** Gets or sets maximum value */
  9758. get: function () {
  9759. return this._maximum;
  9760. },
  9761. set: function (value) {
  9762. if (this._maximum === value) {
  9763. return;
  9764. }
  9765. this._maximum = value;
  9766. this._markAsDirty();
  9767. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9768. },
  9769. enumerable: true,
  9770. configurable: true
  9771. });
  9772. Object.defineProperty(BaseSlider.prototype, "value", {
  9773. /** Gets or sets current value */
  9774. get: function () {
  9775. return this._value;
  9776. },
  9777. set: function (value) {
  9778. value = Math.max(Math.min(value, this._maximum), this._minimum);
  9779. if (this._value === value) {
  9780. return;
  9781. }
  9782. this._value = value;
  9783. this._markAsDirty();
  9784. this.onValueChangedObservable.notifyObservers(this._value);
  9785. },
  9786. enumerable: true,
  9787. configurable: true
  9788. });
  9789. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  9790. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  9791. get: function () {
  9792. return this._isVertical;
  9793. },
  9794. set: function (value) {
  9795. if (this._isVertical === value) {
  9796. return;
  9797. }
  9798. this._isVertical = value;
  9799. this._markAsDirty();
  9800. },
  9801. enumerable: true,
  9802. configurable: true
  9803. });
  9804. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  9805. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  9806. get: function () {
  9807. return this._isThumbClamped;
  9808. },
  9809. set: function (value) {
  9810. if (this._isThumbClamped === value) {
  9811. return;
  9812. }
  9813. this._isThumbClamped = value;
  9814. this._markAsDirty();
  9815. },
  9816. enumerable: true,
  9817. configurable: true
  9818. });
  9819. BaseSlider.prototype._getTypeName = function () {
  9820. return "BaseSlider";
  9821. };
  9822. BaseSlider.prototype._getThumbPosition = function () {
  9823. if (this.isVertical) {
  9824. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  9825. }
  9826. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  9827. };
  9828. BaseSlider.prototype._getThumbThickness = function (type) {
  9829. var thumbThickness = 0;
  9830. switch (type) {
  9831. case "circle":
  9832. if (this._thumbWidth.isPixel) {
  9833. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  9834. }
  9835. else {
  9836. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  9837. }
  9838. break;
  9839. case "rectangle":
  9840. if (this._thumbWidth.isPixel) {
  9841. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  9842. }
  9843. else {
  9844. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  9845. }
  9846. }
  9847. return thumbThickness;
  9848. };
  9849. BaseSlider.prototype._prepareRenderingData = function (type) {
  9850. // Main bar
  9851. this._effectiveBarOffset = 0;
  9852. this._renderLeft = this._currentMeasure.left;
  9853. this._renderTop = this._currentMeasure.top;
  9854. this._renderWidth = this._currentMeasure.width;
  9855. this._renderHeight = this._currentMeasure.height;
  9856. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  9857. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  9858. this._effectiveThumbThickness = this._getThumbThickness(type);
  9859. if (this.displayThumb) {
  9860. this._backgroundBoxLength -= this._effectiveThumbThickness;
  9861. }
  9862. //throw error when height is less than width for vertical slider
  9863. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  9864. console.error("Height should be greater than width");
  9865. return;
  9866. }
  9867. if (this._barOffset.isPixel) {
  9868. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  9869. }
  9870. else {
  9871. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  9872. }
  9873. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  9874. if (this.isVertical) {
  9875. this._renderLeft += this._effectiveBarOffset;
  9876. if (!this.isThumbClamped && this.displayThumb) {
  9877. this._renderTop += (this._effectiveThumbThickness / 2);
  9878. }
  9879. this._renderHeight = this._backgroundBoxLength;
  9880. this._renderWidth = this._backgroundBoxThickness;
  9881. }
  9882. else {
  9883. this._renderTop += this._effectiveBarOffset;
  9884. if (!this.isThumbClamped && this.displayThumb) {
  9885. this._renderLeft += (this._effectiveThumbThickness / 2);
  9886. }
  9887. this._renderHeight = this._backgroundBoxThickness;
  9888. this._renderWidth = this._backgroundBoxLength;
  9889. }
  9890. };
  9891. /** @hidden */
  9892. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  9893. if (this.rotation != 0) {
  9894. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  9895. x = this._transformedPosition.x;
  9896. y = this._transformedPosition.y;
  9897. }
  9898. if (this._isVertical) {
  9899. this.value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  9900. }
  9901. else {
  9902. this.value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  9903. }
  9904. };
  9905. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  9906. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  9907. return false;
  9908. }
  9909. this._pointerIsDown = true;
  9910. this._updateValueFromPointer(coordinates.x, coordinates.y);
  9911. this._host._capturingControl[pointerId] = this;
  9912. return true;
  9913. };
  9914. BaseSlider.prototype._onPointerMove = function (target, coordinates) {
  9915. if (this._pointerIsDown) {
  9916. this._updateValueFromPointer(coordinates.x, coordinates.y);
  9917. }
  9918. _super.prototype._onPointerMove.call(this, target, coordinates);
  9919. };
  9920. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  9921. this._pointerIsDown = false;
  9922. delete this._host._capturingControl[pointerId];
  9923. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  9924. };
  9925. return BaseSlider;
  9926. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  9927. /***/ }),
  9928. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  9929. /*!*************************************************!*\
  9930. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  9931. \*************************************************/
  9932. /*! exports provided: ImageBasedSlider */
  9933. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9934. "use strict";
  9935. __webpack_require__.r(__webpack_exports__);
  9936. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  9937. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9938. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  9939. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  9940. /**
  9941. * Class used to create slider controls based on images
  9942. */
  9943. var ImageBasedSlider = /** @class */ (function (_super) {
  9944. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageBasedSlider, _super);
  9945. /**
  9946. * Creates a new ImageBasedSlider
  9947. * @param name defines the control name
  9948. */
  9949. function ImageBasedSlider(name) {
  9950. var _this = _super.call(this, name) || this;
  9951. _this.name = name;
  9952. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  9953. return _this;
  9954. }
  9955. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  9956. get: function () {
  9957. return this._displayThumb && this.thumbImage != null;
  9958. },
  9959. set: function (value) {
  9960. if (this._displayThumb === value) {
  9961. return;
  9962. }
  9963. this._displayThumb = value;
  9964. this._markAsDirty();
  9965. },
  9966. enumerable: true,
  9967. configurable: true
  9968. });
  9969. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  9970. /**
  9971. * Gets or sets the image used to render the background
  9972. */
  9973. get: function () {
  9974. return this._backgroundImage;
  9975. },
  9976. set: function (value) {
  9977. var _this = this;
  9978. if (this._backgroundImage === value) {
  9979. return;
  9980. }
  9981. this._backgroundImage = value;
  9982. if (value && !value.isLoaded) {
  9983. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  9984. }
  9985. this._markAsDirty();
  9986. },
  9987. enumerable: true,
  9988. configurable: true
  9989. });
  9990. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  9991. /**
  9992. * Gets or sets the image used to render the value bar
  9993. */
  9994. get: function () {
  9995. return this._valueBarImage;
  9996. },
  9997. set: function (value) {
  9998. var _this = this;
  9999. if (this._valueBarImage === value) {
  10000. return;
  10001. }
  10002. this._valueBarImage = value;
  10003. if (value && !value.isLoaded) {
  10004. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10005. }
  10006. this._markAsDirty();
  10007. },
  10008. enumerable: true,
  10009. configurable: true
  10010. });
  10011. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  10012. /**
  10013. * Gets or sets the image used to render the thumb
  10014. */
  10015. get: function () {
  10016. return this._thumbImage;
  10017. },
  10018. set: function (value) {
  10019. var _this = this;
  10020. if (this._thumbImage === value) {
  10021. return;
  10022. }
  10023. this._thumbImage = value;
  10024. if (value && !value.isLoaded) {
  10025. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10026. }
  10027. this._markAsDirty();
  10028. },
  10029. enumerable: true,
  10030. configurable: true
  10031. });
  10032. ImageBasedSlider.prototype._getTypeName = function () {
  10033. return "ImageBasedSlider";
  10034. };
  10035. ImageBasedSlider.prototype._draw = function (context) {
  10036. context.save();
  10037. this._applyStates(context);
  10038. this._prepareRenderingData("rectangle");
  10039. var thumbPosition = this._getThumbPosition();
  10040. var left = this._renderLeft;
  10041. var top = this._renderTop;
  10042. var width = this._renderWidth;
  10043. var height = this._renderHeight;
  10044. // Background
  10045. if (this._backgroundImage) {
  10046. this._tempMeasure.copyFromFloats(left, top, width, height);
  10047. if (this.isThumbClamped && this.displayThumb) {
  10048. if (this.isVertical) {
  10049. this._tempMeasure.height += this._effectiveThumbThickness;
  10050. }
  10051. else {
  10052. this._tempMeasure.width += this._effectiveThumbThickness;
  10053. }
  10054. }
  10055. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  10056. this._backgroundImage._draw(context);
  10057. }
  10058. // Bar
  10059. if (this._valueBarImage) {
  10060. if (this.isVertical) {
  10061. if (this.isThumbClamped && this.displayThumb) {
  10062. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10063. }
  10064. else {
  10065. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  10066. }
  10067. }
  10068. else {
  10069. if (this.isThumbClamped && this.displayThumb) {
  10070. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  10071. }
  10072. else {
  10073. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  10074. }
  10075. }
  10076. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  10077. this._valueBarImage._draw(context);
  10078. }
  10079. // Thumb
  10080. if (this.displayThumb) {
  10081. if (this.isVertical) {
  10082. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10083. }
  10084. else {
  10085. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10086. }
  10087. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  10088. this._thumbImage._draw(context);
  10089. }
  10090. context.restore();
  10091. };
  10092. return ImageBasedSlider;
  10093. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10094. /***/ }),
  10095. /***/ "./2D/controls/sliders/scrollBar.ts":
  10096. /*!******************************************!*\
  10097. !*** ./2D/controls/sliders/scrollBar.ts ***!
  10098. \******************************************/
  10099. /*! exports provided: ScrollBar */
  10100. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10101. "use strict";
  10102. __webpack_require__.r(__webpack_exports__);
  10103. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  10104. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10105. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10106. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10107. /**
  10108. * Class used to create slider controls
  10109. */
  10110. var ScrollBar = /** @class */ (function (_super) {
  10111. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScrollBar, _super);
  10112. /**
  10113. * Creates a new Slider
  10114. * @param name defines the control name
  10115. */
  10116. function ScrollBar(name) {
  10117. var _this = _super.call(this, name) || this;
  10118. _this.name = name;
  10119. _this._background = "black";
  10120. _this._borderColor = "white";
  10121. _this._thumbMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10122. return _this;
  10123. }
  10124. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  10125. /** Gets or sets border color */
  10126. get: function () {
  10127. return this._borderColor;
  10128. },
  10129. set: function (value) {
  10130. if (this._borderColor === value) {
  10131. return;
  10132. }
  10133. this._borderColor = value;
  10134. this._markAsDirty();
  10135. },
  10136. enumerable: true,
  10137. configurable: true
  10138. });
  10139. Object.defineProperty(ScrollBar.prototype, "background", {
  10140. /** Gets or sets background color */
  10141. get: function () {
  10142. return this._background;
  10143. },
  10144. set: function (value) {
  10145. if (this._background === value) {
  10146. return;
  10147. }
  10148. this._background = value;
  10149. this._markAsDirty();
  10150. },
  10151. enumerable: true,
  10152. configurable: true
  10153. });
  10154. ScrollBar.prototype._getTypeName = function () {
  10155. return "Scrollbar";
  10156. };
  10157. ScrollBar.prototype._getThumbThickness = function () {
  10158. var thumbThickness = 0;
  10159. if (this._thumbWidth.isPixel) {
  10160. thumbThickness = this._thumbWidth.getValue(this._host);
  10161. }
  10162. else {
  10163. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10164. }
  10165. return thumbThickness;
  10166. };
  10167. ScrollBar.prototype._draw = function (context) {
  10168. context.save();
  10169. this._applyStates(context);
  10170. this._prepareRenderingData("rectangle");
  10171. var left = this._renderLeft;
  10172. var thumbPosition = this._getThumbPosition();
  10173. context.fillStyle = this._background;
  10174. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  10175. // Value bar
  10176. context.fillStyle = this.color;
  10177. // Thumb
  10178. if (this.isVertical) {
  10179. this._thumbMeasure.left = left - this._effectiveBarOffset;
  10180. this._thumbMeasure.top = this._currentMeasure.top + thumbPosition;
  10181. this._thumbMeasure.width = this._currentMeasure.width;
  10182. this._thumbMeasure.height = this._effectiveThumbThickness;
  10183. }
  10184. else {
  10185. this._thumbMeasure.left = this._currentMeasure.left + thumbPosition;
  10186. this._thumbMeasure.top = this._currentMeasure.top;
  10187. this._thumbMeasure.width = this._effectiveThumbThickness;
  10188. this._thumbMeasure.height = this._currentMeasure.height;
  10189. }
  10190. context.fillRect(this._thumbMeasure.left, this._thumbMeasure.top, this._thumbMeasure.width, this._thumbMeasure.height);
  10191. context.restore();
  10192. };
  10193. /** @hidden */
  10194. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  10195. if (this.rotation != 0) {
  10196. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10197. x = this._transformedPosition.x;
  10198. y = this._transformedPosition.y;
  10199. }
  10200. if (this._first) {
  10201. this._first = false;
  10202. this._originX = x;
  10203. this._originY = y;
  10204. // Check if move is required
  10205. if (x < this._thumbMeasure.left || x > this._thumbMeasure.left + this._thumbMeasure.width || y < this._thumbMeasure.top || y > this._thumbMeasure.top + this._thumbMeasure.height) {
  10206. if (this.isVertical) {
  10207. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  10208. }
  10209. else {
  10210. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  10211. }
  10212. }
  10213. }
  10214. // Delta mode
  10215. var delta = 0;
  10216. if (this.isVertical) {
  10217. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  10218. }
  10219. else {
  10220. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  10221. }
  10222. this.value += delta * (this.maximum - this.minimum);
  10223. this._originX = x;
  10224. this._originY = y;
  10225. };
  10226. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10227. this._first = true;
  10228. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  10229. };
  10230. return ScrollBar;
  10231. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10232. /***/ }),
  10233. /***/ "./2D/controls/sliders/slider.ts":
  10234. /*!***************************************!*\
  10235. !*** ./2D/controls/sliders/slider.ts ***!
  10236. \***************************************/
  10237. /*! exports provided: Slider */
  10238. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10239. "use strict";
  10240. __webpack_require__.r(__webpack_exports__);
  10241. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  10242. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10243. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10244. /**
  10245. * Class used to create slider controls
  10246. */
  10247. var Slider = /** @class */ (function (_super) {
  10248. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Slider, _super);
  10249. /**
  10250. * Creates a new Slider
  10251. * @param name defines the control name
  10252. */
  10253. function Slider(name) {
  10254. var _this = _super.call(this, name) || this;
  10255. _this.name = name;
  10256. _this._background = "black";
  10257. _this._borderColor = "white";
  10258. _this._isThumbCircle = false;
  10259. _this._displayValueBar = true;
  10260. return _this;
  10261. }
  10262. Object.defineProperty(Slider.prototype, "displayValueBar", {
  10263. /** Gets or sets a boolean indicating if the value bar must be rendered */
  10264. get: function () {
  10265. return this._displayValueBar;
  10266. },
  10267. set: function (value) {
  10268. if (this._displayValueBar === value) {
  10269. return;
  10270. }
  10271. this._displayValueBar = value;
  10272. this._markAsDirty();
  10273. },
  10274. enumerable: true,
  10275. configurable: true
  10276. });
  10277. Object.defineProperty(Slider.prototype, "borderColor", {
  10278. /** Gets or sets border color */
  10279. get: function () {
  10280. return this._borderColor;
  10281. },
  10282. set: function (value) {
  10283. if (this._borderColor === value) {
  10284. return;
  10285. }
  10286. this._borderColor = value;
  10287. this._markAsDirty();
  10288. },
  10289. enumerable: true,
  10290. configurable: true
  10291. });
  10292. Object.defineProperty(Slider.prototype, "background", {
  10293. /** Gets or sets background color */
  10294. get: function () {
  10295. return this._background;
  10296. },
  10297. set: function (value) {
  10298. if (this._background === value) {
  10299. return;
  10300. }
  10301. this._background = value;
  10302. this._markAsDirty();
  10303. },
  10304. enumerable: true,
  10305. configurable: true
  10306. });
  10307. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  10308. /** Gets or sets a boolean indicating if the thumb should be round or square */
  10309. get: function () {
  10310. return this._isThumbCircle;
  10311. },
  10312. set: function (value) {
  10313. if (this._isThumbCircle === value) {
  10314. return;
  10315. }
  10316. this._isThumbCircle = value;
  10317. this._markAsDirty();
  10318. },
  10319. enumerable: true,
  10320. configurable: true
  10321. });
  10322. Slider.prototype._getTypeName = function () {
  10323. return "Slider";
  10324. };
  10325. Slider.prototype._draw = function (context) {
  10326. context.save();
  10327. this._applyStates(context);
  10328. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  10329. var left = this._renderLeft;
  10330. var top = this._renderTop;
  10331. var width = this._renderWidth;
  10332. var height = this._renderHeight;
  10333. var radius = 0;
  10334. if (this.isThumbClamped && this.isThumbCircle) {
  10335. if (this.isVertical) {
  10336. top += (this._effectiveThumbThickness / 2);
  10337. }
  10338. else {
  10339. left += (this._effectiveThumbThickness / 2);
  10340. }
  10341. radius = this._backgroundBoxThickness / 2;
  10342. }
  10343. else {
  10344. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  10345. }
  10346. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10347. context.shadowColor = this.shadowColor;
  10348. context.shadowBlur = this.shadowBlur;
  10349. context.shadowOffsetX = this.shadowOffsetX;
  10350. context.shadowOffsetY = this.shadowOffsetY;
  10351. }
  10352. var thumbPosition = this._getThumbPosition();
  10353. context.fillStyle = this._background;
  10354. if (this.isVertical) {
  10355. if (this.isThumbClamped) {
  10356. if (this.isThumbCircle) {
  10357. context.beginPath();
  10358. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  10359. context.fill();
  10360. context.fillRect(left, top, width, height);
  10361. }
  10362. else {
  10363. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  10364. }
  10365. }
  10366. else {
  10367. context.fillRect(left, top, width, height);
  10368. }
  10369. }
  10370. else {
  10371. if (this.isThumbClamped) {
  10372. if (this.isThumbCircle) {
  10373. context.beginPath();
  10374. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10375. context.fill();
  10376. context.fillRect(left, top, width, height);
  10377. }
  10378. else {
  10379. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  10380. }
  10381. }
  10382. else {
  10383. context.fillRect(left, top, width, height);
  10384. }
  10385. }
  10386. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10387. context.shadowBlur = 0;
  10388. context.shadowOffsetX = 0;
  10389. context.shadowOffsetY = 0;
  10390. }
  10391. // Value bar
  10392. context.fillStyle = this.color;
  10393. if (this._displayValueBar) {
  10394. if (this.isVertical) {
  10395. if (this.isThumbClamped) {
  10396. if (this.isThumbCircle) {
  10397. context.beginPath();
  10398. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  10399. context.fill();
  10400. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10401. }
  10402. else {
  10403. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10404. }
  10405. }
  10406. else {
  10407. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10408. }
  10409. }
  10410. else {
  10411. if (this.isThumbClamped) {
  10412. if (this.isThumbCircle) {
  10413. context.beginPath();
  10414. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  10415. context.fill();
  10416. context.fillRect(left, top, thumbPosition, height);
  10417. }
  10418. else {
  10419. context.fillRect(left, top, thumbPosition, height);
  10420. }
  10421. }
  10422. else {
  10423. context.fillRect(left, top, thumbPosition, height);
  10424. }
  10425. }
  10426. }
  10427. // Thumb
  10428. if (this.displayThumb) {
  10429. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10430. context.shadowColor = this.shadowColor;
  10431. context.shadowBlur = this.shadowBlur;
  10432. context.shadowOffsetX = this.shadowOffsetX;
  10433. context.shadowOffsetY = this.shadowOffsetY;
  10434. }
  10435. if (this._isThumbCircle) {
  10436. context.beginPath();
  10437. if (this.isVertical) {
  10438. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  10439. }
  10440. else {
  10441. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10442. }
  10443. context.fill();
  10444. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10445. context.shadowBlur = 0;
  10446. context.shadowOffsetX = 0;
  10447. context.shadowOffsetY = 0;
  10448. }
  10449. context.strokeStyle = this._borderColor;
  10450. context.stroke();
  10451. }
  10452. else {
  10453. if (this.isVertical) {
  10454. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10455. }
  10456. else {
  10457. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10458. }
  10459. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10460. context.shadowBlur = 0;
  10461. context.shadowOffsetX = 0;
  10462. context.shadowOffsetY = 0;
  10463. }
  10464. context.strokeStyle = this._borderColor;
  10465. if (this.isVertical) {
  10466. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10467. }
  10468. else {
  10469. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10470. }
  10471. }
  10472. }
  10473. context.restore();
  10474. };
  10475. return Slider;
  10476. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10477. /***/ }),
  10478. /***/ "./2D/controls/stackPanel.ts":
  10479. /*!***********************************!*\
  10480. !*** ./2D/controls/stackPanel.ts ***!
  10481. \***********************************/
  10482. /*! exports provided: StackPanel */
  10483. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10484. "use strict";
  10485. __webpack_require__.r(__webpack_exports__);
  10486. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  10487. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10488. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  10489. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  10490. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  10491. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10492. /**
  10493. * Class used to create a 2D stack panel container
  10494. */
  10495. var StackPanel = /** @class */ (function (_super) {
  10496. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StackPanel, _super);
  10497. /**
  10498. * Creates a new StackPanel
  10499. * @param name defines control name
  10500. */
  10501. function StackPanel(name) {
  10502. var _this = _super.call(this, name) || this;
  10503. _this.name = name;
  10504. _this._isVertical = true;
  10505. _this._manualWidth = false;
  10506. _this._manualHeight = false;
  10507. _this._doNotTrackManualChanges = false;
  10508. return _this;
  10509. }
  10510. Object.defineProperty(StackPanel.prototype, "isVertical", {
  10511. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  10512. get: function () {
  10513. return this._isVertical;
  10514. },
  10515. set: function (value) {
  10516. if (this._isVertical === value) {
  10517. return;
  10518. }
  10519. this._isVertical = value;
  10520. this._markAsDirty();
  10521. },
  10522. enumerable: true,
  10523. configurable: true
  10524. });
  10525. Object.defineProperty(StackPanel.prototype, "width", {
  10526. get: function () {
  10527. return this._width.toString(this._host);
  10528. },
  10529. /**
  10530. * Gets or sets panel width.
  10531. * This value should not be set when in horizontal mode as it will be computed automatically
  10532. */
  10533. set: function (value) {
  10534. if (!this._doNotTrackManualChanges) {
  10535. this._manualWidth = true;
  10536. }
  10537. if (this._width.toString(this._host) === value) {
  10538. return;
  10539. }
  10540. if (this._width.fromString(value)) {
  10541. this._markAsDirty();
  10542. }
  10543. },
  10544. enumerable: true,
  10545. configurable: true
  10546. });
  10547. Object.defineProperty(StackPanel.prototype, "height", {
  10548. get: function () {
  10549. return this._height.toString(this._host);
  10550. },
  10551. /**
  10552. * Gets or sets panel height.
  10553. * This value should not be set when in vertical mode as it will be computed automatically
  10554. */
  10555. set: function (value) {
  10556. if (!this._doNotTrackManualChanges) {
  10557. this._manualHeight = true;
  10558. }
  10559. if (this._height.toString(this._host) === value) {
  10560. return;
  10561. }
  10562. if (this._height.fromString(value)) {
  10563. this._markAsDirty();
  10564. }
  10565. },
  10566. enumerable: true,
  10567. configurable: true
  10568. });
  10569. StackPanel.prototype._getTypeName = function () {
  10570. return "StackPanel";
  10571. };
  10572. /** @hidden */
  10573. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  10574. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10575. var child = _a[_i];
  10576. if (this._isVertical) {
  10577. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10578. }
  10579. else {
  10580. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10581. }
  10582. }
  10583. _super.prototype._preMeasure.call(this, parentMeasure, context);
  10584. };
  10585. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  10586. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  10587. this._measureForChildren.copyFrom(parentMeasure);
  10588. this._measureForChildren.left = this._currentMeasure.left;
  10589. this._measureForChildren.top = this._currentMeasure.top;
  10590. if (!this.isVertical || this._manualWidth) {
  10591. this._measureForChildren.width = this._currentMeasure.width;
  10592. }
  10593. if (this.isVertical || this._manualHeight) {
  10594. this._measureForChildren.height = this._currentMeasure.height;
  10595. }
  10596. };
  10597. StackPanel.prototype._postMeasure = function () {
  10598. var stackWidth = 0;
  10599. var stackHeight = 0;
  10600. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10601. var child = _a[_i];
  10602. if (!child.isVisible || child.notRenderable) {
  10603. continue;
  10604. }
  10605. if (this._isVertical) {
  10606. if (child.top !== stackHeight + "px") {
  10607. child.top = stackHeight + "px";
  10608. this._rebuildLayout = true;
  10609. child._top.ignoreAdaptiveScaling = true;
  10610. }
  10611. if (child._height.isPercentage) {
  10612. 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");
  10613. }
  10614. else {
  10615. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  10616. }
  10617. }
  10618. else {
  10619. if (child.left !== stackWidth + "px") {
  10620. child.left = stackWidth + "px";
  10621. this._rebuildLayout = true;
  10622. child._left.ignoreAdaptiveScaling = true;
  10623. }
  10624. if (child._width.isPercentage) {
  10625. 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");
  10626. }
  10627. else {
  10628. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  10629. }
  10630. }
  10631. }
  10632. this._doNotTrackManualChanges = true;
  10633. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  10634. // User can now define their own height and width for stack panel.
  10635. var panelWidthChanged = false;
  10636. var panelHeightChanged = false;
  10637. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  10638. var previousHeight = this.height;
  10639. this.height = stackHeight + "px";
  10640. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  10641. }
  10642. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  10643. var previousWidth = this.width;
  10644. this.width = stackWidth + "px";
  10645. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  10646. }
  10647. if (panelHeightChanged) {
  10648. this._height.ignoreAdaptiveScaling = true;
  10649. }
  10650. if (panelWidthChanged) {
  10651. this._width.ignoreAdaptiveScaling = true;
  10652. }
  10653. this._doNotTrackManualChanges = false;
  10654. if (panelWidthChanged || panelHeightChanged) {
  10655. this._rebuildLayout = true;
  10656. }
  10657. _super.prototype._postMeasure.call(this);
  10658. };
  10659. return StackPanel;
  10660. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  10661. /***/ }),
  10662. /***/ "./2D/controls/statics.ts":
  10663. /*!********************************!*\
  10664. !*** ./2D/controls/statics.ts ***!
  10665. \********************************/
  10666. /*! exports provided: name */
  10667. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10668. "use strict";
  10669. __webpack_require__.r(__webpack_exports__);
  10670. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  10671. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10672. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  10673. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  10674. /**
  10675. * Forcing an export so that this code will execute
  10676. * @hidden
  10677. */
  10678. var name = "Statics";
  10679. /**
  10680. * Creates a stack panel that can be used to render headers
  10681. * @param control defines the control to associate with the header
  10682. * @param text defines the text of the header
  10683. * @param size defines the size of the header
  10684. * @param options defines options used to configure the header
  10685. * @returns a new StackPanel
  10686. */
  10687. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  10688. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  10689. var isHorizontal = options ? options.isHorizontal : true;
  10690. var controlFirst = options ? options.controlFirst : true;
  10691. panel.isVertical = !isHorizontal;
  10692. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  10693. header.text = text;
  10694. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10695. if (isHorizontal) {
  10696. header.width = size;
  10697. }
  10698. else {
  10699. header.height = size;
  10700. }
  10701. if (controlFirst) {
  10702. panel.addControl(control);
  10703. panel.addControl(header);
  10704. header.paddingLeft = "5px";
  10705. }
  10706. else {
  10707. panel.addControl(header);
  10708. panel.addControl(control);
  10709. header.paddingRight = "5px";
  10710. }
  10711. header.shadowBlur = control.shadowBlur;
  10712. header.shadowColor = control.shadowColor;
  10713. header.shadowOffsetX = control.shadowOffsetX;
  10714. header.shadowOffsetY = control.shadowOffsetY;
  10715. return panel;
  10716. };
  10717. /***/ }),
  10718. /***/ "./2D/controls/textBlock.ts":
  10719. /*!**********************************!*\
  10720. !*** ./2D/controls/textBlock.ts ***!
  10721. \**********************************/
  10722. /*! exports provided: TextWrapping, TextBlock */
  10723. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10724. "use strict";
  10725. __webpack_require__.r(__webpack_exports__);
  10726. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  10727. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  10728. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10729. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  10730. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  10731. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  10732. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10733. /**
  10734. * Enum that determines the text-wrapping mode to use.
  10735. */
  10736. var TextWrapping;
  10737. (function (TextWrapping) {
  10738. /**
  10739. * Clip the text when it's larger than Control.width; this is the default mode.
  10740. */
  10741. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  10742. /**
  10743. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  10744. */
  10745. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  10746. /**
  10747. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  10748. */
  10749. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  10750. })(TextWrapping || (TextWrapping = {}));
  10751. /**
  10752. * Class used to create text block control
  10753. */
  10754. var TextBlock = /** @class */ (function (_super) {
  10755. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextBlock, _super);
  10756. /**
  10757. * Creates a new TextBlock object
  10758. * @param name defines the name of the control
  10759. * @param text defines the text to display (emptry string by default)
  10760. */
  10761. function TextBlock(
  10762. /**
  10763. * Defines the name of the control
  10764. */
  10765. name, text) {
  10766. if (text === void 0) { text = ""; }
  10767. var _this = _super.call(this, name) || this;
  10768. _this.name = name;
  10769. _this._text = "";
  10770. _this._textWrapping = TextWrapping.Clip;
  10771. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  10772. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  10773. _this._resizeToFit = false;
  10774. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  10775. _this._outlineWidth = 0;
  10776. _this._outlineColor = "white";
  10777. /**
  10778. * An event triggered after the text is changed
  10779. */
  10780. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10781. /**
  10782. * An event triggered after the text was broken up into lines
  10783. */
  10784. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10785. _this.text = text;
  10786. return _this;
  10787. }
  10788. Object.defineProperty(TextBlock.prototype, "lines", {
  10789. /**
  10790. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  10791. */
  10792. get: function () {
  10793. return this._lines;
  10794. },
  10795. enumerable: true,
  10796. configurable: true
  10797. });
  10798. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  10799. /**
  10800. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  10801. */
  10802. get: function () {
  10803. return this._resizeToFit;
  10804. },
  10805. /**
  10806. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  10807. */
  10808. set: function (value) {
  10809. if (this._resizeToFit === value) {
  10810. return;
  10811. }
  10812. this._resizeToFit = value;
  10813. if (this._resizeToFit) {
  10814. this._width.ignoreAdaptiveScaling = true;
  10815. this._height.ignoreAdaptiveScaling = true;
  10816. }
  10817. this._markAsDirty();
  10818. },
  10819. enumerable: true,
  10820. configurable: true
  10821. });
  10822. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  10823. /**
  10824. * Gets or sets a boolean indicating if text must be wrapped
  10825. */
  10826. get: function () {
  10827. return this._textWrapping;
  10828. },
  10829. /**
  10830. * Gets or sets a boolean indicating if text must be wrapped
  10831. */
  10832. set: function (value) {
  10833. if (this._textWrapping === value) {
  10834. return;
  10835. }
  10836. this._textWrapping = +value;
  10837. this._markAsDirty();
  10838. },
  10839. enumerable: true,
  10840. configurable: true
  10841. });
  10842. Object.defineProperty(TextBlock.prototype, "text", {
  10843. /**
  10844. * Gets or sets text to display
  10845. */
  10846. get: function () {
  10847. return this._text;
  10848. },
  10849. /**
  10850. * Gets or sets text to display
  10851. */
  10852. set: function (value) {
  10853. if (this._text === value) {
  10854. return;
  10855. }
  10856. this._text = value;
  10857. this._markAsDirty();
  10858. this.onTextChangedObservable.notifyObservers(this);
  10859. },
  10860. enumerable: true,
  10861. configurable: true
  10862. });
  10863. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  10864. /**
  10865. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  10866. */
  10867. get: function () {
  10868. return this._textHorizontalAlignment;
  10869. },
  10870. /**
  10871. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  10872. */
  10873. set: function (value) {
  10874. if (this._textHorizontalAlignment === value) {
  10875. return;
  10876. }
  10877. this._textHorizontalAlignment = value;
  10878. this._markAsDirty();
  10879. },
  10880. enumerable: true,
  10881. configurable: true
  10882. });
  10883. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  10884. /**
  10885. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  10886. */
  10887. get: function () {
  10888. return this._textVerticalAlignment;
  10889. },
  10890. /**
  10891. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  10892. */
  10893. set: function (value) {
  10894. if (this._textVerticalAlignment === value) {
  10895. return;
  10896. }
  10897. this._textVerticalAlignment = value;
  10898. this._markAsDirty();
  10899. },
  10900. enumerable: true,
  10901. configurable: true
  10902. });
  10903. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  10904. /**
  10905. * Gets or sets line spacing value
  10906. */
  10907. get: function () {
  10908. return this._lineSpacing.toString(this._host);
  10909. },
  10910. /**
  10911. * Gets or sets line spacing value
  10912. */
  10913. set: function (value) {
  10914. if (this._lineSpacing.fromString(value)) {
  10915. this._markAsDirty();
  10916. }
  10917. },
  10918. enumerable: true,
  10919. configurable: true
  10920. });
  10921. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  10922. /**
  10923. * Gets or sets outlineWidth of the text to display
  10924. */
  10925. get: function () {
  10926. return this._outlineWidth;
  10927. },
  10928. /**
  10929. * Gets or sets outlineWidth of the text to display
  10930. */
  10931. set: function (value) {
  10932. if (this._outlineWidth === value) {
  10933. return;
  10934. }
  10935. this._outlineWidth = value;
  10936. this._markAsDirty();
  10937. },
  10938. enumerable: true,
  10939. configurable: true
  10940. });
  10941. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  10942. /**
  10943. * Gets or sets outlineColor of the text to display
  10944. */
  10945. get: function () {
  10946. return this._outlineColor;
  10947. },
  10948. /**
  10949. * Gets or sets outlineColor of the text to display
  10950. */
  10951. set: function (value) {
  10952. if (this._outlineColor === value) {
  10953. return;
  10954. }
  10955. this._outlineColor = value;
  10956. this._markAsDirty();
  10957. },
  10958. enumerable: true,
  10959. configurable: true
  10960. });
  10961. TextBlock.prototype._getTypeName = function () {
  10962. return "TextBlock";
  10963. };
  10964. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  10965. if (!this._fontOffset) {
  10966. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  10967. }
  10968. _super.prototype._processMeasures.call(this, parentMeasure, context);
  10969. // Prepare lines
  10970. this._lines = this._breakLines(this._currentMeasure.width, context);
  10971. this.onLinesReadyObservable.notifyObservers(this);
  10972. var maxLineWidth = 0;
  10973. for (var i = 0; i < this._lines.length; i++) {
  10974. var line = this._lines[i];
  10975. if (line.width > maxLineWidth) {
  10976. maxLineWidth = line.width;
  10977. }
  10978. }
  10979. if (this._resizeToFit) {
  10980. if (this._textWrapping === TextWrapping.Clip) {
  10981. var newWidth = this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth;
  10982. if (newWidth !== this._width.internalValue) {
  10983. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  10984. this._rebuildLayout = true;
  10985. }
  10986. }
  10987. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length;
  10988. if (newHeight !== this._height.internalValue) {
  10989. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  10990. this._rebuildLayout = true;
  10991. }
  10992. }
  10993. };
  10994. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  10995. var width = this._currentMeasure.width;
  10996. var x = 0;
  10997. switch (this._textHorizontalAlignment) {
  10998. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  10999. x = 0;
  11000. break;
  11001. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  11002. x = width - textWidth;
  11003. break;
  11004. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  11005. x = (width - textWidth) / 2;
  11006. break;
  11007. }
  11008. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11009. context.shadowColor = this.shadowColor;
  11010. context.shadowBlur = this.shadowBlur;
  11011. context.shadowOffsetX = this.shadowOffsetX;
  11012. context.shadowOffsetY = this.shadowOffsetY;
  11013. }
  11014. if (this.outlineWidth) {
  11015. context.strokeText(text, this._currentMeasure.left + x, y);
  11016. }
  11017. context.fillText(text, this._currentMeasure.left + x, y);
  11018. };
  11019. /** @hidden */
  11020. TextBlock.prototype._draw = function (context) {
  11021. context.save();
  11022. this._applyStates(context);
  11023. // Render lines
  11024. this._renderLines(context);
  11025. context.restore();
  11026. };
  11027. TextBlock.prototype._applyStates = function (context) {
  11028. _super.prototype._applyStates.call(this, context);
  11029. if (this.outlineWidth) {
  11030. context.lineWidth = this.outlineWidth;
  11031. context.strokeStyle = this.outlineColor;
  11032. }
  11033. };
  11034. TextBlock.prototype._breakLines = function (refWidth, context) {
  11035. var lines = [];
  11036. var _lines = this.text.split("\n");
  11037. if (this._textWrapping === TextWrapping.Ellipsis) {
  11038. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  11039. var _line = _lines_1[_i];
  11040. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  11041. }
  11042. }
  11043. else if (this._textWrapping === TextWrapping.WordWrap) {
  11044. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  11045. var _line = _lines_2[_a];
  11046. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  11047. }
  11048. }
  11049. else {
  11050. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  11051. var _line = _lines_3[_b];
  11052. lines.push(this._parseLine(_line, context));
  11053. }
  11054. }
  11055. return lines;
  11056. };
  11057. TextBlock.prototype._parseLine = function (line, context) {
  11058. if (line === void 0) { line = ''; }
  11059. return { text: line, width: context.measureText(line).width };
  11060. };
  11061. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  11062. if (line === void 0) { line = ''; }
  11063. var lineWidth = context.measureText(line).width;
  11064. if (lineWidth > width) {
  11065. line += '…';
  11066. }
  11067. while (line.length > 2 && lineWidth > width) {
  11068. line = line.slice(0, -2) + '…';
  11069. lineWidth = context.measureText(line).width;
  11070. }
  11071. return { text: line, width: lineWidth };
  11072. };
  11073. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  11074. if (line === void 0) { line = ''; }
  11075. var lines = [];
  11076. var words = line.split(' ');
  11077. var lineWidth = 0;
  11078. for (var n = 0; n < words.length; n++) {
  11079. var testLine = n > 0 ? line + " " + words[n] : words[0];
  11080. var metrics = context.measureText(testLine);
  11081. var testWidth = metrics.width;
  11082. if (testWidth > width && n > 0) {
  11083. lines.push({ text: line, width: lineWidth });
  11084. line = words[n];
  11085. lineWidth = context.measureText(line).width;
  11086. }
  11087. else {
  11088. lineWidth = testWidth;
  11089. line = testLine;
  11090. }
  11091. }
  11092. lines.push({ text: line, width: lineWidth });
  11093. return lines;
  11094. };
  11095. TextBlock.prototype._renderLines = function (context) {
  11096. var height = this._currentMeasure.height;
  11097. var rootY = 0;
  11098. switch (this._textVerticalAlignment) {
  11099. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  11100. rootY = this._fontOffset.ascent;
  11101. break;
  11102. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  11103. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  11104. break;
  11105. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  11106. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  11107. break;
  11108. }
  11109. rootY += this._currentMeasure.top;
  11110. for (var i = 0; i < this._lines.length; i++) {
  11111. var line = this._lines[i];
  11112. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  11113. if (this._lineSpacing.isPixel) {
  11114. rootY += this._lineSpacing.getValue(this._host);
  11115. }
  11116. else {
  11117. rootY = rootY + (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11118. }
  11119. }
  11120. this._drawText(line.text, line.width, rootY, context);
  11121. rootY += this._fontOffset.height;
  11122. }
  11123. };
  11124. /**
  11125. * Given a width constraint applied on the text block, find the expected height
  11126. * @returns expected height
  11127. */
  11128. TextBlock.prototype.computeExpectedHeight = function () {
  11129. if (this.text && this.widthInPixels) {
  11130. var context_1 = document.createElement('canvas').getContext('2d');
  11131. if (context_1) {
  11132. this._applyStates(context_1);
  11133. if (!this._fontOffset) {
  11134. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  11135. }
  11136. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  11137. return this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  11138. }
  11139. }
  11140. return 0;
  11141. };
  11142. TextBlock.prototype.dispose = function () {
  11143. _super.prototype.dispose.call(this);
  11144. this.onTextChangedObservable.clear();
  11145. };
  11146. return TextBlock;
  11147. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  11148. /***/ }),
  11149. /***/ "./2D/controls/virtualKeyboard.ts":
  11150. /*!****************************************!*\
  11151. !*** ./2D/controls/virtualKeyboard.ts ***!
  11152. \****************************************/
  11153. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  11154. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11155. "use strict";
  11156. __webpack_require__.r(__webpack_exports__);
  11157. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  11158. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  11159. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11160. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  11161. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  11162. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  11163. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  11164. /**
  11165. * Class used to store key control properties
  11166. */
  11167. var KeyPropertySet = /** @class */ (function () {
  11168. function KeyPropertySet() {
  11169. }
  11170. return KeyPropertySet;
  11171. }());
  11172. /**
  11173. * Class used to create virtual keyboard
  11174. */
  11175. var VirtualKeyboard = /** @class */ (function (_super) {
  11176. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VirtualKeyboard, _super);
  11177. function VirtualKeyboard() {
  11178. var _this = _super !== null && _super.apply(this, arguments) || this;
  11179. /** Observable raised when a key is pressed */
  11180. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11181. /** Gets or sets default key button width */
  11182. _this.defaultButtonWidth = "40px";
  11183. /** Gets or sets default key button height */
  11184. _this.defaultButtonHeight = "40px";
  11185. /** Gets or sets default key button left padding */
  11186. _this.defaultButtonPaddingLeft = "2px";
  11187. /** Gets or sets default key button right padding */
  11188. _this.defaultButtonPaddingRight = "2px";
  11189. /** Gets or sets default key button top padding */
  11190. _this.defaultButtonPaddingTop = "2px";
  11191. /** Gets or sets default key button bottom padding */
  11192. _this.defaultButtonPaddingBottom = "2px";
  11193. /** Gets or sets default key button foreground color */
  11194. _this.defaultButtonColor = "#DDD";
  11195. /** Gets or sets default key button background color */
  11196. _this.defaultButtonBackground = "#070707";
  11197. /** Gets or sets shift button foreground color */
  11198. _this.shiftButtonColor = "#7799FF";
  11199. /** Gets or sets shift button thickness*/
  11200. _this.selectedShiftThickness = 1;
  11201. /** Gets shift key state */
  11202. _this.shiftState = 0;
  11203. _this._currentlyConnectedInputText = null;
  11204. _this._connectedInputTexts = [];
  11205. _this._onKeyPressObserver = null;
  11206. return _this;
  11207. }
  11208. VirtualKeyboard.prototype._getTypeName = function () {
  11209. return "VirtualKeyboard";
  11210. };
  11211. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  11212. var _this = this;
  11213. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  11214. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  11215. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  11216. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  11217. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  11218. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  11219. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  11220. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  11221. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  11222. button.thickness = 0;
  11223. button.isFocusInvisible = true;
  11224. button.shadowColor = this.shadowColor;
  11225. button.shadowBlur = this.shadowBlur;
  11226. button.shadowOffsetX = this.shadowOffsetX;
  11227. button.shadowOffsetY = this.shadowOffsetY;
  11228. button.onPointerUpObservable.add(function () {
  11229. _this.onKeyPressObservable.notifyObservers(key);
  11230. });
  11231. return button;
  11232. };
  11233. /**
  11234. * Adds a new row of keys
  11235. * @param keys defines the list of keys to add
  11236. * @param propertySets defines the associated property sets
  11237. */
  11238. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  11239. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  11240. panel.isVertical = false;
  11241. panel.isFocusInvisible = true;
  11242. for (var i = 0; i < keys.length; i++) {
  11243. var properties = null;
  11244. if (propertySets && propertySets.length === keys.length) {
  11245. properties = propertySets[i];
  11246. }
  11247. panel.addControl(this._createKey(keys[i], properties));
  11248. }
  11249. this.addControl(panel);
  11250. };
  11251. /**
  11252. * Set the shift key to a specific state
  11253. * @param shiftState defines the new shift state
  11254. */
  11255. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  11256. if (!this.children) {
  11257. return;
  11258. }
  11259. for (var i = 0; i < this.children.length; i++) {
  11260. var row = this.children[i];
  11261. if (!row || !row.children) {
  11262. continue;
  11263. }
  11264. var rowContainer = row;
  11265. for (var j = 0; j < rowContainer.children.length; j++) {
  11266. var button = rowContainer.children[j];
  11267. if (!button || !button.children[0]) {
  11268. continue;
  11269. }
  11270. var button_tblock = button.children[0];
  11271. if (button_tblock.text === "\u21E7") {
  11272. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  11273. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  11274. }
  11275. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  11276. }
  11277. }
  11278. };
  11279. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  11280. /** Gets the input text control currently attached to the keyboard */
  11281. get: function () {
  11282. return this._currentlyConnectedInputText;
  11283. },
  11284. enumerable: true,
  11285. configurable: true
  11286. });
  11287. /**
  11288. * Connects the keyboard with an input text control
  11289. *
  11290. * @param input defines the target control
  11291. */
  11292. VirtualKeyboard.prototype.connect = function (input) {
  11293. var _this = this;
  11294. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  11295. if (inputTextAlreadyConnected) {
  11296. return;
  11297. }
  11298. if (this._onKeyPressObserver === null) {
  11299. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  11300. if (!_this._currentlyConnectedInputText) {
  11301. return;
  11302. }
  11303. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  11304. switch (key) {
  11305. case "\u21E7":
  11306. _this.shiftState++;
  11307. if (_this.shiftState > 2) {
  11308. _this.shiftState = 0;
  11309. }
  11310. _this.applyShiftState(_this.shiftState);
  11311. return;
  11312. case "\u2190":
  11313. _this._currentlyConnectedInputText.processKey(8);
  11314. return;
  11315. case "\u21B5":
  11316. _this._currentlyConnectedInputText.processKey(13);
  11317. return;
  11318. }
  11319. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  11320. if (_this.shiftState === 1) {
  11321. _this.shiftState = 0;
  11322. _this.applyShiftState(_this.shiftState);
  11323. }
  11324. });
  11325. }
  11326. this.isVisible = false;
  11327. this._currentlyConnectedInputText = input;
  11328. input._connectedVirtualKeyboard = this;
  11329. // Events hooking
  11330. var onFocusObserver = input.onFocusObservable.add(function () {
  11331. _this._currentlyConnectedInputText = input;
  11332. input._connectedVirtualKeyboard = _this;
  11333. _this.isVisible = true;
  11334. });
  11335. var onBlurObserver = input.onBlurObservable.add(function () {
  11336. input._connectedVirtualKeyboard = null;
  11337. _this._currentlyConnectedInputText = null;
  11338. _this.isVisible = false;
  11339. });
  11340. this._connectedInputTexts.push({
  11341. input: input,
  11342. onBlurObserver: onBlurObserver,
  11343. onFocusObserver: onFocusObserver
  11344. });
  11345. };
  11346. /**
  11347. * Disconnects the keyboard from connected InputText controls
  11348. *
  11349. * @param input optionally defines a target control, otherwise all are disconnected
  11350. */
  11351. VirtualKeyboard.prototype.disconnect = function (input) {
  11352. var _this = this;
  11353. if (input) {
  11354. // .find not available on IE
  11355. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  11356. if (filtered.length === 1) {
  11357. this._removeConnectedInputObservables(filtered[0]);
  11358. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  11359. if (this._currentlyConnectedInputText === input) {
  11360. this._currentlyConnectedInputText = null;
  11361. }
  11362. }
  11363. }
  11364. else {
  11365. this._connectedInputTexts.forEach(function (connectedInputText) {
  11366. _this._removeConnectedInputObservables(connectedInputText);
  11367. });
  11368. this._connectedInputTexts = [];
  11369. }
  11370. if (this._connectedInputTexts.length === 0) {
  11371. this._currentlyConnectedInputText = null;
  11372. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  11373. this._onKeyPressObserver = null;
  11374. }
  11375. };
  11376. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  11377. connectedInputText.input._connectedVirtualKeyboard = null;
  11378. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  11379. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  11380. };
  11381. /**
  11382. * Release all resources
  11383. */
  11384. VirtualKeyboard.prototype.dispose = function () {
  11385. _super.prototype.dispose.call(this);
  11386. this.disconnect();
  11387. };
  11388. // Statics
  11389. /**
  11390. * Creates a new keyboard using a default layout
  11391. *
  11392. * @param name defines control name
  11393. * @returns a new VirtualKeyboard
  11394. */
  11395. VirtualKeyboard.CreateDefaultLayout = function (name) {
  11396. var returnValue = new VirtualKeyboard(name);
  11397. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  11398. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  11399. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  11400. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  11401. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  11402. return returnValue;
  11403. };
  11404. return VirtualKeyboard;
  11405. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  11406. /***/ }),
  11407. /***/ "./2D/index.ts":
  11408. /*!*********************!*\
  11409. !*** ./2D/index.ts ***!
  11410. \*********************/
  11411. /*! 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 */
  11412. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11413. "use strict";
  11414. __webpack_require__.r(__webpack_exports__);
  11415. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  11416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  11417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  11418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  11419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  11420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  11421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  11422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  11423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  11424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  11425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  11426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  11427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  11428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  11429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  11430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  11431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  11432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  11433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  11434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  11435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  11436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  11437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  11438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  11439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  11440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  11441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  11442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  11443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  11444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  11445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  11446. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  11447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  11448. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  11449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  11450. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  11451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  11452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  11453. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  11454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  11455. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  11456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  11457. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  11458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  11459. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  11461. /***/ }),
  11462. /***/ "./2D/math2D.ts":
  11463. /*!**********************!*\
  11464. !*** ./2D/math2D.ts ***!
  11465. \**********************/
  11466. /*! exports provided: Vector2WithInfo, Matrix2D */
  11467. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11468. "use strict";
  11469. __webpack_require__.r(__webpack_exports__);
  11470. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  11471. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  11472. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11473. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  11474. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  11475. /**
  11476. * Class used to transport Vector2 information for pointer events
  11477. */
  11478. var Vector2WithInfo = /** @class */ (function (_super) {
  11479. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Vector2WithInfo, _super);
  11480. /**
  11481. * Creates a new Vector2WithInfo
  11482. * @param source defines the vector2 data to transport
  11483. * @param buttonIndex defines the current mouse button index
  11484. */
  11485. function Vector2WithInfo(source,
  11486. /** defines the current mouse button index */
  11487. buttonIndex) {
  11488. if (buttonIndex === void 0) { buttonIndex = 0; }
  11489. var _this = _super.call(this, source.x, source.y) || this;
  11490. _this.buttonIndex = buttonIndex;
  11491. return _this;
  11492. }
  11493. return Vector2WithInfo;
  11494. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  11495. /** Class used to provide 2D matrix features */
  11496. var Matrix2D = /** @class */ (function () {
  11497. /**
  11498. * Creates a new matrix
  11499. * @param m00 defines value for (0, 0)
  11500. * @param m01 defines value for (0, 1)
  11501. * @param m10 defines value for (1, 0)
  11502. * @param m11 defines value for (1, 1)
  11503. * @param m20 defines value for (2, 0)
  11504. * @param m21 defines value for (2, 1)
  11505. */
  11506. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  11507. /** Gets the internal array of 6 floats used to store matrix data */
  11508. this.m = new Float32Array(6);
  11509. this.fromValues(m00, m01, m10, m11, m20, m21);
  11510. }
  11511. /**
  11512. * Fills the matrix from direct values
  11513. * @param m00 defines value for (0, 0)
  11514. * @param m01 defines value for (0, 1)
  11515. * @param m10 defines value for (1, 0)
  11516. * @param m11 defines value for (1, 1)
  11517. * @param m20 defines value for (2, 0)
  11518. * @param m21 defines value for (2, 1)
  11519. * @returns the current modified matrix
  11520. */
  11521. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  11522. this.m[0] = m00;
  11523. this.m[1] = m01;
  11524. this.m[2] = m10;
  11525. this.m[3] = m11;
  11526. this.m[4] = m20;
  11527. this.m[5] = m21;
  11528. return this;
  11529. };
  11530. /**
  11531. * Gets matrix determinant
  11532. * @returns the determinant
  11533. */
  11534. Matrix2D.prototype.determinant = function () {
  11535. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  11536. };
  11537. /**
  11538. * Inverses the matrix and stores it in a target matrix
  11539. * @param result defines the target matrix
  11540. * @returns the current matrix
  11541. */
  11542. Matrix2D.prototype.invertToRef = function (result) {
  11543. var l0 = this.m[0];
  11544. var l1 = this.m[1];
  11545. var l2 = this.m[2];
  11546. var l3 = this.m[3];
  11547. var l4 = this.m[4];
  11548. var l5 = this.m[5];
  11549. var det = this.determinant();
  11550. if (det < (babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  11551. result.m[0] = 0;
  11552. result.m[1] = 0;
  11553. result.m[2] = 0;
  11554. result.m[3] = 0;
  11555. result.m[4] = 0;
  11556. result.m[5] = 0;
  11557. return this;
  11558. }
  11559. var detDiv = 1 / det;
  11560. var det4 = l2 * l5 - l3 * l4;
  11561. var det5 = l1 * l4 - l0 * l5;
  11562. result.m[0] = l3 * detDiv;
  11563. result.m[1] = -l1 * detDiv;
  11564. result.m[2] = -l2 * detDiv;
  11565. result.m[3] = l0 * detDiv;
  11566. result.m[4] = det4 * detDiv;
  11567. result.m[5] = det5 * detDiv;
  11568. return this;
  11569. };
  11570. /**
  11571. * Multiplies the current matrix with another one
  11572. * @param other defines the second operand
  11573. * @param result defines the target matrix
  11574. * @returns the current matrix
  11575. */
  11576. Matrix2D.prototype.multiplyToRef = function (other, result) {
  11577. var l0 = this.m[0];
  11578. var l1 = this.m[1];
  11579. var l2 = this.m[2];
  11580. var l3 = this.m[3];
  11581. var l4 = this.m[4];
  11582. var l5 = this.m[5];
  11583. var r0 = other.m[0];
  11584. var r1 = other.m[1];
  11585. var r2 = other.m[2];
  11586. var r3 = other.m[3];
  11587. var r4 = other.m[4];
  11588. var r5 = other.m[5];
  11589. result.m[0] = l0 * r0 + l1 * r2;
  11590. result.m[1] = l0 * r1 + l1 * r3;
  11591. result.m[2] = l2 * r0 + l3 * r2;
  11592. result.m[3] = l2 * r1 + l3 * r3;
  11593. result.m[4] = l4 * r0 + l5 * r2 + r4;
  11594. result.m[5] = l4 * r1 + l5 * r3 + r5;
  11595. return this;
  11596. };
  11597. /**
  11598. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  11599. * @param x defines the x coordinate to transform
  11600. * @param y defines the x coordinate to transform
  11601. * @param result defines the target vector2
  11602. * @returns the current matrix
  11603. */
  11604. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  11605. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  11606. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  11607. return this;
  11608. };
  11609. // Statics
  11610. /**
  11611. * Creates an identity matrix
  11612. * @returns a new matrix
  11613. */
  11614. Matrix2D.Identity = function () {
  11615. return new Matrix2D(1, 0, 0, 1, 0, 0);
  11616. };
  11617. /**
  11618. * Creates a translation matrix and stores it in a target matrix
  11619. * @param x defines the x coordinate of the translation
  11620. * @param y defines the y coordinate of the translation
  11621. * @param result defines the target matrix
  11622. */
  11623. Matrix2D.TranslationToRef = function (x, y, result) {
  11624. result.fromValues(1, 0, 0, 1, x, y);
  11625. };
  11626. /**
  11627. * Creates a scaling matrix and stores it in a target matrix
  11628. * @param x defines the x coordinate of the scaling
  11629. * @param y defines the y coordinate of the scaling
  11630. * @param result defines the target matrix
  11631. */
  11632. Matrix2D.ScalingToRef = function (x, y, result) {
  11633. result.fromValues(x, 0, 0, y, 0, 0);
  11634. };
  11635. /**
  11636. * Creates a rotation matrix and stores it in a target matrix
  11637. * @param angle defines the rotation angle
  11638. * @param result defines the target matrix
  11639. */
  11640. Matrix2D.RotationToRef = function (angle, result) {
  11641. var s = Math.sin(angle);
  11642. var c = Math.cos(angle);
  11643. result.fromValues(c, s, -s, c, 0, 0);
  11644. };
  11645. /**
  11646. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  11647. * @param tx defines the x coordinate of the translation
  11648. * @param ty defines the y coordinate of the translation
  11649. * @param angle defines the rotation angle
  11650. * @param scaleX defines the x coordinate of the scaling
  11651. * @param scaleY defines the y coordinate of the scaling
  11652. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  11653. * @param result defines the target matrix
  11654. */
  11655. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  11656. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  11657. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  11658. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  11659. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  11660. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  11661. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  11662. if (parentMatrix) {
  11663. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  11664. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  11665. }
  11666. else {
  11667. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  11668. }
  11669. };
  11670. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  11671. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  11672. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  11673. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  11674. Matrix2D._TempCompose0 = Matrix2D.Identity();
  11675. Matrix2D._TempCompose1 = Matrix2D.Identity();
  11676. Matrix2D._TempCompose2 = Matrix2D.Identity();
  11677. return Matrix2D;
  11678. }());
  11679. /***/ }),
  11680. /***/ "./2D/measure.ts":
  11681. /*!***********************!*\
  11682. !*** ./2D/measure.ts ***!
  11683. \***********************/
  11684. /*! exports provided: Measure */
  11685. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11686. "use strict";
  11687. __webpack_require__.r(__webpack_exports__);
  11688. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  11689. /**
  11690. * Class used to store 2D control sizes
  11691. */
  11692. var Measure = /** @class */ (function () {
  11693. /**
  11694. * Creates a new measure
  11695. * @param left defines left coordinate
  11696. * @param top defines top coordinate
  11697. * @param width defines width dimension
  11698. * @param height defines height dimension
  11699. */
  11700. function Measure(
  11701. /** defines left coordinate */
  11702. left,
  11703. /** defines top coordinate */
  11704. top,
  11705. /** defines width dimension */
  11706. width,
  11707. /** defines height dimension */
  11708. height) {
  11709. this.left = left;
  11710. this.top = top;
  11711. this.width = width;
  11712. this.height = height;
  11713. }
  11714. /**
  11715. * Copy from another measure
  11716. * @param other defines the other measure to copy from
  11717. */
  11718. Measure.prototype.copyFrom = function (other) {
  11719. this.left = other.left;
  11720. this.top = other.top;
  11721. this.width = other.width;
  11722. this.height = other.height;
  11723. };
  11724. /**
  11725. * Copy from a group of 4 floats
  11726. * @param left defines left coordinate
  11727. * @param top defines top coordinate
  11728. * @param width defines width dimension
  11729. * @param height defines height dimension
  11730. */
  11731. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  11732. this.left = left;
  11733. this.top = top;
  11734. this.width = width;
  11735. this.height = height;
  11736. };
  11737. /**
  11738. * Check equality between this measure and another one
  11739. * @param other defines the other measures
  11740. * @returns true if both measures are equals
  11741. */
  11742. Measure.prototype.isEqualsTo = function (other) {
  11743. if (this.left !== other.left) {
  11744. return false;
  11745. }
  11746. if (this.top !== other.top) {
  11747. return false;
  11748. }
  11749. if (this.width !== other.width) {
  11750. return false;
  11751. }
  11752. if (this.height !== other.height) {
  11753. return false;
  11754. }
  11755. return true;
  11756. };
  11757. /**
  11758. * Creates an empty measure
  11759. * @returns a new measure
  11760. */
  11761. Measure.Empty = function () {
  11762. return new Measure(0, 0, 0, 0);
  11763. };
  11764. return Measure;
  11765. }());
  11766. /***/ }),
  11767. /***/ "./2D/multiLinePoint.ts":
  11768. /*!******************************!*\
  11769. !*** ./2D/multiLinePoint.ts ***!
  11770. \******************************/
  11771. /*! exports provided: MultiLinePoint */
  11772. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11773. "use strict";
  11774. __webpack_require__.r(__webpack_exports__);
  11775. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  11776. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  11777. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  11778. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11779. /**
  11780. * Class used to store a point for a MultiLine object.
  11781. * The point can be pure 2D coordinates, a mesh or a control
  11782. */
  11783. var MultiLinePoint = /** @class */ (function () {
  11784. /**
  11785. * Creates a new MultiLinePoint
  11786. * @param multiLine defines the source MultiLine object
  11787. */
  11788. function MultiLinePoint(multiLine) {
  11789. this._multiLine = multiLine;
  11790. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  11791. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  11792. this._point = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  11793. }
  11794. Object.defineProperty(MultiLinePoint.prototype, "x", {
  11795. /** Gets or sets x coordinate */
  11796. get: function () {
  11797. return this._x.toString(this._multiLine._host);
  11798. },
  11799. set: function (value) {
  11800. if (this._x.toString(this._multiLine._host) === value) {
  11801. return;
  11802. }
  11803. if (this._x.fromString(value)) {
  11804. this._multiLine._markAsDirty();
  11805. }
  11806. },
  11807. enumerable: true,
  11808. configurable: true
  11809. });
  11810. Object.defineProperty(MultiLinePoint.prototype, "y", {
  11811. /** Gets or sets y coordinate */
  11812. get: function () {
  11813. return this._y.toString(this._multiLine._host);
  11814. },
  11815. set: function (value) {
  11816. if (this._y.toString(this._multiLine._host) === value) {
  11817. return;
  11818. }
  11819. if (this._y.fromString(value)) {
  11820. this._multiLine._markAsDirty();
  11821. }
  11822. },
  11823. enumerable: true,
  11824. configurable: true
  11825. });
  11826. Object.defineProperty(MultiLinePoint.prototype, "control", {
  11827. /** Gets or sets the control associated with this point */
  11828. get: function () {
  11829. return this._control;
  11830. },
  11831. set: function (value) {
  11832. if (this._control === value) {
  11833. return;
  11834. }
  11835. if (this._control && this._controlObserver) {
  11836. this._control.onDirtyObservable.remove(this._controlObserver);
  11837. this._controlObserver = null;
  11838. }
  11839. this._control = value;
  11840. if (this._control) {
  11841. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  11842. }
  11843. this._multiLine._markAsDirty();
  11844. },
  11845. enumerable: true,
  11846. configurable: true
  11847. });
  11848. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  11849. /** Gets or sets the mesh associated with this point */
  11850. get: function () {
  11851. return this._mesh;
  11852. },
  11853. set: function (value) {
  11854. if (this._mesh === value) {
  11855. return;
  11856. }
  11857. if (this._mesh && this._meshObserver) {
  11858. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  11859. }
  11860. this._mesh = value;
  11861. if (this._mesh) {
  11862. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  11863. }
  11864. this._multiLine._markAsDirty();
  11865. },
  11866. enumerable: true,
  11867. configurable: true
  11868. });
  11869. /** Resets links */
  11870. MultiLinePoint.prototype.resetLinks = function () {
  11871. this.control = null;
  11872. this.mesh = null;
  11873. };
  11874. /**
  11875. * Gets a translation vector
  11876. * @returns the translation vector
  11877. */
  11878. MultiLinePoint.prototype.translate = function () {
  11879. this._point = this._translatePoint();
  11880. return this._point;
  11881. };
  11882. MultiLinePoint.prototype._translatePoint = function () {
  11883. if (this._mesh != null) {
  11884. return this._multiLine._host.getProjectedPosition(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  11885. }
  11886. else if (this._control != null) {
  11887. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](this._control.centerX, this._control.centerY);
  11888. }
  11889. else {
  11890. var host = this._multiLine._host;
  11891. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  11892. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  11893. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](xValue, yValue);
  11894. }
  11895. };
  11896. /** Release associated resources */
  11897. MultiLinePoint.prototype.dispose = function () {
  11898. this.resetLinks();
  11899. };
  11900. return MultiLinePoint;
  11901. }());
  11902. /***/ }),
  11903. /***/ "./2D/style.ts":
  11904. /*!*********************!*\
  11905. !*** ./2D/style.ts ***!
  11906. \*********************/
  11907. /*! exports provided: Style */
  11908. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11909. "use strict";
  11910. __webpack_require__.r(__webpack_exports__);
  11911. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  11912. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  11913. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  11914. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11915. /**
  11916. * Define a style used by control to automatically setup properties based on a template.
  11917. * Only support font related properties so far
  11918. */
  11919. var Style = /** @class */ (function () {
  11920. /**
  11921. * Creates a new style object
  11922. * @param host defines the AdvancedDynamicTexture which hosts this style
  11923. */
  11924. function Style(host) {
  11925. this._fontFamily = "Arial";
  11926. this._fontStyle = "";
  11927. this._fontWeight = "";
  11928. /** @hidden */
  11929. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  11930. /**
  11931. * Observable raised when the style values are changed
  11932. */
  11933. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  11934. this._host = host;
  11935. }
  11936. Object.defineProperty(Style.prototype, "fontSize", {
  11937. /**
  11938. * Gets or sets the font size
  11939. */
  11940. get: function () {
  11941. return this._fontSize.toString(this._host);
  11942. },
  11943. set: function (value) {
  11944. if (this._fontSize.toString(this._host) === value) {
  11945. return;
  11946. }
  11947. if (this._fontSize.fromString(value)) {
  11948. this.onChangedObservable.notifyObservers(this);
  11949. }
  11950. },
  11951. enumerable: true,
  11952. configurable: true
  11953. });
  11954. Object.defineProperty(Style.prototype, "fontFamily", {
  11955. /**
  11956. * Gets or sets the font family
  11957. */
  11958. get: function () {
  11959. return this._fontFamily;
  11960. },
  11961. set: function (value) {
  11962. if (this._fontFamily === value) {
  11963. return;
  11964. }
  11965. this._fontFamily = value;
  11966. this.onChangedObservable.notifyObservers(this);
  11967. },
  11968. enumerable: true,
  11969. configurable: true
  11970. });
  11971. Object.defineProperty(Style.prototype, "fontStyle", {
  11972. /**
  11973. * Gets or sets the font style
  11974. */
  11975. get: function () {
  11976. return this._fontStyle;
  11977. },
  11978. set: function (value) {
  11979. if (this._fontStyle === value) {
  11980. return;
  11981. }
  11982. this._fontStyle = value;
  11983. this.onChangedObservable.notifyObservers(this);
  11984. },
  11985. enumerable: true,
  11986. configurable: true
  11987. });
  11988. Object.defineProperty(Style.prototype, "fontWeight", {
  11989. /** Gets or sets font weight */
  11990. get: function () {
  11991. return this._fontWeight;
  11992. },
  11993. set: function (value) {
  11994. if (this._fontWeight === value) {
  11995. return;
  11996. }
  11997. this._fontWeight = value;
  11998. this.onChangedObservable.notifyObservers(this);
  11999. },
  12000. enumerable: true,
  12001. configurable: true
  12002. });
  12003. /** Dispose all associated resources */
  12004. Style.prototype.dispose = function () {
  12005. this.onChangedObservable.clear();
  12006. };
  12007. return Style;
  12008. }());
  12009. /***/ }),
  12010. /***/ "./2D/valueAndUnit.ts":
  12011. /*!****************************!*\
  12012. !*** ./2D/valueAndUnit.ts ***!
  12013. \****************************/
  12014. /*! exports provided: ValueAndUnit */
  12015. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12016. "use strict";
  12017. __webpack_require__.r(__webpack_exports__);
  12018. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  12019. /**
  12020. * Class used to specific a value and its associated unit
  12021. */
  12022. var ValueAndUnit = /** @class */ (function () {
  12023. /**
  12024. * Creates a new ValueAndUnit
  12025. * @param value defines the value to store
  12026. * @param unit defines the unit to store
  12027. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  12028. */
  12029. function ValueAndUnit(value,
  12030. /** defines the unit to store */
  12031. unit,
  12032. /** defines a boolean indicating if the value can be negative */
  12033. negativeValueAllowed) {
  12034. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12035. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  12036. this.unit = unit;
  12037. this.negativeValueAllowed = negativeValueAllowed;
  12038. this._value = 1;
  12039. /**
  12040. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  12041. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  12042. */
  12043. this.ignoreAdaptiveScaling = false;
  12044. this._value = value;
  12045. this._originalUnit = unit;
  12046. }
  12047. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  12048. /** Gets a boolean indicating if the value is a percentage */
  12049. get: function () {
  12050. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  12051. },
  12052. enumerable: true,
  12053. configurable: true
  12054. });
  12055. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  12056. /** Gets a boolean indicating if the value is store as pixel */
  12057. get: function () {
  12058. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  12059. },
  12060. enumerable: true,
  12061. configurable: true
  12062. });
  12063. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  12064. /** Gets direct internal value */
  12065. get: function () {
  12066. return this._value;
  12067. },
  12068. enumerable: true,
  12069. configurable: true
  12070. });
  12071. /**
  12072. * Gets value as pixel
  12073. * @param host defines the root host
  12074. * @param refValue defines the reference value for percentages
  12075. * @returns the value as pixel
  12076. */
  12077. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  12078. if (this.isPixel) {
  12079. return this.getValue(host);
  12080. }
  12081. return this.getValue(host) * refValue;
  12082. };
  12083. /**
  12084. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  12085. * @param value defines the value to store
  12086. * @param unit defines the unit to store
  12087. * @returns the current ValueAndUnit
  12088. */
  12089. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  12090. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12091. this._value = value;
  12092. this.unit = unit;
  12093. return this;
  12094. };
  12095. /**
  12096. * Gets the value accordingly to its unit
  12097. * @param host defines the root host
  12098. * @returns the value
  12099. */
  12100. ValueAndUnit.prototype.getValue = function (host) {
  12101. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  12102. var width = 0;
  12103. var height = 0;
  12104. if (host.idealWidth) {
  12105. width = (this._value * host.getSize().width) / host.idealWidth;
  12106. }
  12107. if (host.idealHeight) {
  12108. height = (this._value * host.getSize().height) / host.idealHeight;
  12109. }
  12110. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  12111. return window.innerWidth < window.innerHeight ? width : height;
  12112. }
  12113. if (host.idealWidth) { // horizontal
  12114. return width;
  12115. }
  12116. if (host.idealHeight) { // vertical
  12117. return height;
  12118. }
  12119. }
  12120. return this._value;
  12121. };
  12122. /**
  12123. * Gets a string representation of the value
  12124. * @param host defines the root host
  12125. * @returns a string
  12126. */
  12127. ValueAndUnit.prototype.toString = function (host) {
  12128. switch (this.unit) {
  12129. case ValueAndUnit.UNITMODE_PERCENTAGE:
  12130. return (this.getValue(host) * 100) + "%";
  12131. case ValueAndUnit.UNITMODE_PIXEL:
  12132. return this.getValue(host) + "px";
  12133. }
  12134. return this.unit.toString();
  12135. };
  12136. /**
  12137. * Store a value parsed from a string
  12138. * @param source defines the source string
  12139. * @returns true if the value was successfully parsed
  12140. */
  12141. ValueAndUnit.prototype.fromString = function (source) {
  12142. var match = ValueAndUnit._Regex.exec(source.toString());
  12143. if (!match || match.length === 0) {
  12144. return false;
  12145. }
  12146. var sourceValue = parseFloat(match[1]);
  12147. var sourceUnit = this._originalUnit;
  12148. if (!this.negativeValueAllowed) {
  12149. if (sourceValue < 0) {
  12150. sourceValue = 0;
  12151. }
  12152. }
  12153. if (match.length === 4) {
  12154. switch (match[3]) {
  12155. case "px":
  12156. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  12157. break;
  12158. case "%":
  12159. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  12160. sourceValue /= 100.0;
  12161. break;
  12162. }
  12163. }
  12164. if (sourceValue === this._value && sourceUnit === this.unit) {
  12165. return false;
  12166. }
  12167. this._value = sourceValue;
  12168. this.unit = sourceUnit;
  12169. return true;
  12170. };
  12171. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  12172. /** UNITMODE_PERCENTAGE */
  12173. get: function () {
  12174. return ValueAndUnit._UNITMODE_PERCENTAGE;
  12175. },
  12176. enumerable: true,
  12177. configurable: true
  12178. });
  12179. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  12180. /** UNITMODE_PIXEL */
  12181. get: function () {
  12182. return ValueAndUnit._UNITMODE_PIXEL;
  12183. },
  12184. enumerable: true,
  12185. configurable: true
  12186. });
  12187. // Static
  12188. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  12189. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  12190. ValueAndUnit._UNITMODE_PIXEL = 1;
  12191. return ValueAndUnit;
  12192. }());
  12193. /***/ }),
  12194. /***/ "./3D/controls/abstractButton3D.ts":
  12195. /*!*****************************************!*\
  12196. !*** ./3D/controls/abstractButton3D.ts ***!
  12197. \*****************************************/
  12198. /*! exports provided: AbstractButton3D */
  12199. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12200. "use strict";
  12201. __webpack_require__.r(__webpack_exports__);
  12202. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  12203. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12204. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/observable");
  12205. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  12206. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  12207. /**
  12208. * Class used as a root to all buttons
  12209. */
  12210. var AbstractButton3D = /** @class */ (function (_super) {
  12211. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AbstractButton3D, _super);
  12212. /**
  12213. * Creates a new button
  12214. * @param name defines the control name
  12215. */
  12216. function AbstractButton3D(name) {
  12217. return _super.call(this, name) || this;
  12218. }
  12219. AbstractButton3D.prototype._getTypeName = function () {
  12220. return "AbstractButton3D";
  12221. };
  12222. // Mesh association
  12223. AbstractButton3D.prototype._createNode = function (scene) {
  12224. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  12225. };
  12226. return AbstractButton3D;
  12227. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  12228. /***/ }),
  12229. /***/ "./3D/controls/button3D.ts":
  12230. /*!*********************************!*\
  12231. !*** ./3D/controls/button3D.ts ***!
  12232. \*********************************/
  12233. /*! exports provided: Button3D */
  12234. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12235. "use strict";
  12236. __webpack_require__.r(__webpack_exports__);
  12237. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  12238. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12239. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  12240. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  12241. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  12242. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  12243. /**
  12244. * Class used to create a button in 3D
  12245. */
  12246. var Button3D = /** @class */ (function (_super) {
  12247. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Button3D, _super);
  12248. /**
  12249. * Creates a new button
  12250. * @param name defines the control name
  12251. */
  12252. function Button3D(name) {
  12253. var _this = _super.call(this, name) || this;
  12254. _this._contentResolution = 512;
  12255. _this._contentScaleRatio = 2;
  12256. // Default animations
  12257. _this.pointerEnterAnimation = function () {
  12258. if (!_this.mesh) {
  12259. return;
  12260. }
  12261. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  12262. };
  12263. _this.pointerOutAnimation = function () {
  12264. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  12265. };
  12266. _this.pointerDownAnimation = function () {
  12267. if (!_this.mesh) {
  12268. return;
  12269. }
  12270. _this.mesh.scaling.scaleInPlace(0.95);
  12271. };
  12272. _this.pointerUpAnimation = function () {
  12273. if (!_this.mesh) {
  12274. return;
  12275. }
  12276. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  12277. };
  12278. return _this;
  12279. }
  12280. Object.defineProperty(Button3D.prototype, "contentResolution", {
  12281. /**
  12282. * Gets or sets the texture resolution used to render content (512 by default)
  12283. */
  12284. get: function () {
  12285. return this._contentResolution;
  12286. },
  12287. set: function (value) {
  12288. if (this._contentResolution === value) {
  12289. return;
  12290. }
  12291. this._contentResolution = value;
  12292. this._resetContent();
  12293. },
  12294. enumerable: true,
  12295. configurable: true
  12296. });
  12297. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  12298. /**
  12299. * Gets or sets the texture scale ratio used to render content (2 by default)
  12300. */
  12301. get: function () {
  12302. return this._contentScaleRatio;
  12303. },
  12304. set: function (value) {
  12305. if (this._contentScaleRatio === value) {
  12306. return;
  12307. }
  12308. this._contentScaleRatio = value;
  12309. this._resetContent();
  12310. },
  12311. enumerable: true,
  12312. configurable: true
  12313. });
  12314. Button3D.prototype._disposeFacadeTexture = function () {
  12315. if (this._facadeTexture) {
  12316. this._facadeTexture.dispose();
  12317. this._facadeTexture = null;
  12318. }
  12319. };
  12320. Button3D.prototype._resetContent = function () {
  12321. this._disposeFacadeTexture();
  12322. this.content = this._content;
  12323. };
  12324. Object.defineProperty(Button3D.prototype, "content", {
  12325. /**
  12326. * Gets or sets the GUI 2D content used to display the button's facade
  12327. */
  12328. get: function () {
  12329. return this._content;
  12330. },
  12331. set: function (value) {
  12332. this._content = value;
  12333. if (!this._host || !this._host.utilityLayer) {
  12334. return;
  12335. }
  12336. if (!this._facadeTexture) {
  12337. 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);
  12338. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  12339. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  12340. this._facadeTexture.premulAlpha = true;
  12341. }
  12342. this._facadeTexture.addControl(value);
  12343. this._applyFacade(this._facadeTexture);
  12344. },
  12345. enumerable: true,
  12346. configurable: true
  12347. });
  12348. /**
  12349. * Apply the facade texture (created from the content property).
  12350. * This function can be overloaded by child classes
  12351. * @param facadeTexture defines the AdvancedDynamicTexture to use
  12352. */
  12353. Button3D.prototype._applyFacade = function (facadeTexture) {
  12354. this._currentMaterial.emissiveTexture = facadeTexture;
  12355. };
  12356. Button3D.prototype._getTypeName = function () {
  12357. return "Button3D";
  12358. };
  12359. // Mesh association
  12360. Button3D.prototype._createNode = function (scene) {
  12361. var faceUV = new Array(6);
  12362. for (var i = 0; i < 6; i++) {
  12363. faceUV[i] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  12364. }
  12365. faceUV[1] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  12366. var mesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["MeshBuilder"].CreateBox(this.name + "_rootMesh", {
  12367. width: 1.0,
  12368. height: 1.0,
  12369. depth: 0.08,
  12370. faceUV: faceUV
  12371. }, scene);
  12372. return mesh;
  12373. };
  12374. Button3D.prototype._affectMaterial = function (mesh) {
  12375. var material = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  12376. material.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  12377. mesh.material = material;
  12378. this._currentMaterial = material;
  12379. this._resetContent();
  12380. };
  12381. /**
  12382. * Releases all associated resources
  12383. */
  12384. Button3D.prototype.dispose = function () {
  12385. _super.prototype.dispose.call(this);
  12386. this._disposeFacadeTexture();
  12387. if (this._currentMaterial) {
  12388. this._currentMaterial.dispose();
  12389. }
  12390. };
  12391. return Button3D;
  12392. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  12393. /***/ }),
  12394. /***/ "./3D/controls/container3D.ts":
  12395. /*!************************************!*\
  12396. !*** ./3D/controls/container3D.ts ***!
  12397. \************************************/
  12398. /*! exports provided: Container3D */
  12399. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12400. "use strict";
  12401. __webpack_require__.r(__webpack_exports__);
  12402. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  12403. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12404. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/observable");
  12405. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  12406. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  12407. /**
  12408. * Class used to create containers for controls
  12409. */
  12410. var Container3D = /** @class */ (function (_super) {
  12411. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Container3D, _super);
  12412. /**
  12413. * Creates a new container
  12414. * @param name defines the container name
  12415. */
  12416. function Container3D(name) {
  12417. var _this = _super.call(this, name) || this;
  12418. _this._blockLayout = false;
  12419. /**
  12420. * Gets the list of child controls
  12421. */
  12422. _this._children = new Array();
  12423. return _this;
  12424. }
  12425. Object.defineProperty(Container3D.prototype, "children", {
  12426. /**
  12427. * Gets the list of child controls
  12428. */
  12429. get: function () {
  12430. return this._children;
  12431. },
  12432. enumerable: true,
  12433. configurable: true
  12434. });
  12435. Object.defineProperty(Container3D.prototype, "blockLayout", {
  12436. /**
  12437. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  12438. * This is helpful to optimize layout operation when adding multiple children in a row
  12439. */
  12440. get: function () {
  12441. return this._blockLayout;
  12442. },
  12443. set: function (value) {
  12444. if (this._blockLayout === value) {
  12445. return;
  12446. }
  12447. this._blockLayout = value;
  12448. if (!this._blockLayout) {
  12449. this._arrangeChildren();
  12450. }
  12451. },
  12452. enumerable: true,
  12453. configurable: true
  12454. });
  12455. /**
  12456. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  12457. * @returns the current container
  12458. */
  12459. Container3D.prototype.updateLayout = function () {
  12460. this._arrangeChildren();
  12461. return this;
  12462. };
  12463. /**
  12464. * Gets a boolean indicating if the given control is in the children of this control
  12465. * @param control defines the control to check
  12466. * @returns true if the control is in the child list
  12467. */
  12468. Container3D.prototype.containsControl = function (control) {
  12469. return this._children.indexOf(control) !== -1;
  12470. };
  12471. /**
  12472. * Adds a control to the children of this control
  12473. * @param control defines the control to add
  12474. * @returns the current container
  12475. */
  12476. Container3D.prototype.addControl = function (control) {
  12477. var index = this._children.indexOf(control);
  12478. if (index !== -1) {
  12479. return this;
  12480. }
  12481. control.parent = this;
  12482. control._host = this._host;
  12483. this._children.push(control);
  12484. if (this._host.utilityLayer) {
  12485. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  12486. if (control.node) {
  12487. control.node.parent = this.node;
  12488. }
  12489. if (!this.blockLayout) {
  12490. this._arrangeChildren();
  12491. }
  12492. }
  12493. return this;
  12494. };
  12495. /**
  12496. * This function will be called everytime a new control is added
  12497. */
  12498. Container3D.prototype._arrangeChildren = function () {
  12499. };
  12500. Container3D.prototype._createNode = function (scene) {
  12501. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  12502. };
  12503. /**
  12504. * Removes a control from the children of this control
  12505. * @param control defines the control to remove
  12506. * @returns the current container
  12507. */
  12508. Container3D.prototype.removeControl = function (control) {
  12509. var index = this._children.indexOf(control);
  12510. if (index !== -1) {
  12511. this._children.splice(index, 1);
  12512. control.parent = null;
  12513. control._disposeNode();
  12514. }
  12515. return this;
  12516. };
  12517. Container3D.prototype._getTypeName = function () {
  12518. return "Container3D";
  12519. };
  12520. /**
  12521. * Releases all associated resources
  12522. */
  12523. Container3D.prototype.dispose = function () {
  12524. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  12525. var control = _a[_i];
  12526. control.dispose();
  12527. }
  12528. this._children = [];
  12529. _super.prototype.dispose.call(this);
  12530. };
  12531. /** Control rotation will remain unchanged */
  12532. Container3D.UNSET_ORIENTATION = 0;
  12533. /** Control will rotate to make it look at sphere central axis */
  12534. Container3D.FACEORIGIN_ORIENTATION = 1;
  12535. /** Control will rotate to make it look back at sphere central axis */
  12536. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  12537. /** Control will rotate to look at z axis (0, 0, 1) */
  12538. Container3D.FACEFORWARD_ORIENTATION = 3;
  12539. /** Control will rotate to look at negative z axis (0, 0, -1) */
  12540. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  12541. return Container3D;
  12542. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  12543. /***/ }),
  12544. /***/ "./3D/controls/control3D.ts":
  12545. /*!**********************************!*\
  12546. !*** ./3D/controls/control3D.ts ***!
  12547. \**********************************/
  12548. /*! exports provided: Control3D */
  12549. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12550. "use strict";
  12551. __webpack_require__.r(__webpack_exports__);
  12552. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  12553. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  12554. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  12555. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  12556. /**
  12557. * Class used as base class for controls
  12558. */
  12559. var Control3D = /** @class */ (function () {
  12560. /**
  12561. * Creates a new control
  12562. * @param name defines the control name
  12563. */
  12564. function Control3D(
  12565. /** Defines the control name */
  12566. name) {
  12567. this.name = name;
  12568. this._downCount = 0;
  12569. this._enterCount = -1;
  12570. this._downPointerIds = {};
  12571. this._isVisible = true;
  12572. /**
  12573. * An event triggered when the pointer move over the control
  12574. */
  12575. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12576. /**
  12577. * An event triggered when the pointer move out of the control
  12578. */
  12579. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12580. /**
  12581. * An event triggered when the pointer taps the control
  12582. */
  12583. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12584. /**
  12585. * An event triggered when pointer is up
  12586. */
  12587. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12588. /**
  12589. * An event triggered when a control is clicked on (with a mouse)
  12590. */
  12591. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12592. /**
  12593. * An event triggered when pointer enters the control
  12594. */
  12595. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12596. // Behaviors
  12597. this._behaviors = new Array();
  12598. }
  12599. Object.defineProperty(Control3D.prototype, "position", {
  12600. /** Gets or sets the control position in world space */
  12601. get: function () {
  12602. if (!this._node) {
  12603. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  12604. }
  12605. return this._node.position;
  12606. },
  12607. set: function (value) {
  12608. if (!this._node) {
  12609. return;
  12610. }
  12611. this._node.position = value;
  12612. },
  12613. enumerable: true,
  12614. configurable: true
  12615. });
  12616. Object.defineProperty(Control3D.prototype, "scaling", {
  12617. /** Gets or sets the control scaling in world space */
  12618. get: function () {
  12619. if (!this._node) {
  12620. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  12621. }
  12622. return this._node.scaling;
  12623. },
  12624. set: function (value) {
  12625. if (!this._node) {
  12626. return;
  12627. }
  12628. this._node.scaling = value;
  12629. },
  12630. enumerable: true,
  12631. configurable: true
  12632. });
  12633. Object.defineProperty(Control3D.prototype, "behaviors", {
  12634. /**
  12635. * Gets the list of attached behaviors
  12636. * @see http://doc.babylonjs.com/features/behaviour
  12637. */
  12638. get: function () {
  12639. return this._behaviors;
  12640. },
  12641. enumerable: true,
  12642. configurable: true
  12643. });
  12644. /**
  12645. * Attach a behavior to the control
  12646. * @see http://doc.babylonjs.com/features/behaviour
  12647. * @param behavior defines the behavior to attach
  12648. * @returns the current control
  12649. */
  12650. Control3D.prototype.addBehavior = function (behavior) {
  12651. var _this = this;
  12652. var index = this._behaviors.indexOf(behavior);
  12653. if (index !== -1) {
  12654. return this;
  12655. }
  12656. behavior.init();
  12657. var scene = this._host.scene;
  12658. if (scene.isLoading) {
  12659. // We defer the attach when the scene will be loaded
  12660. scene.onDataLoadedObservable.addOnce(function () {
  12661. behavior.attach(_this);
  12662. });
  12663. }
  12664. else {
  12665. behavior.attach(this);
  12666. }
  12667. this._behaviors.push(behavior);
  12668. return this;
  12669. };
  12670. /**
  12671. * Remove an attached behavior
  12672. * @see http://doc.babylonjs.com/features/behaviour
  12673. * @param behavior defines the behavior to attach
  12674. * @returns the current control
  12675. */
  12676. Control3D.prototype.removeBehavior = function (behavior) {
  12677. var index = this._behaviors.indexOf(behavior);
  12678. if (index === -1) {
  12679. return this;
  12680. }
  12681. this._behaviors[index].detach();
  12682. this._behaviors.splice(index, 1);
  12683. return this;
  12684. };
  12685. /**
  12686. * Gets an attached behavior by name
  12687. * @param name defines the name of the behavior to look for
  12688. * @see http://doc.babylonjs.com/features/behaviour
  12689. * @returns null if behavior was not found else the requested behavior
  12690. */
  12691. Control3D.prototype.getBehaviorByName = function (name) {
  12692. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  12693. var behavior = _a[_i];
  12694. if (behavior.name === name) {
  12695. return behavior;
  12696. }
  12697. }
  12698. return null;
  12699. };
  12700. Object.defineProperty(Control3D.prototype, "isVisible", {
  12701. /** Gets or sets a boolean indicating if the control is visible */
  12702. get: function () {
  12703. return this._isVisible;
  12704. },
  12705. set: function (value) {
  12706. if (this._isVisible === value) {
  12707. return;
  12708. }
  12709. this._isVisible = value;
  12710. var mesh = this.mesh;
  12711. if (mesh) {
  12712. mesh.setEnabled(value);
  12713. }
  12714. },
  12715. enumerable: true,
  12716. configurable: true
  12717. });
  12718. Object.defineProperty(Control3D.prototype, "typeName", {
  12719. /**
  12720. * Gets a string representing the class name
  12721. */
  12722. get: function () {
  12723. return this._getTypeName();
  12724. },
  12725. enumerable: true,
  12726. configurable: true
  12727. });
  12728. /**
  12729. * Get the current class name of the control.
  12730. * @returns current class name
  12731. */
  12732. Control3D.prototype.getClassName = function () {
  12733. return this._getTypeName();
  12734. };
  12735. Control3D.prototype._getTypeName = function () {
  12736. return "Control3D";
  12737. };
  12738. Object.defineProperty(Control3D.prototype, "node", {
  12739. /**
  12740. * Gets the transform node used by this control
  12741. */
  12742. get: function () {
  12743. return this._node;
  12744. },
  12745. enumerable: true,
  12746. configurable: true
  12747. });
  12748. Object.defineProperty(Control3D.prototype, "mesh", {
  12749. /**
  12750. * Gets the mesh used to render this control
  12751. */
  12752. get: function () {
  12753. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  12754. return this._node;
  12755. }
  12756. return null;
  12757. },
  12758. enumerable: true,
  12759. configurable: true
  12760. });
  12761. /**
  12762. * Link the control as child of the given node
  12763. * @param node defines the node to link to. Use null to unlink the control
  12764. * @returns the current control
  12765. */
  12766. Control3D.prototype.linkToTransformNode = function (node) {
  12767. if (this._node) {
  12768. this._node.parent = node;
  12769. }
  12770. return this;
  12771. };
  12772. /** @hidden **/
  12773. Control3D.prototype._prepareNode = function (scene) {
  12774. if (!this._node) {
  12775. this._node = this._createNode(scene);
  12776. if (!this.node) {
  12777. return;
  12778. }
  12779. this._node.metadata = this; // Store the control on the metadata field in order to get it when picking
  12780. this._node.position = this.position;
  12781. this._node.scaling = this.scaling;
  12782. var mesh = this.mesh;
  12783. if (mesh) {
  12784. mesh.isPickable = true;
  12785. this._affectMaterial(mesh);
  12786. }
  12787. }
  12788. };
  12789. /**
  12790. * Node creation.
  12791. * Can be overriden by children
  12792. * @param scene defines the scene where the node must be attached
  12793. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  12794. */
  12795. Control3D.prototype._createNode = function (scene) {
  12796. // Do nothing by default
  12797. return null;
  12798. };
  12799. /**
  12800. * Affect a material to the given mesh
  12801. * @param mesh defines the mesh which will represent the control
  12802. */
  12803. Control3D.prototype._affectMaterial = function (mesh) {
  12804. mesh.material = null;
  12805. };
  12806. // Pointers
  12807. /** @hidden */
  12808. Control3D.prototype._onPointerMove = function (target, coordinates) {
  12809. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  12810. };
  12811. /** @hidden */
  12812. Control3D.prototype._onPointerEnter = function (target) {
  12813. if (this._enterCount > 0) {
  12814. return false;
  12815. }
  12816. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  12817. this._enterCount = 0;
  12818. }
  12819. this._enterCount++;
  12820. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  12821. if (this.pointerEnterAnimation) {
  12822. this.pointerEnterAnimation();
  12823. }
  12824. return true;
  12825. };
  12826. /** @hidden */
  12827. Control3D.prototype._onPointerOut = function (target) {
  12828. this._enterCount = 0;
  12829. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  12830. if (this.pointerOutAnimation) {
  12831. this.pointerOutAnimation();
  12832. }
  12833. };
  12834. /** @hidden */
  12835. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  12836. if (this._downCount !== 0) {
  12837. return false;
  12838. }
  12839. this._downCount++;
  12840. this._downPointerIds[pointerId] = true;
  12841. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  12842. if (this.pointerDownAnimation) {
  12843. this.pointerDownAnimation();
  12844. }
  12845. return true;
  12846. };
  12847. /** @hidden */
  12848. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  12849. this._downCount = 0;
  12850. delete this._downPointerIds[pointerId];
  12851. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  12852. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  12853. }
  12854. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  12855. if (this.pointerUpAnimation) {
  12856. this.pointerUpAnimation();
  12857. }
  12858. };
  12859. /** @hidden */
  12860. Control3D.prototype.forcePointerUp = function (pointerId) {
  12861. if (pointerId === void 0) { pointerId = null; }
  12862. if (pointerId !== null) {
  12863. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  12864. }
  12865. else {
  12866. for (var key in this._downPointerIds) {
  12867. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  12868. }
  12869. }
  12870. };
  12871. /** @hidden */
  12872. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  12873. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  12874. this._onPointerMove(this, pickedPoint);
  12875. var previousControlOver = this._host._lastControlOver[pointerId];
  12876. if (previousControlOver && previousControlOver !== this) {
  12877. previousControlOver._onPointerOut(this);
  12878. }
  12879. if (previousControlOver !== this) {
  12880. this._onPointerEnter(this);
  12881. }
  12882. this._host._lastControlOver[pointerId] = this;
  12883. return true;
  12884. }
  12885. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  12886. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  12887. this._host._lastControlDown[pointerId] = this;
  12888. this._host._lastPickedControl = this;
  12889. return true;
  12890. }
  12891. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  12892. if (this._host._lastControlDown[pointerId]) {
  12893. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  12894. }
  12895. delete this._host._lastControlDown[pointerId];
  12896. return true;
  12897. }
  12898. return false;
  12899. };
  12900. /** @hidden */
  12901. Control3D.prototype._disposeNode = function () {
  12902. if (this._node) {
  12903. this._node.dispose();
  12904. this._node = null;
  12905. }
  12906. };
  12907. /**
  12908. * Releases all associated resources
  12909. */
  12910. Control3D.prototype.dispose = function () {
  12911. this.onPointerDownObservable.clear();
  12912. this.onPointerEnterObservable.clear();
  12913. this.onPointerMoveObservable.clear();
  12914. this.onPointerOutObservable.clear();
  12915. this.onPointerUpObservable.clear();
  12916. this.onPointerClickObservable.clear();
  12917. this._disposeNode();
  12918. // Behaviors
  12919. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  12920. var behavior = _a[_i];
  12921. behavior.detach();
  12922. }
  12923. };
  12924. return Control3D;
  12925. }());
  12926. /***/ }),
  12927. /***/ "./3D/controls/cylinderPanel.ts":
  12928. /*!**************************************!*\
  12929. !*** ./3D/controls/cylinderPanel.ts ***!
  12930. \**************************************/
  12931. /*! exports provided: CylinderPanel */
  12932. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12933. "use strict";
  12934. __webpack_require__.r(__webpack_exports__);
  12935. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  12936. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12937. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  12938. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  12939. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  12940. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  12941. /**
  12942. * Class used to create a container panel deployed on the surface of a cylinder
  12943. */
  12944. var CylinderPanel = /** @class */ (function (_super) {
  12945. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CylinderPanel, _super);
  12946. function CylinderPanel() {
  12947. var _this = _super !== null && _super.apply(this, arguments) || this;
  12948. _this._radius = 5.0;
  12949. return _this;
  12950. }
  12951. Object.defineProperty(CylinderPanel.prototype, "radius", {
  12952. /**
  12953. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  12954. */
  12955. get: function () {
  12956. return this._radius;
  12957. },
  12958. set: function (value) {
  12959. var _this = this;
  12960. if (this._radius === value) {
  12961. return;
  12962. }
  12963. this._radius = value;
  12964. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  12965. _this._arrangeChildren();
  12966. });
  12967. },
  12968. enumerable: true,
  12969. configurable: true
  12970. });
  12971. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  12972. var mesh = control.mesh;
  12973. if (!mesh) {
  12974. return;
  12975. }
  12976. var newPos = this._cylindricalMapping(nodePosition);
  12977. control.position = newPos;
  12978. switch (this.orientation) {
  12979. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  12980. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  12981. break;
  12982. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  12983. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  12984. break;
  12985. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  12986. break;
  12987. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  12988. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  12989. break;
  12990. }
  12991. };
  12992. CylinderPanel.prototype._cylindricalMapping = function (source) {
  12993. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  12994. var yAngle = (source.x / this._radius);
  12995. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  12996. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  12997. };
  12998. return CylinderPanel;
  12999. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13000. /***/ }),
  13001. /***/ "./3D/controls/holographicButton.ts":
  13002. /*!******************************************!*\
  13003. !*** ./3D/controls/holographicButton.ts ***!
  13004. \******************************************/
  13005. /*! exports provided: HolographicButton */
  13006. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13007. "use strict";
  13008. __webpack_require__.r(__webpack_exports__);
  13009. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  13010. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13011. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13012. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  13013. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__);
  13014. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  13015. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  13016. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  13017. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  13018. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  13019. /**
  13020. * Class used to create a holographic button in 3D
  13021. */
  13022. var HolographicButton = /** @class */ (function (_super) {
  13023. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HolographicButton, _super);
  13024. /**
  13025. * Creates a new button
  13026. * @param name defines the control name
  13027. */
  13028. function HolographicButton(name, shareMaterials) {
  13029. if (shareMaterials === void 0) { shareMaterials = true; }
  13030. var _this = _super.call(this, name) || this;
  13031. _this._shareMaterials = true;
  13032. _this._shareMaterials = shareMaterials;
  13033. // Default animations
  13034. _this.pointerEnterAnimation = function () {
  13035. if (!_this.mesh) {
  13036. return;
  13037. }
  13038. _this._frontPlate.setEnabled(true);
  13039. };
  13040. _this.pointerOutAnimation = function () {
  13041. if (!_this.mesh) {
  13042. return;
  13043. }
  13044. _this._frontPlate.setEnabled(false);
  13045. };
  13046. return _this;
  13047. }
  13048. HolographicButton.prototype._disposeTooltip = function () {
  13049. this._tooltipFade = null;
  13050. if (this._tooltipTextBlock) {
  13051. this._tooltipTextBlock.dispose();
  13052. }
  13053. if (this._tooltipTexture) {
  13054. this._tooltipTexture.dispose();
  13055. }
  13056. if (this._tooltipMesh) {
  13057. this._tooltipMesh.dispose();
  13058. }
  13059. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  13060. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  13061. };
  13062. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  13063. get: function () {
  13064. if (this._tooltipTextBlock) {
  13065. return this._tooltipTextBlock.text;
  13066. }
  13067. return null;
  13068. },
  13069. /**
  13070. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  13071. */
  13072. set: function (text) {
  13073. var _this = this;
  13074. if (!text) {
  13075. this._disposeTooltip();
  13076. return;
  13077. }
  13078. if (!this._tooltipFade) {
  13079. // Create tooltip with mesh and text
  13080. this._tooltipMesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["MeshBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  13081. 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);
  13082. var mat = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  13083. mat.diffuseColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  13084. tooltipBackground.material = mat;
  13085. tooltipBackground.isPickable = false;
  13086. this._tooltipMesh.addChild(tooltipBackground);
  13087. tooltipBackground.position.z = 0.05;
  13088. this._tooltipMesh.scaling.y = 1 / 3;
  13089. this._tooltipMesh.position.y = 0.7;
  13090. this._tooltipMesh.position.z = -0.15;
  13091. this._tooltipMesh.isPickable = false;
  13092. this._tooltipMesh.parent = this._backPlate;
  13093. // Create text texture for the tooltip
  13094. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  13095. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  13096. this._tooltipTextBlock.scaleY = 3;
  13097. this._tooltipTextBlock.color = "white";
  13098. this._tooltipTextBlock.fontSize = 130;
  13099. this._tooltipTexture.addControl(this._tooltipTextBlock);
  13100. // Add hover action to tooltip
  13101. this._tooltipFade = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  13102. this._tooltipFade.delay = 500;
  13103. this._tooltipMesh.addBehavior(this._tooltipFade);
  13104. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  13105. if (_this._tooltipFade) {
  13106. _this._tooltipFade.fadeIn(true);
  13107. }
  13108. });
  13109. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  13110. if (_this._tooltipFade) {
  13111. _this._tooltipFade.fadeIn(false);
  13112. }
  13113. });
  13114. }
  13115. if (this._tooltipTextBlock) {
  13116. this._tooltipTextBlock.text = text;
  13117. }
  13118. },
  13119. enumerable: true,
  13120. configurable: true
  13121. });
  13122. Object.defineProperty(HolographicButton.prototype, "text", {
  13123. /**
  13124. * Gets or sets text for the button
  13125. */
  13126. get: function () {
  13127. return this._text;
  13128. },
  13129. set: function (value) {
  13130. if (this._text === value) {
  13131. return;
  13132. }
  13133. this._text = value;
  13134. this._rebuildContent();
  13135. },
  13136. enumerable: true,
  13137. configurable: true
  13138. });
  13139. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  13140. /**
  13141. * Gets or sets the image url for the button
  13142. */
  13143. get: function () {
  13144. return this._imageUrl;
  13145. },
  13146. set: function (value) {
  13147. if (this._imageUrl === value) {
  13148. return;
  13149. }
  13150. this._imageUrl = value;
  13151. this._rebuildContent();
  13152. },
  13153. enumerable: true,
  13154. configurable: true
  13155. });
  13156. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  13157. /**
  13158. * Gets the back material used by this button
  13159. */
  13160. get: function () {
  13161. return this._backMaterial;
  13162. },
  13163. enumerable: true,
  13164. configurable: true
  13165. });
  13166. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  13167. /**
  13168. * Gets the front material used by this button
  13169. */
  13170. get: function () {
  13171. return this._frontMaterial;
  13172. },
  13173. enumerable: true,
  13174. configurable: true
  13175. });
  13176. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  13177. /**
  13178. * Gets the plate material used by this button
  13179. */
  13180. get: function () {
  13181. return this._plateMaterial;
  13182. },
  13183. enumerable: true,
  13184. configurable: true
  13185. });
  13186. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  13187. /**
  13188. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  13189. */
  13190. get: function () {
  13191. return this._shareMaterials;
  13192. },
  13193. enumerable: true,
  13194. configurable: true
  13195. });
  13196. HolographicButton.prototype._getTypeName = function () {
  13197. return "HolographicButton";
  13198. };
  13199. HolographicButton.prototype._rebuildContent = function () {
  13200. this._disposeFacadeTexture();
  13201. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  13202. panel.isVertical = true;
  13203. if (this._imageUrl) {
  13204. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  13205. image.source = this._imageUrl;
  13206. image.paddingTop = "40px";
  13207. image.height = "180px";
  13208. image.width = "100px";
  13209. image.paddingBottom = "40px";
  13210. panel.addControl(image);
  13211. }
  13212. if (this._text) {
  13213. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  13214. text.text = this._text;
  13215. text.color = "white";
  13216. text.height = "30px";
  13217. text.fontSize = 24;
  13218. panel.addControl(text);
  13219. }
  13220. if (this._frontPlate) {
  13221. this.content = panel;
  13222. }
  13223. };
  13224. // Mesh association
  13225. HolographicButton.prototype._createNode = function (scene) {
  13226. this._backPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["MeshBuilder"].CreateBox(this.name + "BackMesh", {
  13227. width: 1.0,
  13228. height: 1.0,
  13229. depth: 0.08
  13230. }, scene);
  13231. this._frontPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["MeshBuilder"].CreateBox(this.name + "FrontMesh", {
  13232. width: 1.0,
  13233. height: 1.0,
  13234. depth: 0.08
  13235. }, scene);
  13236. this._frontPlate.parent = this._backPlate;
  13237. this._frontPlate.position.z = -0.08;
  13238. this._frontPlate.isPickable = false;
  13239. this._frontPlate.setEnabled(false);
  13240. this._textPlate = _super.prototype._createNode.call(this, scene);
  13241. this._textPlate.parent = this._backPlate;
  13242. this._textPlate.position.z = -0.08;
  13243. this._textPlate.isPickable = false;
  13244. return this._backPlate;
  13245. };
  13246. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  13247. this._plateMaterial.emissiveTexture = facadeTexture;
  13248. this._plateMaterial.opacityTexture = facadeTexture;
  13249. };
  13250. HolographicButton.prototype._createBackMaterial = function (mesh) {
  13251. var _this = this;
  13252. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  13253. this._backMaterial.renderHoverLight = true;
  13254. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  13255. if (pickedPoint) {
  13256. _this._backMaterial.hoverPosition = pickedPoint;
  13257. _this._backMaterial.hoverColor.a = 1.0;
  13258. }
  13259. else {
  13260. _this._backMaterial.hoverColor.a = 0;
  13261. }
  13262. });
  13263. };
  13264. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  13265. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  13266. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  13267. this._frontMaterial.alpha = 0.5; // Additive
  13268. this._frontMaterial.renderBorders = true;
  13269. };
  13270. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  13271. this._plateMaterial = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  13272. this._plateMaterial.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  13273. };
  13274. HolographicButton.prototype._affectMaterial = function (mesh) {
  13275. // Back
  13276. if (this._shareMaterials) {
  13277. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  13278. this._createBackMaterial(mesh);
  13279. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  13280. }
  13281. else {
  13282. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  13283. }
  13284. // Front
  13285. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  13286. this._createFrontMaterial(mesh);
  13287. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  13288. }
  13289. else {
  13290. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  13291. }
  13292. }
  13293. else {
  13294. this._createBackMaterial(mesh);
  13295. this._createFrontMaterial(mesh);
  13296. }
  13297. this._createPlateMaterial(mesh);
  13298. this._backPlate.material = this._backMaterial;
  13299. this._frontPlate.material = this._frontMaterial;
  13300. this._textPlate.material = this._plateMaterial;
  13301. this._rebuildContent();
  13302. };
  13303. /**
  13304. * Releases all associated resources
  13305. */
  13306. HolographicButton.prototype.dispose = function () {
  13307. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  13308. this._disposeTooltip();
  13309. if (!this.shareMaterials) {
  13310. this._backMaterial.dispose();
  13311. this._frontMaterial.dispose();
  13312. this._plateMaterial.dispose();
  13313. if (this._pickedPointObserver) {
  13314. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  13315. this._pickedPointObserver = null;
  13316. }
  13317. }
  13318. };
  13319. return HolographicButton;
  13320. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  13321. /***/ }),
  13322. /***/ "./3D/controls/index.ts":
  13323. /*!******************************!*\
  13324. !*** ./3D/controls/index.ts ***!
  13325. \******************************/
  13326. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel */
  13327. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13328. "use strict";
  13329. __webpack_require__.r(__webpack_exports__);
  13330. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  13331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  13332. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  13334. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  13336. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13337. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  13338. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  13339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  13340. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  13341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  13342. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  13343. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  13344. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  13345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  13346. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  13347. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  13348. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  13349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  13350. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  13351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  13352. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__["VolumeBasedPanel"]; });
  13354. /***/ }),
  13355. /***/ "./3D/controls/meshButton3D.ts":
  13356. /*!*************************************!*\
  13357. !*** ./3D/controls/meshButton3D.ts ***!
  13358. \*************************************/
  13359. /*! exports provided: MeshButton3D */
  13360. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13361. "use strict";
  13362. __webpack_require__.r(__webpack_exports__);
  13363. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  13364. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13365. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13366. /**
  13367. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  13368. */
  13369. var MeshButton3D = /** @class */ (function (_super) {
  13370. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MeshButton3D, _super);
  13371. /**
  13372. * Creates a new 3D button based on a mesh
  13373. * @param mesh mesh to become a 3D button
  13374. * @param name defines the control name
  13375. */
  13376. function MeshButton3D(mesh, name) {
  13377. var _this = _super.call(this, name) || this;
  13378. _this._currentMesh = mesh;
  13379. /**
  13380. * Provides a default behavior on hover/out & up/down
  13381. * Override those function to create your own desired behavior specific to your mesh
  13382. */
  13383. _this.pointerEnterAnimation = function () {
  13384. if (!_this.mesh) {
  13385. return;
  13386. }
  13387. _this.mesh.scaling.scaleInPlace(1.1);
  13388. };
  13389. _this.pointerOutAnimation = function () {
  13390. if (!_this.mesh) {
  13391. return;
  13392. }
  13393. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  13394. };
  13395. _this.pointerDownAnimation = function () {
  13396. if (!_this.mesh) {
  13397. return;
  13398. }
  13399. _this.mesh.scaling.scaleInPlace(0.95);
  13400. };
  13401. _this.pointerUpAnimation = function () {
  13402. if (!_this.mesh) {
  13403. return;
  13404. }
  13405. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  13406. };
  13407. return _this;
  13408. }
  13409. MeshButton3D.prototype._getTypeName = function () {
  13410. return "MeshButton3D";
  13411. };
  13412. // Mesh association
  13413. MeshButton3D.prototype._createNode = function (scene) {
  13414. var _this = this;
  13415. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  13416. mesh.metadata = _this;
  13417. });
  13418. return this._currentMesh;
  13419. };
  13420. MeshButton3D.prototype._affectMaterial = function (mesh) {
  13421. };
  13422. return MeshButton3D;
  13423. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  13424. /***/ }),
  13425. /***/ "./3D/controls/planePanel.ts":
  13426. /*!***********************************!*\
  13427. !*** ./3D/controls/planePanel.ts ***!
  13428. \***********************************/
  13429. /*! exports provided: PlanePanel */
  13430. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13431. "use strict";
  13432. __webpack_require__.r(__webpack_exports__);
  13433. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  13434. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13435. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  13436. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  13437. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13438. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13439. /**
  13440. * Class used to create a container panel deployed on the surface of a plane
  13441. */
  13442. var PlanePanel = /** @class */ (function (_super) {
  13443. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlanePanel, _super);
  13444. function PlanePanel() {
  13445. return _super !== null && _super.apply(this, arguments) || this;
  13446. }
  13447. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  13448. var mesh = control.mesh;
  13449. if (!mesh) {
  13450. return;
  13451. }
  13452. control.position = nodePosition.clone();
  13453. var target = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  13454. target.copyFrom(nodePosition);
  13455. switch (this.orientation) {
  13456. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  13457. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  13458. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  13459. mesh.lookAt(target);
  13460. break;
  13461. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13462. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13463. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  13464. mesh.lookAt(target);
  13465. break;
  13466. }
  13467. };
  13468. return PlanePanel;
  13469. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  13470. /***/ }),
  13471. /***/ "./3D/controls/scatterPanel.ts":
  13472. /*!*************************************!*\
  13473. !*** ./3D/controls/scatterPanel.ts ***!
  13474. \*************************************/
  13475. /*! exports provided: ScatterPanel */
  13476. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13477. "use strict";
  13478. __webpack_require__.r(__webpack_exports__);
  13479. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  13480. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13481. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  13482. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13483. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13484. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13485. /**
  13486. * Class used to create a container panel where items get randomized planar mapping
  13487. */
  13488. var ScatterPanel = /** @class */ (function (_super) {
  13489. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScatterPanel, _super);
  13490. function ScatterPanel() {
  13491. var _this = _super !== null && _super.apply(this, arguments) || this;
  13492. _this._iteration = 100.0;
  13493. return _this;
  13494. }
  13495. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  13496. /**
  13497. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  13498. */
  13499. get: function () {
  13500. return this._iteration;
  13501. },
  13502. set: function (value) {
  13503. var _this = this;
  13504. if (this._iteration === value) {
  13505. return;
  13506. }
  13507. this._iteration = value;
  13508. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13509. _this._arrangeChildren();
  13510. });
  13511. },
  13512. enumerable: true,
  13513. configurable: true
  13514. });
  13515. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  13516. var mesh = control.mesh;
  13517. var newPos = this._scatterMapping(nodePosition);
  13518. if (!mesh) {
  13519. return;
  13520. }
  13521. switch (this.orientation) {
  13522. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13523. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13524. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  13525. break;
  13526. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13527. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13528. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  13529. break;
  13530. }
  13531. control.position = newPos;
  13532. };
  13533. ScatterPanel.prototype._scatterMapping = function (source) {
  13534. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  13535. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  13536. return source;
  13537. };
  13538. ScatterPanel.prototype._finalProcessing = function () {
  13539. var meshes = [];
  13540. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13541. var child = _a[_i];
  13542. if (!child.mesh) {
  13543. continue;
  13544. }
  13545. meshes.push(child.mesh);
  13546. }
  13547. for (var count = 0; count < this._iteration; count++) {
  13548. meshes.sort(function (a, b) {
  13549. var distance1 = a.position.lengthSquared();
  13550. var distance2 = b.position.lengthSquared();
  13551. if (distance1 < distance2) {
  13552. return 1;
  13553. }
  13554. else if (distance1 > distance2) {
  13555. return -1;
  13556. }
  13557. return 0;
  13558. });
  13559. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  13560. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  13561. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector2[0];
  13562. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  13563. for (var i = 0; i < meshes.length - 1; i++) {
  13564. for (var j = i + 1; j < meshes.length; j++) {
  13565. if (i != j) {
  13566. meshes[j].position.subtractToRef(meshes[i].position, difference);
  13567. // Ignore Z axis
  13568. difference2D.x = difference.x;
  13569. difference2D.y = difference.y;
  13570. var combinedRadius = cellSize;
  13571. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  13572. var minSeparation = Math.min(distance, radiusPaddingSquared);
  13573. distance -= minSeparation;
  13574. if (distance < (Math.pow(combinedRadius, 2.0))) {
  13575. difference2D.normalize();
  13576. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  13577. meshes[j].position.addInPlace(difference);
  13578. meshes[i].position.subtractInPlace(difference);
  13579. }
  13580. }
  13581. }
  13582. }
  13583. }
  13584. };
  13585. return ScatterPanel;
  13586. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13587. /***/ }),
  13588. /***/ "./3D/controls/spherePanel.ts":
  13589. /*!************************************!*\
  13590. !*** ./3D/controls/spherePanel.ts ***!
  13591. \************************************/
  13592. /*! exports provided: SpherePanel */
  13593. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13594. "use strict";
  13595. __webpack_require__.r(__webpack_exports__);
  13596. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  13597. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13598. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  13599. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13600. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13601. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13602. /**
  13603. * Class used to create a container panel deployed on the surface of a sphere
  13604. */
  13605. var SpherePanel = /** @class */ (function (_super) {
  13606. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SpherePanel, _super);
  13607. function SpherePanel() {
  13608. var _this = _super !== null && _super.apply(this, arguments) || this;
  13609. _this._radius = 5.0;
  13610. return _this;
  13611. }
  13612. Object.defineProperty(SpherePanel.prototype, "radius", {
  13613. /**
  13614. * Gets or sets the radius of the sphere where to project controls (5 by default)
  13615. */
  13616. get: function () {
  13617. return this._radius;
  13618. },
  13619. set: function (value) {
  13620. var _this = this;
  13621. if (this._radius === value) {
  13622. return;
  13623. }
  13624. this._radius = value;
  13625. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13626. _this._arrangeChildren();
  13627. });
  13628. },
  13629. enumerable: true,
  13630. configurable: true
  13631. });
  13632. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  13633. var mesh = control.mesh;
  13634. if (!mesh) {
  13635. return;
  13636. }
  13637. var newPos = this._sphericalMapping(nodePosition);
  13638. control.position = newPos;
  13639. switch (this.orientation) {
  13640. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13641. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  13642. break;
  13643. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13644. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  13645. break;
  13646. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13647. break;
  13648. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13649. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  13650. break;
  13651. }
  13652. };
  13653. SpherePanel.prototype._sphericalMapping = function (source) {
  13654. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  13655. var xAngle = (source.y / this._radius);
  13656. var yAngle = -(source.x / this._radius);
  13657. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13658. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13659. };
  13660. return SpherePanel;
  13661. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13662. /***/ }),
  13663. /***/ "./3D/controls/stackPanel3D.ts":
  13664. /*!*************************************!*\
  13665. !*** ./3D/controls/stackPanel3D.ts ***!
  13666. \*************************************/
  13667. /*! exports provided: StackPanel3D */
  13668. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13669. "use strict";
  13670. __webpack_require__.r(__webpack_exports__);
  13671. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  13672. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13673. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  13674. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13675. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13676. /**
  13677. * Class used to create a stack panel in 3D on XY plane
  13678. */
  13679. var StackPanel3D = /** @class */ (function (_super) {
  13680. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StackPanel3D, _super);
  13681. /**
  13682. * Creates new StackPanel
  13683. * @param isVertical
  13684. */
  13685. function StackPanel3D(isVertical) {
  13686. if (isVertical === void 0) { isVertical = false; }
  13687. var _this = _super.call(this) || this;
  13688. _this._isVertical = false;
  13689. /**
  13690. * Gets or sets the distance between elements
  13691. */
  13692. _this.margin = 0.1;
  13693. _this._isVertical = isVertical;
  13694. return _this;
  13695. }
  13696. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  13697. /**
  13698. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  13699. */
  13700. get: function () {
  13701. return this._isVertical;
  13702. },
  13703. set: function (value) {
  13704. var _this = this;
  13705. if (this._isVertical === value) {
  13706. return;
  13707. }
  13708. this._isVertical = value;
  13709. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13710. _this._arrangeChildren();
  13711. });
  13712. },
  13713. enumerable: true,
  13714. configurable: true
  13715. });
  13716. StackPanel3D.prototype._arrangeChildren = function () {
  13717. var width = 0;
  13718. var height = 0;
  13719. var controlCount = 0;
  13720. var extendSizes = [];
  13721. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  13722. // Measure
  13723. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13724. var child = _a[_i];
  13725. if (!child.mesh) {
  13726. continue;
  13727. }
  13728. controlCount++;
  13729. child.mesh.computeWorldMatrix(true);
  13730. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13731. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  13732. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13733. extendSizes.push(extendSize);
  13734. if (this._isVertical) {
  13735. height += extendSize.y;
  13736. }
  13737. else {
  13738. width += extendSize.x;
  13739. }
  13740. }
  13741. if (this._isVertical) {
  13742. height += (controlCount - 1) * this.margin / 2;
  13743. }
  13744. else {
  13745. width += (controlCount - 1) * this.margin / 2;
  13746. }
  13747. // Arrange
  13748. var offset;
  13749. if (this._isVertical) {
  13750. offset = -height;
  13751. }
  13752. else {
  13753. offset = -width;
  13754. }
  13755. var index = 0;
  13756. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  13757. var child = _c[_b];
  13758. if (!child.mesh) {
  13759. continue;
  13760. }
  13761. controlCount--;
  13762. var extendSize = extendSizes[index++];
  13763. if (this._isVertical) {
  13764. child.position.y = offset + extendSize.y;
  13765. child.position.x = 0;
  13766. offset += extendSize.y * 2;
  13767. }
  13768. else {
  13769. child.position.x = offset + extendSize.x;
  13770. child.position.y = 0;
  13771. offset += extendSize.x * 2;
  13772. }
  13773. offset += (controlCount > 0 ? this.margin : 0);
  13774. }
  13775. };
  13776. return StackPanel3D;
  13777. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  13778. /***/ }),
  13779. /***/ "./3D/controls/volumeBasedPanel.ts":
  13780. /*!*****************************************!*\
  13781. !*** ./3D/controls/volumeBasedPanel.ts ***!
  13782. \*****************************************/
  13783. /*! exports provided: VolumeBasedPanel */
  13784. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13785. "use strict";
  13786. __webpack_require__.r(__webpack_exports__);
  13787. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  13788. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13789. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  13790. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13791. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13792. /**
  13793. * Abstract class used to create a container panel deployed on the surface of a volume
  13794. */
  13795. var VolumeBasedPanel = /** @class */ (function (_super) {
  13796. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VolumeBasedPanel, _super);
  13797. /**
  13798. * Creates new VolumeBasedPanel
  13799. */
  13800. function VolumeBasedPanel() {
  13801. var _this = _super.call(this) || this;
  13802. _this._columns = 10;
  13803. _this._rows = 0;
  13804. _this._rowThenColum = true;
  13805. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  13806. /**
  13807. * Gets or sets the distance between elements
  13808. */
  13809. _this.margin = 0;
  13810. return _this;
  13811. }
  13812. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  13813. /**
  13814. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  13815. * | Value | Type | Description |
  13816. * | ----- | ----------------------------------- | ----------- |
  13817. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  13818. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  13819. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  13820. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  13821. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  13822. */
  13823. get: function () {
  13824. return this._orientation;
  13825. },
  13826. set: function (value) {
  13827. var _this = this;
  13828. if (this._orientation === value) {
  13829. return;
  13830. }
  13831. this._orientation = value;
  13832. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13833. _this._arrangeChildren();
  13834. });
  13835. },
  13836. enumerable: true,
  13837. configurable: true
  13838. });
  13839. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  13840. /**
  13841. * Gets or sets the number of columns requested (10 by default).
  13842. * The panel will automatically compute the number of rows based on number of child controls.
  13843. */
  13844. get: function () {
  13845. return this._columns;
  13846. },
  13847. set: function (value) {
  13848. var _this = this;
  13849. if (this._columns === value) {
  13850. return;
  13851. }
  13852. this._columns = value;
  13853. this._rowThenColum = true;
  13854. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13855. _this._arrangeChildren();
  13856. });
  13857. },
  13858. enumerable: true,
  13859. configurable: true
  13860. });
  13861. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  13862. /**
  13863. * Gets or sets a the number of rows requested.
  13864. * The panel will automatically compute the number of columns based on number of child controls.
  13865. */
  13866. get: function () {
  13867. return this._rows;
  13868. },
  13869. set: function (value) {
  13870. var _this = this;
  13871. if (this._rows === value) {
  13872. return;
  13873. }
  13874. this._rows = value;
  13875. this._rowThenColum = false;
  13876. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13877. _this._arrangeChildren();
  13878. });
  13879. },
  13880. enumerable: true,
  13881. configurable: true
  13882. });
  13883. VolumeBasedPanel.prototype._arrangeChildren = function () {
  13884. this._cellWidth = 0;
  13885. this._cellHeight = 0;
  13886. var rows = 0;
  13887. var columns = 0;
  13888. var controlCount = 0;
  13889. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  13890. // Measure
  13891. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13892. var child = _a[_i];
  13893. if (!child.mesh) {
  13894. continue;
  13895. }
  13896. controlCount++;
  13897. child.mesh.computeWorldMatrix(true);
  13898. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  13899. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  13900. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  13901. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  13902. boundingBox.max.subtractToRef(boundingBox.min, diff);
  13903. diff.scaleInPlace(0.5);
  13904. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  13905. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  13906. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  13907. }
  13908. this._cellWidth += this.margin * 2;
  13909. this._cellHeight += this.margin * 2;
  13910. // Arrange
  13911. if (this._rowThenColum) {
  13912. columns = this._columns;
  13913. rows = Math.ceil(controlCount / this._columns);
  13914. }
  13915. else {
  13916. rows = this._rows;
  13917. columns = Math.ceil(controlCount / this._rows);
  13918. }
  13919. var startOffsetX = (columns * 0.5) * this._cellWidth;
  13920. var startOffsetY = (rows * 0.5) * this._cellHeight;
  13921. var nodeGrid = [];
  13922. var cellCounter = 0;
  13923. if (this._rowThenColum) {
  13924. for (var r = 0; r < rows; r++) {
  13925. for (var c = 0; c < columns; c++) {
  13926. 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));
  13927. cellCounter++;
  13928. if (cellCounter > controlCount) {
  13929. break;
  13930. }
  13931. }
  13932. }
  13933. }
  13934. else {
  13935. for (var c = 0; c < columns; c++) {
  13936. for (var r = 0; r < rows; r++) {
  13937. 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));
  13938. cellCounter++;
  13939. if (cellCounter > controlCount) {
  13940. break;
  13941. }
  13942. }
  13943. }
  13944. }
  13945. cellCounter = 0;
  13946. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  13947. var child = _c[_b];
  13948. if (!child.mesh) {
  13949. continue;
  13950. }
  13951. this._mapGridNode(child, nodeGrid[cellCounter]);
  13952. cellCounter++;
  13953. }
  13954. this._finalProcessing();
  13955. };
  13956. /** Child classes can implement this function to provide additional processing */
  13957. VolumeBasedPanel.prototype._finalProcessing = function () {
  13958. };
  13959. return VolumeBasedPanel;
  13960. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  13961. /***/ }),
  13962. /***/ "./3D/gui3DManager.ts":
  13963. /*!****************************!*\
  13964. !*** ./3D/gui3DManager.ts ***!
  13965. \****************************/
  13966. /*! exports provided: GUI3DManager */
  13967. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13968. "use strict";
  13969. __webpack_require__.r(__webpack_exports__);
  13970. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  13971. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  13972. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  13973. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  13974. /**
  13975. * Class used to manage 3D user interface
  13976. * @see http://doc.babylonjs.com/how_to/gui3d
  13977. */
  13978. var GUI3DManager = /** @class */ (function () {
  13979. /**
  13980. * Creates a new GUI3DManager
  13981. * @param scene
  13982. */
  13983. function GUI3DManager(scene) {
  13984. var _this = this;
  13985. /** @hidden */
  13986. this._lastControlOver = {};
  13987. /** @hidden */
  13988. this._lastControlDown = {};
  13989. /**
  13990. * Observable raised when the point picked by the pointer events changed
  13991. */
  13992. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13993. // Shared resources
  13994. /** @hidden */
  13995. this._sharedMaterials = {};
  13996. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  13997. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  13998. _this._sceneDisposeObserver = null;
  13999. _this._utilityLayer = null;
  14000. _this.dispose();
  14001. });
  14002. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  14003. this._utilityLayer.onlyCheckPointerDownEvents = false;
  14004. this._utilityLayer.pickUtilitySceneFirst = false;
  14005. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  14006. return mesh && mesh.metadata && mesh.metadata._node;
  14007. };
  14008. // Root
  14009. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  14010. this._rootContainer._host = this;
  14011. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  14012. // Events
  14013. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  14014. _this._handlePointerOut(pointerId, true);
  14015. });
  14016. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  14017. _this._doPicking(pi);
  14018. });
  14019. // Scene
  14020. this._utilityLayer.utilityLayerScene.autoClear = false;
  14021. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  14022. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  14023. }
  14024. Object.defineProperty(GUI3DManager.prototype, "scene", {
  14025. /** Gets the hosting scene */
  14026. get: function () {
  14027. return this._scene;
  14028. },
  14029. enumerable: true,
  14030. configurable: true
  14031. });
  14032. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  14033. /** Gets associated utility layer */
  14034. get: function () {
  14035. return this._utilityLayer;
  14036. },
  14037. enumerable: true,
  14038. configurable: true
  14039. });
  14040. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  14041. var previousControlOver = this._lastControlOver[pointerId];
  14042. if (previousControlOver) {
  14043. previousControlOver._onPointerOut(previousControlOver);
  14044. delete this._lastControlOver[pointerId];
  14045. }
  14046. if (isPointerUp) {
  14047. if (this._lastControlDown[pointerId]) {
  14048. this._lastControlDown[pointerId].forcePointerUp();
  14049. delete this._lastControlDown[pointerId];
  14050. }
  14051. }
  14052. this.onPickedPointChangedObservable.notifyObservers(null);
  14053. };
  14054. GUI3DManager.prototype._doPicking = function (pi) {
  14055. if (!this._utilityLayer || !this._utilityLayer.utilityLayerScene.activeCamera) {
  14056. return false;
  14057. }
  14058. var pointerEvent = (pi.event);
  14059. var pointerId = pointerEvent.pointerId || 0;
  14060. var buttonIndex = pointerEvent.button;
  14061. var pickingInfo = pi.pickInfo;
  14062. if (!pickingInfo || !pickingInfo.hit) {
  14063. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  14064. return false;
  14065. }
  14066. var control = (pickingInfo.pickedMesh.metadata);
  14067. if (pickingInfo.pickedPoint) {
  14068. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  14069. }
  14070. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  14071. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  14072. if (this._lastControlOver[pointerId]) {
  14073. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  14074. }
  14075. delete this._lastControlOver[pointerId];
  14076. }
  14077. }
  14078. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  14079. if (this._lastControlDown[pointerEvent.pointerId]) {
  14080. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  14081. delete this._lastControlDown[pointerEvent.pointerId];
  14082. }
  14083. if (pointerEvent.pointerType === "touch") {
  14084. this._handlePointerOut(pointerId, false);
  14085. }
  14086. }
  14087. return true;
  14088. };
  14089. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  14090. /**
  14091. * Gets the root container
  14092. */
  14093. get: function () {
  14094. return this._rootContainer;
  14095. },
  14096. enumerable: true,
  14097. configurable: true
  14098. });
  14099. /**
  14100. * Gets a boolean indicating if the given control is in the root child list
  14101. * @param control defines the control to check
  14102. * @returns true if the control is in the root child list
  14103. */
  14104. GUI3DManager.prototype.containsControl = function (control) {
  14105. return this._rootContainer.containsControl(control);
  14106. };
  14107. /**
  14108. * Adds a control to the root child list
  14109. * @param control defines the control to add
  14110. * @returns the current manager
  14111. */
  14112. GUI3DManager.prototype.addControl = function (control) {
  14113. this._rootContainer.addControl(control);
  14114. return this;
  14115. };
  14116. /**
  14117. * Removes a control from the root child list
  14118. * @param control defines the control to remove
  14119. * @returns the current container
  14120. */
  14121. GUI3DManager.prototype.removeControl = function (control) {
  14122. this._rootContainer.removeControl(control);
  14123. return this;
  14124. };
  14125. /**
  14126. * Releases all associated resources
  14127. */
  14128. GUI3DManager.prototype.dispose = function () {
  14129. this._rootContainer.dispose();
  14130. for (var materialName in this._sharedMaterials) {
  14131. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  14132. continue;
  14133. }
  14134. this._sharedMaterials[materialName].dispose();
  14135. }
  14136. this._sharedMaterials = {};
  14137. if (this._pointerOutObserver && this._utilityLayer) {
  14138. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  14139. this._pointerOutObserver = null;
  14140. }
  14141. this.onPickedPointChangedObservable.clear();
  14142. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  14143. if (utilityLayerScene) {
  14144. if (this._pointerObserver) {
  14145. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  14146. this._pointerObserver = null;
  14147. }
  14148. }
  14149. if (this._scene) {
  14150. if (this._sceneDisposeObserver) {
  14151. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  14152. this._sceneDisposeObserver = null;
  14153. }
  14154. }
  14155. if (this._utilityLayer) {
  14156. this._utilityLayer.dispose();
  14157. }
  14158. };
  14159. return GUI3DManager;
  14160. }());
  14161. /***/ }),
  14162. /***/ "./3D/index.ts":
  14163. /*!*********************!*\
  14164. !*** ./3D/index.ts ***!
  14165. \*********************/
  14166. /*! exports provided: GUI3DManager, Vector3WithInfo, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  14167. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14168. "use strict";
  14169. __webpack_require__.r(__webpack_exports__);
  14170. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  14171. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14172. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  14173. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  14174. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  14175. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  14176. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  14177. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  14178. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  14179. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  14180. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  14181. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  14182. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  14183. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  14184. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  14185. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  14186. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  14187. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  14188. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  14189. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  14190. /***/ }),
  14191. /***/ "./3D/materials/fluentMaterial.ts":
  14192. /*!****************************************!*\
  14193. !*** ./3D/materials/fluentMaterial.ts ***!
  14194. \****************************************/
  14195. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  14196. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14197. "use strict";
  14198. __webpack_require__.r(__webpack_exports__);
  14199. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  14200. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  14201. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14202. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/observable");
  14203. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  14204. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  14205. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  14206. /** @hidden */
  14207. var FluentMaterialDefines = /** @class */ (function (_super) {
  14208. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FluentMaterialDefines, _super);
  14209. function FluentMaterialDefines() {
  14210. var _this = _super.call(this) || this;
  14211. _this.INNERGLOW = false;
  14212. _this.BORDER = false;
  14213. _this.HOVERLIGHT = false;
  14214. _this.TEXTURE = false;
  14215. _this.rebuild();
  14216. return _this;
  14217. }
  14218. return FluentMaterialDefines;
  14219. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  14220. /**
  14221. * Class used to render controls with fluent desgin
  14222. */
  14223. var FluentMaterial = /** @class */ (function (_super) {
  14224. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FluentMaterial, _super);
  14225. /**
  14226. * Creates a new Fluent material
  14227. * @param name defines the name of the material
  14228. * @param scene defines the hosting scene
  14229. */
  14230. function FluentMaterial(name, scene) {
  14231. var _this = _super.call(this, name, scene) || this;
  14232. /**
  14233. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  14234. */
  14235. _this.innerGlowColorIntensity = 0.5;
  14236. /**
  14237. * Gets or sets the inner glow color (white by default)
  14238. */
  14239. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  14240. /**
  14241. * Gets or sets alpha value (default is 1.0)
  14242. */
  14243. _this.alpha = 1.0;
  14244. /**
  14245. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  14246. */
  14247. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  14248. /**
  14249. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  14250. */
  14251. _this.renderBorders = false;
  14252. /**
  14253. * Gets or sets border width (default is 0.5)
  14254. */
  14255. _this.borderWidth = 0.5;
  14256. /**
  14257. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  14258. */
  14259. _this.edgeSmoothingValue = 0.02;
  14260. /**
  14261. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  14262. */
  14263. _this.borderMinValue = 0.1;
  14264. /**
  14265. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  14266. */
  14267. _this.renderHoverLight = false;
  14268. /**
  14269. * Gets or sets the radius used to render the hover light (default is 1.0)
  14270. */
  14271. _this.hoverRadius = 1.0;
  14272. /**
  14273. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  14274. */
  14275. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  14276. /**
  14277. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  14278. */
  14279. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  14280. return _this;
  14281. }
  14282. FluentMaterial.prototype.needAlphaBlending = function () {
  14283. return this.alpha !== 1.0;
  14284. };
  14285. FluentMaterial.prototype.needAlphaTesting = function () {
  14286. return false;
  14287. };
  14288. FluentMaterial.prototype.getAlphaTestTexture = function () {
  14289. return null;
  14290. };
  14291. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  14292. if (this.isFrozen) {
  14293. if (this._wasPreviouslyReady && subMesh.effect) {
  14294. return true;
  14295. }
  14296. }
  14297. if (!subMesh._materialDefines) {
  14298. subMesh._materialDefines = new FluentMaterialDefines();
  14299. }
  14300. var scene = this.getScene();
  14301. var defines = subMesh._materialDefines;
  14302. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  14303. if (defines._renderId === scene.getRenderId()) {
  14304. return true;
  14305. }
  14306. }
  14307. if (defines._areTexturesDirty) {
  14308. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  14309. defines.BORDER = this.renderBorders;
  14310. defines.HOVERLIGHT = this.renderHoverLight;
  14311. if (this._albedoTexture) {
  14312. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  14313. return false;
  14314. }
  14315. else {
  14316. defines.TEXTURE = true;
  14317. }
  14318. }
  14319. else {
  14320. defines.TEXTURE = false;
  14321. }
  14322. }
  14323. var engine = scene.getEngine();
  14324. // Get correct effect
  14325. if (defines.isDirty) {
  14326. defines.markAsProcessed();
  14327. scene.resetCachedMaterial();
  14328. //Attributes
  14329. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  14330. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  14331. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  14332. var shaderName = "fluent";
  14333. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  14334. "hoverColor", "hoverPosition", "hoverRadius"
  14335. ];
  14336. var samplers = ["albedoSampler"];
  14337. var uniformBuffers = new Array();
  14338. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  14339. uniformsNames: uniforms,
  14340. uniformBuffersNames: uniformBuffers,
  14341. samplers: samplers,
  14342. defines: defines,
  14343. maxSimultaneousLights: 4
  14344. });
  14345. var join = defines.toString();
  14346. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  14347. attributes: attribs,
  14348. uniformsNames: uniforms,
  14349. uniformBuffersNames: uniformBuffers,
  14350. samplers: samplers,
  14351. defines: join,
  14352. fallbacks: null,
  14353. onCompiled: this.onCompiled,
  14354. onError: this.onError,
  14355. indexParameters: { maxSimultaneousLights: 4 }
  14356. }, engine));
  14357. }
  14358. if (!subMesh.effect || !subMesh.effect.isReady()) {
  14359. return false;
  14360. }
  14361. defines._renderId = scene.getRenderId();
  14362. this._wasPreviouslyReady = true;
  14363. return true;
  14364. };
  14365. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  14366. var scene = this.getScene();
  14367. var defines = subMesh._materialDefines;
  14368. if (!defines) {
  14369. return;
  14370. }
  14371. var effect = subMesh.effect;
  14372. if (!effect) {
  14373. return;
  14374. }
  14375. this._activeEffect = effect;
  14376. // Matrices
  14377. this.bindOnlyWorldMatrix(world);
  14378. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  14379. if (this._mustRebind(scene, effect)) {
  14380. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  14381. if (defines.INNERGLOW) {
  14382. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  14383. }
  14384. if (defines.BORDER) {
  14385. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  14386. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  14387. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  14388. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0]);
  14389. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0]);
  14390. }
  14391. if (defines.HOVERLIGHT) {
  14392. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  14393. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  14394. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  14395. }
  14396. if (defines.TEXTURE) {
  14397. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  14398. }
  14399. }
  14400. this._afterBind(mesh, this._activeEffect);
  14401. };
  14402. FluentMaterial.prototype.getActiveTextures = function () {
  14403. var activeTextures = _super.prototype.getActiveTextures.call(this);
  14404. return activeTextures;
  14405. };
  14406. FluentMaterial.prototype.hasTexture = function (texture) {
  14407. if (_super.prototype.hasTexture.call(this, texture)) {
  14408. return true;
  14409. }
  14410. return false;
  14411. };
  14412. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  14413. _super.prototype.dispose.call(this, forceDisposeEffect);
  14414. };
  14415. FluentMaterial.prototype.clone = function (name) {
  14416. var _this = this;
  14417. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  14418. };
  14419. FluentMaterial.prototype.serialize = function () {
  14420. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  14421. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  14422. return serializationObject;
  14423. };
  14424. FluentMaterial.prototype.getClassName = function () {
  14425. return "FluentMaterial";
  14426. };
  14427. // Statics
  14428. FluentMaterial.Parse = function (source, scene, rootUrl) {
  14429. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  14430. };
  14431. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14432. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14433. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14434. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  14435. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14436. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  14437. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  14438. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14439. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14440. ], FluentMaterial.prototype, "alpha", void 0);
  14441. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14442. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  14443. ], FluentMaterial.prototype, "albedoColor", void 0);
  14444. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14445. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14446. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14447. ], FluentMaterial.prototype, "renderBorders", void 0);
  14448. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14449. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14450. ], FluentMaterial.prototype, "borderWidth", void 0);
  14451. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14452. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14453. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  14454. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14455. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14456. ], FluentMaterial.prototype, "borderMinValue", void 0);
  14457. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14458. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14459. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14460. ], FluentMaterial.prototype, "renderHoverLight", void 0);
  14461. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14462. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14463. ], FluentMaterial.prototype, "hoverRadius", void 0);
  14464. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14465. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  14466. ], FluentMaterial.prototype, "hoverColor", void 0);
  14467. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14468. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  14469. ], FluentMaterial.prototype, "hoverPosition", void 0);
  14470. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14471. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  14472. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  14473. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14474. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  14475. ], FluentMaterial.prototype, "albedoTexture", void 0);
  14476. return FluentMaterial;
  14477. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  14478. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  14479. /***/ }),
  14480. /***/ "./3D/materials/index.ts":
  14481. /*!*******************************!*\
  14482. !*** ./3D/materials/index.ts ***!
  14483. \*******************************/
  14484. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  14485. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14486. "use strict";
  14487. __webpack_require__.r(__webpack_exports__);
  14488. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  14489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  14490. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  14491. /***/ }),
  14492. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  14493. /*!*************************************************!*\
  14494. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  14495. \*************************************************/
  14496. /*! exports provided: fluentPixelShader */
  14497. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14498. "use strict";
  14499. __webpack_require__.r(__webpack_exports__);
  14500. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  14501. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/observable");
  14502. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  14503. var name = 'fluentPixelShader';
  14504. 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}";
  14505. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  14506. /** @hidden */
  14507. var fluentPixelShader = { name: name, shader: shader };
  14508. /***/ }),
  14509. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  14510. /*!***********************************************!*\
  14511. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  14512. \***********************************************/
  14513. /*! exports provided: fluentVertexShader */
  14514. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14515. "use strict";
  14516. __webpack_require__.r(__webpack_exports__);
  14517. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  14518. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/observable");
  14519. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  14520. var name = 'fluentVertexShader';
  14521. 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";
  14522. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  14523. /** @hidden */
  14524. var fluentVertexShader = { name: name, shader: shader };
  14525. /***/ }),
  14526. /***/ "./3D/vector3WithInfo.ts":
  14527. /*!*******************************!*\
  14528. !*** ./3D/vector3WithInfo.ts ***!
  14529. \*******************************/
  14530. /*! exports provided: Vector3WithInfo */
  14531. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14532. "use strict";
  14533. __webpack_require__.r(__webpack_exports__);
  14534. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  14535. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14536. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  14537. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  14538. /**
  14539. * Class used to transport Vector3 information for pointer events
  14540. */
  14541. var Vector3WithInfo = /** @class */ (function (_super) {
  14542. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Vector3WithInfo, _super);
  14543. /**
  14544. * Creates a new Vector3WithInfo
  14545. * @param source defines the vector3 data to transport
  14546. * @param buttonIndex defines the current mouse button index
  14547. */
  14548. function Vector3WithInfo(source,
  14549. /** defines the current mouse button index */
  14550. buttonIndex) {
  14551. if (buttonIndex === void 0) { buttonIndex = 0; }
  14552. var _this = _super.call(this, source.x, source.y, source.z) || this;
  14553. _this.buttonIndex = buttonIndex;
  14554. return _this;
  14555. }
  14556. return Vector3WithInfo;
  14557. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  14558. /***/ }),
  14559. /***/ "./index.ts":
  14560. /*!******************!*\
  14561. !*** ./index.ts ***!
  14562. \******************/
  14563. /*! 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 */
  14564. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14565. "use strict";
  14566. __webpack_require__.r(__webpack_exports__);
  14567. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  14568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  14569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  14570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  14571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  14572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  14573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  14574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  14575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  14576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  14577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  14578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  14579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  14580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  14581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  14582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  14583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  14584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  14585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  14586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  14587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  14588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  14589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  14590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  14591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  14592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  14593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  14594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  14595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  14596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  14597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  14598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  14599. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  14600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  14601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  14602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  14603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  14604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  14605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  14606. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  14607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  14608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  14609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  14610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  14611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  14612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  14613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  14614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  14615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  14616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  14617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  14618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  14619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  14620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  14621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  14622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  14623. /***/ }),
  14624. /***/ "./legacy/legacy.ts":
  14625. /*!**************************!*\
  14626. !*** ./legacy/legacy.ts ***!
  14627. \**************************/
  14628. /*! 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 */
  14629. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14630. "use strict";
  14631. __webpack_require__.r(__webpack_exports__);
  14632. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  14633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  14634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  14635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  14636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  14637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  14638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  14639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  14640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  14641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  14642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  14643. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  14644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  14645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  14646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  14647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  14648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  14649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  14650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  14651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  14652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  14653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  14654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  14655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  14656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  14657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  14658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  14659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  14660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  14661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  14662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  14663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  14664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  14665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  14666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  14667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  14668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  14669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  14670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  14671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  14672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  14673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  14675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  14676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  14677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  14678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  14679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  14680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  14681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  14682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  14683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  14684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  14685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  14686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  14687. /**
  14688. * Legacy support, defining window.BABYLON.GUI (global variable).
  14689. *
  14690. * This is the entry point for the UMD module.
  14691. * The entry point for a future ESM package should be index.ts
  14692. */
  14693. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  14694. if (typeof globalObject !== "undefined") {
  14695. globalObject.BABYLON = globalObject.BABYLON || {};
  14696. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  14697. }
  14698. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  14699. /***/ }),
  14700. /***/ "babylonjs/Misc/observable":
  14701. /*!****************************************************************************************************!*\
  14702. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  14703. \****************************************************************************************************/
  14704. /*! no static exports found */
  14705. /***/ (function(module, exports) {
  14706. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_observable__;
  14707. /***/ })
  14708. /******/ });
  14709. });
  14710. //# sourceMappingURL=babylon.gui.js.map